From 18688cdd5e45928fd55bb3f22e64b57557f1ff2b Mon Sep 17 00:00:00 2001 From: jinoosss Date: Mon, 1 Apr 2024 06:56:36 +0900 Subject: [PATCH 01/25] chore: Separate Graphql schemas --- gqlgen.yml | 22 +- serve/graph/{ => generated}/generated.go | 5025 +++++++++++++---- serve/graph/resolver.go | 77 - serve/graph/schema.graphql | 205 - serve/graph/schema.resolvers.go | 167 - .../graph/schema/filter/block_filter.graphql | 24 + .../schema/filter/transaction_filter.graphql | 215 + serve/graph/schema/query.graphql | 19 + serve/graph/schema/schema.graphql | 9 + serve/graph/schema/subscription.graphql | 29 + serve/graph/schema/types/block.graphql | 33 + serve/graph/schema/types/transaction.graphql | 103 + serve/graph/setup.go | 7 +- 13 files changed, 4477 insertions(+), 1458 deletions(-) rename serve/graph/{ => generated}/generated.go (60%) delete mode 100644 serve/graph/resolver.go delete mode 100644 serve/graph/schema.graphql delete mode 100644 serve/graph/schema.resolvers.go create mode 100644 serve/graph/schema/filter/block_filter.graphql create mode 100644 serve/graph/schema/filter/transaction_filter.graphql create mode 100644 serve/graph/schema/query.graphql create mode 100644 serve/graph/schema/schema.graphql create mode 100644 serve/graph/schema/subscription.graphql create mode 100644 serve/graph/schema/types/block.graphql create mode 100644 serve/graph/schema/types/transaction.graphql diff --git a/gqlgen.yml b/gqlgen.yml index 41131de2..aec6660b 100644 --- a/gqlgen.yml +++ b/gqlgen.yml @@ -1,11 +1,12 @@ # Where are all the schema files located? globs are supported eg src/**/*.graphql schema: - - serve/graph/*.graphql + - serve/graph/schema/*.graphql + - serve/graph/schema/**/*.graphql # Where should the generated server code go? exec: - filename: serve/graph/generated.go - package: graph + filename: serve/graph/generated/generated.go + package: generated # Where should any generated models go? model: @@ -15,8 +16,8 @@ model: # Where should the resolver implementations go? resolver: layout: follow-schema - dir: serve/graph - package: graph + dir: serve/graph/resolvers + package: resolvers filename_template: "{name}.resolvers.go" # Optional: turn on to not generate template comments above resolvers # omit_template_comment: false @@ -85,4 +86,13 @@ models: - github.com/gnolang/tx-indexer/serve/graph/model.Block Transaction: model: - - github.com/gnolang/tx-indexer/serve/graph/model.Transaction \ No newline at end of file + - github.com/gnolang/tx-indexer/serve/graph/model.Transaction + TransactionMessage: + model: + - github.com/gnolang/tx-indexer/serve/graph/model.TransactionMessage + BlockFilter: + model: + - github.com/gnolang/tx-indexer/serve/graph/model.BlockFilter + TransactionFilter: + model: + - github.com/gnolang/tx-indexer/serve/graph/model.TransactionFilter diff --git a/serve/graph/generated.go b/serve/graph/generated/generated.go similarity index 60% rename from serve/graph/generated.go rename to serve/graph/generated/generated.go index 69694fb5..281ff65d 100644 --- a/serve/graph/generated.go +++ b/serve/graph/generated/generated.go @@ -1,11 +1,10 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package graph +package generated import ( "bytes" "context" - "embed" "errors" "fmt" "io" @@ -49,6 +48,12 @@ type DirectiveRoot struct { } type ComplexityRoot struct { + BankMsgSend struct { + Amount func(childComplexity int) int + FromAddress func(childComplexity int) int + ToAddress func(childComplexity int) int + } + Block struct { ChainID func(childComplexity int) int Height func(childComplexity int) int @@ -57,6 +62,37 @@ type ComplexityRoot struct { Version func(childComplexity int) int } + MemFile struct { + Body func(childComplexity int) int + Name func(childComplexity int) int + } + + MemPackage struct { + Files func(childComplexity int) int + Name func(childComplexity int) int + Path func(childComplexity int) int + } + + MsgAddPackage struct { + Creator func(childComplexity int) int + Deposit func(childComplexity int) int + Package func(childComplexity int) int + } + + MsgCall struct { + Args func(childComplexity int) int + Caller func(childComplexity int) int + Func func(childComplexity int) int + PkgPath func(childComplexity int) int + Send func(childComplexity int) int + } + + MsgRun struct { + Caller func(childComplexity int) int + Package func(childComplexity int) int + Send func(childComplexity int) int + } + Query struct { Blocks func(childComplexity int, filter model.BlockFilter) int LatestBlockHeight func(childComplexity int) int @@ -64,8 +100,8 @@ type ComplexityRoot struct { } Subscription struct { - Blocks func(childComplexity int) int - Transactions func(childComplexity int) int + Blocks func(childComplexity int, filter model.BlockFilter) int + Transactions func(childComplexity int, filter model.TransactionFilter) int } Transaction struct { @@ -75,6 +111,19 @@ type ComplexityRoot struct { 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 + } + + TransactionMessage struct { + Route func(childComplexity int) int + TypeUrl func(childComplexity int) int + Value func(childComplexity int) int + } + + TxFee struct { + GasFee func(childComplexity int) int + GasWanted func(childComplexity int) int } } @@ -84,8 +133,8 @@ type QueryResolver interface { LatestBlockHeight(ctx context.Context) (int, error) } type SubscriptionResolver interface { - Transactions(ctx context.Context) (<-chan *model.Transaction, error) - Blocks(ctx context.Context) (<-chan *model.Block, error) + Transactions(ctx context.Context, filter model.TransactionFilter) (<-chan *model.Transaction, error) + Blocks(ctx context.Context, filter model.BlockFilter) (<-chan *model.Block, error) } type executableSchema struct { @@ -107,6 +156,27 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { + case "BankMsgSend.amount": + if e.complexity.BankMsgSend.Amount == nil { + break + } + + return e.complexity.BankMsgSend.Amount(childComplexity), true + + case "BankMsgSend.from_address": + if e.complexity.BankMsgSend.FromAddress == nil { + break + } + + return e.complexity.BankMsgSend.FromAddress(childComplexity), true + + case "BankMsgSend.to_address": + if e.complexity.BankMsgSend.ToAddress == nil { + break + } + + return e.complexity.BankMsgSend.ToAddress(childComplexity), true + case "Block.chain_id": if e.complexity.Block.ChainID == nil { break @@ -142,6 +212,118 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Block.Version(childComplexity), true + case "MemFile.Body": + if e.complexity.MemFile.Body == nil { + break + } + + return e.complexity.MemFile.Body(childComplexity), true + + case "MemFile.Name": + if e.complexity.MemFile.Name == nil { + break + } + + return e.complexity.MemFile.Name(childComplexity), true + + case "MemPackage.Files": + if e.complexity.MemPackage.Files == nil { + break + } + + return e.complexity.MemPackage.Files(childComplexity), true + + case "MemPackage.Name": + if e.complexity.MemPackage.Name == nil { + break + } + + return e.complexity.MemPackage.Name(childComplexity), true + + case "MemPackage.Path": + if e.complexity.MemPackage.Path == nil { + break + } + + return e.complexity.MemPackage.Path(childComplexity), true + + case "MsgAddPackage.creator": + if e.complexity.MsgAddPackage.Creator == nil { + break + } + + return e.complexity.MsgAddPackage.Creator(childComplexity), true + + case "MsgAddPackage.deposit": + if e.complexity.MsgAddPackage.Deposit == nil { + break + } + + return e.complexity.MsgAddPackage.Deposit(childComplexity), true + + case "MsgAddPackage.package": + if e.complexity.MsgAddPackage.Package == nil { + break + } + + return e.complexity.MsgAddPackage.Package(childComplexity), true + + case "MsgCall.args": + if e.complexity.MsgCall.Args == nil { + break + } + + return e.complexity.MsgCall.Args(childComplexity), true + + case "MsgCall.caller": + if e.complexity.MsgCall.Caller == nil { + break + } + + return e.complexity.MsgCall.Caller(childComplexity), true + + case "MsgCall.func": + if e.complexity.MsgCall.Func == nil { + break + } + + return e.complexity.MsgCall.Func(childComplexity), true + + case "MsgCall.pkg_path": + if e.complexity.MsgCall.PkgPath == nil { + break + } + + return e.complexity.MsgCall.PkgPath(childComplexity), true + + case "MsgCall.send": + if e.complexity.MsgCall.Send == nil { + break + } + + return e.complexity.MsgCall.Send(childComplexity), true + + case "MsgRun.caller": + if e.complexity.MsgRun.Caller == nil { + break + } + + return e.complexity.MsgRun.Caller(childComplexity), true + + case "MsgRun.package": + if e.complexity.MsgRun.Package == nil { + break + } + + return e.complexity.MsgRun.Package(childComplexity), true + + case "MsgRun.send": + if e.complexity.MsgRun.Send == nil { + break + } + + return e.complexity.MsgRun.Send(childComplexity), true + case "Query.blocks": if e.complexity.Query.Blocks == nil { break @@ -178,14 +360,24 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - return e.complexity.Subscription.Blocks(childComplexity), true + args, err := ec.field_Subscription_blocks_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Subscription.Blocks(childComplexity, args["filter"].(model.BlockFilter)), true case "Subscription.transactions": if e.complexity.Subscription.Transactions == nil { break } - return e.complexity.Subscription.Transactions(childComplexity), true + args, err := ec.field_Subscription_transactions_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Subscription.Transactions(childComplexity, args["filter"].(model.TransactionFilter)), true case "Transaction.block_height": if e.complexity.Transaction.BlockHeight == nil { @@ -229,6 +421,55 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Transaction.Index(childComplexity), true + case "Transaction.memo": + if e.complexity.Transaction.Memo == nil { + break + } + + return e.complexity.Transaction.Memo(childComplexity), true + + case "Transaction.messages": + if e.complexity.Transaction.Messages == nil { + break + } + + return e.complexity.Transaction.Messages(childComplexity), true + + case "TransactionMessage.route": + if e.complexity.TransactionMessage.Route == nil { + break + } + + return e.complexity.TransactionMessage.Route(childComplexity), true + + case "TransactionMessage.typeUrl": + if e.complexity.TransactionMessage.TypeUrl == nil { + break + } + + return e.complexity.TransactionMessage.TypeUrl(childComplexity), true + + case "TransactionMessage.value": + if e.complexity.TransactionMessage.Value == nil { + break + } + + return e.complexity.TransactionMessage.Value(childComplexity), true + + case "TxFee.gas_fee": + if e.complexity.TxFee.GasFee == nil { + break + } + + return e.complexity.TxFee.GasFee(childComplexity), true + + case "TxFee.gas_wanted": + if e.complexity.TxFee.GasWanted == nil { + break + } + + return e.complexity.TxFee.GasWanted(childComplexity), true + } return 0, false } @@ -237,8 +478,17 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputBankMsgSendInput, ec.unmarshalInputBlockFilter, + ec.unmarshalInputMemFileInput, + ec.unmarshalInputMemPackageInput, + ec.unmarshalInputMsgAddPackageInput, + ec.unmarshalInputMsgCallInput, + ec.unmarshalInputMsgRunInput, + ec.unmarshalInputTransactionBankMessageInput, ec.unmarshalInputTransactionFilter, + ec.unmarshalInputTransactionMessageInput, + ec.unmarshalInputTransactionVmMessageInput, ) first := true @@ -337,19 +587,446 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } -//go:embed "schema.graphql" -var sourcesFS embed.FS +var sources = []*ast.Source{ + {Name: "../schema/query.graphql", Input: `""" +Root Query type to fetch data about Blocks and Transactions based on filters or retrieve the latest block height. +""" +type Query { + """ + Retrieves a list of Transactions that match the given filter criteria. If the result is incomplete due to errors, both partial results and errors are returned. + """ + transactions(filter: TransactionFilter!): [Transaction!] + + """ + Fetches Blocks matching the specified filter criteria. Incomplete results due to errors return both the partial Blocks and the associated errors. + """ + blocks(filter: BlockFilter!): [Block!] + + """ + Returns the height of the most recently processed Block by the blockchain indexer, indicating the current length of the blockchain. + """ + latestBlockHeight: Int! +} +`, BuiltIn: false}, + {Name: "../schema/schema.graphql", Input: `schema { + query: Query + subscription: Subscription +} + +""" +Field representing a point on time. It is following the RFC3339Nano format ("2006-01-02T15:04:05.999999999Z07:00") +""" +scalar Time +`, BuiltIn: false}, + {Name: "../schema/subscription.graphql", Input: `""" +Subscriptions provide a way for clients to receive real-time updates about Transactions and Blocks based on specified filter criteria. +Subscribers will only receive updates for events occurring after the subscription is established. +""" +type Subscription { + """ + Subscribes to real-time updates of Transactions that match the provided filter criteria. + This subscription starts immediately and only includes Transactions added to the blockchain after the subscription is active. + + This is useful for applications needing to track Transactions in real-time, such as wallets tracking incoming transactions + or analytics platforms monitoring blockchain activity. + + Returns: + - Transaction: Each received update is a Transaction object that matches the filter criteria. + """ + transactions(filter: TransactionFilter!): Transaction! + + """ + Subscribes to real-time updates of Blocks that match the provided filter criteria. Similar to the Transactions subscription, + this subscription is active immediately upon creation and only includes Blocks added after the subscription begins. + + This subscription is ideal for services that need to be notified of new Blocks for processing or analysis, such as block explorers, + data aggregators, or security monitoring tools. + + Returns: + - Block: Each update consists of a Block object that satisfies the filter criteria, allowing subscribers to process or analyze new Blocks in real time. + """ + blocks(filter: BlockFilter!): Block! +} +`, BuiltIn: false}, + {Name: "../schema/filter/block_filter.graphql", Input: `""" +Filters for querying Blocks within specified criteria related to their attributes. +""" +input BlockFilter { + """ + Minimum block height from which to start fetching Blocks, inclusive. If unspecified, there is no lower bound. + """ + from_height: Int + + """ + Maximum block height up to which Blocks should be fetched, exclusive. If unspecified, there is no upper bound. + """ + to_height: Int + + """ + Minimum timestamp from which to start fetching Blocks, inclusive. Blocks created at or after this time will be included. + """ + from_time: Time + + """ + Maximum timestamp up to which to fetch Blocks, exclusive. Only Blocks created before this time are included. + """ + to_time: Time +} +`, BuiltIn: false}, + {Name: "../schema/filter/transaction_filter.graphql", Input: `""" +Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. +""" +input TransactionFilter { + """ + Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. + """ + from_block_height: Int + + """ + Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. + """ + to_block_height: Int + + """ + Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. + """ + from_index: Int + + """ + Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. + """ + to_index: Int + + """ + Minimum ` + "`" + `gas_wanted` + "`" + ` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. + """ + from_gas_wanted: Int + + """ + Maximum ` + "`" + `gas_wanted` + "`" + ` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. + """ + to_gas_wanted: Int + + """ + Minimum ` + "`" + `gas_used` + "`" + ` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. + """ + from_gas_used: Int + + """ + Maximum ` + "`" + `gas_used` + "`" + ` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. + """ + to_gas_used: Int + + """ + Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. + """ + hash: String + + """ + Transaction's message to filter Transactions. + """ + message: TransactionMessageInput + + """ + ` + "`" + `memo` + "`" + ` value to filter Transaction's memo. + """ + memo: String +} + +""" +Input for filters by transaction message. +""" +input TransactionMessageInput { + """ + The type of transaction message. + """ + type_url: MessageType + + """ + The route of transaction message. + """ + route: MessageRoute + + """ + Input parameters required when the message router type is ` + "`" + `bank` + "`" + `. + """ + bank_param: TransactionBankMessageInput + + """ + Input parameters required when the message router type is ` + "`" + `vm` + "`" + `. + """ + vm_param: TransactionVmMessageInput +} + +""" +Input parameters required when the message router is ` + "`" + `bank` + "`" + `. +""" +input TransactionBankMessageInput { + """ + Input parameters required when the message type is ` + "`" + `send` + "`" + `. + """ + send: BankMsgSendInput +} + +""" +Input parameters required when the message type is ` + "`" + `send` + "`" + `. +""" +input BankMsgSendInput { + """ + Filter by ` + "`" + `from_address` + "`" + `. + """ + from_address: String + + """ + Filter by ` + "`" + `to_address` + "`" + `. + """ + to_address: String + + """ + Filter by ` + "`" + `amount` + "`" + `. + """ + amount: String +} + +""" +Input parameters required when the message router is ` + "`" + `vm` + "`" + `. +""" +input TransactionVmMessageInput { + """ + Input parameters required when the message type is ` + "`" + `exec` + "`" + `. + """ + m_call: MsgCallInput + + """ + Input parameters required when the message type is ` + "`" + `add_package` + "`" + `. + """ + m_addpkg: MsgAddPackageInput + + """ + Input parameters required when the message type is ` + "`" + `run` + "`" + `. + """ + m_run: MsgRunInput +} + +""" +Input parameters required when the message type is ` + "`" + `exec` + "`" + `. +""" +input MsgCallInput { + """ + Filter by ` + "`" + `caller` + "`" + `. + """ + caller: String + + """ + Filter by ` + "`" + `send` + "`" + `. + """ + send: String + + """ + Filter by ` + "`" + `pkg_path` + "`" + `. + """ + pkg_path: String + + """ + Filter by ` + "`" + `func` + "`" + `. + """ + func: String + + """ + Filter by ` + "`" + `args` + "`" + `, Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + """ + args: [String!] +} + +""" +Input parameters required when the message type is ` + "`" + `add_package` + "`" + `. +""" +input MsgAddPackageInput { + """ + Filter by ` + "`" + `creator` + "`" + `. + """ + creator: String + + """ + Filter by ` + "`" + `package` + "`" + `. + """ + package: MemPackageInput + + """ + Filter by ` + "`" + `deposit` + "`" + `. + """ + deposit: String +} + +""" +Input parameters required when the message type is ` + "`" + `run` + "`" + `. +""" +input MsgRunInput { + """ + Filter by ` + "`" + `caller` + "`" + `. + """ + caller: String + + """ + Filter by ` + "`" + `send` + "`" + `. + """ + send: String + + """ + Filter by ` + "`" + `package` + "`" + `. + """ + package: MemPackageInput +} + +input MemPackageInput { + Name: String + Path: String + Files: [MemFileInput] +} + +input MemFileInput { + Name: String + Body: String +} +`, BuiltIn: false}, + {Name: "../schema/types/block.graphql", Input: `""" +Represents a blockchain block with various attributes detailing its creation and content. +""" +type Block { + """ + A unique identifier for the Block determined by its position in the blockchain. + This integer is strictly increasing with each new Block. + """ + height: Int! + + """ + The software version of the node that created this Block, indicating the specific + implementation and versioning of the blockchain protocol used. + """ + version: String! + + """ + An identifier for the specific blockchain network this Block belongs to. Helps in + distinguishing between different networks like mainnet, testnet, etc. + """ + chain_id: String! + + """ + The timestamp at which this Block was proposed and finalized in the blockchain. Represented in UTC. + """ + time: Time! + + """ + Encoded data representing the blockchain address of the proposer who submitted this Block. + It is raw and requires decoding to be human-readable. + """ + proposer_address_raw: String! +} +`, BuiltIn: false}, + {Name: "../schema/types/transaction.graphql", Input: `""" +Defines a transaction within a block, detailing its execution specifics and content. +""" +type Transaction { + """ + A sequential index representing the order of this Transaction within its Block. Unique within the context of its Block. + """ + index: Int! -func sourceData(filename string) string { - data, err := sourcesFS.ReadFile(filename) - if err != nil { - panic(fmt.Sprintf("codegen problem: %s not available", filename)) - } - return string(data) + """ + Hash from Transaction content in base64 encoding. + """ + hash: String! + + """ + The height of the Block in which this Transaction is included. Links the Transaction to its containing Block. + """ + block_height: Int! + + """ + The declared amount of computational effort the sender is willing to pay for executing this Transaction. + """ + gas_wanted: Int! + + """ + The actual amount of computational effort consumed to execute this Transaction. It could be less or equal to ` + "`" + `gas_wanted` + "`" + `. + """ + gas_used: Int! + + """ + The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. + """ + content_raw: String! + + """ + The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. + """ + messages: [TransactionMessage]! + + memo: String! } -var sources = []*ast.Source{ - {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, +enum MessageRoute { + vm + bank +} + +enum MessageType { + send + exec + add_package + run +} + +type TransactionMessage { + typeUrl: MessageType! + route: MessageRoute! + value: MessageValue! +} + +union MessageValue = BankMsgSend | MsgCall | MsgAddPackage | MsgRun + +type BankMsgSend { + from_address: String! + to_address: String! + amount: String! +} + +type MsgCall { + caller: String! + send: String! + pkg_path: String! + func: String! + args: [String!] +} + +type MsgAddPackage { + creator: String! + package: MemPackage! + deposit: String! +} + +type MsgRun { + caller: String! + send: String! + package: MemPackage! +} + +type MemPackage { + Name: String! + Path: String! + Files: [MemFile!] +} + +type MemFile { + Name: String! + Body: String! +} + +type TxFee { + gas_wanted: Int! + gas_fee: Int! +} +`, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) @@ -402,6 +1079,36 @@ func (ec *executionContext) field_Query_transactions_args(ctx context.Context, r return args, nil } +func (ec *executionContext) field_Subscription_blocks_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.BlockFilter + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalNBlockFilter2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlockFilter(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Subscription_transactions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.TransactionFilter + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalNTransactionFilter2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionFilter(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -440,8 +1147,8 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** -func (ec *executionContext) _Block_height(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_height(ctx, field) +func (ec *executionContext) _BankMsgSend_from_address(ctx context.Context, field graphql.CollectedField, obj *model.BankMsgSend) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BankMsgSend_from_address(ctx, field) if err != nil { return graphql.Null } @@ -454,7 +1161,7 @@ func (ec *executionContext) _Block_height(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Height(), nil + return obj.FromAddress, nil }) if err != nil { ec.Error(ctx, err) @@ -466,26 +1173,26 @@ func (ec *executionContext) _Block_height(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(int64) + res := resTmp.(string) fc.Result = res - return ec.marshalNInt2int64(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Block_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BankMsgSend_from_address(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Block", + Object: "BankMsgSend", 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) _Block_version(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_version(ctx, field) +func (ec *executionContext) _BankMsgSend_to_address(ctx context.Context, field graphql.CollectedField, obj *model.BankMsgSend) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BankMsgSend_to_address(ctx, field) if err != nil { return graphql.Null } @@ -498,7 +1205,7 @@ func (ec *executionContext) _Block_version(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Version(), nil + return obj.ToAddress, nil }) if err != nil { ec.Error(ctx, err) @@ -515,11 +1222,11 @@ func (ec *executionContext) _Block_version(ctx context.Context, field graphql.Co return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Block_version(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BankMsgSend_to_address(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Block", + Object: "BankMsgSend", 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") @@ -528,8 +1235,8 @@ func (ec *executionContext) fieldContext_Block_version(ctx context.Context, fiel return fc, nil } -func (ec *executionContext) _Block_chain_id(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_chain_id(ctx, field) +func (ec *executionContext) _BankMsgSend_amount(ctx context.Context, field graphql.CollectedField, obj *model.BankMsgSend) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BankMsgSend_amount(ctx, field) if err != nil { return graphql.Null } @@ -542,7 +1249,7 @@ func (ec *executionContext) _Block_chain_id(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ChainID(), nil + return obj.Amount, nil }) if err != nil { ec.Error(ctx, err) @@ -559,11 +1266,11 @@ func (ec *executionContext) _Block_chain_id(ctx context.Context, field graphql.C return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Block_chain_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BankMsgSend_amount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Block", + Object: "BankMsgSend", 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") @@ -572,8 +1279,8 @@ func (ec *executionContext) fieldContext_Block_chain_id(ctx context.Context, fie return fc, nil } -func (ec *executionContext) _Block_time(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_time(ctx, field) +func (ec *executionContext) _Block_height(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Block_height(ctx, field) if err != nil { return graphql.Null } @@ -586,7 +1293,7 @@ func (ec *executionContext) _Block_time(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Time(), nil + return obj.Height(), nil }) if err != nil { ec.Error(ctx, err) @@ -598,26 +1305,26 @@ func (ec *executionContext) _Block_time(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(int64) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNInt2int64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Block_time(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Block_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Block", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Block_proposer_address_raw(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_proposer_address_raw(ctx, field) +func (ec *executionContext) _Block_version(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Block_version(ctx, field) if err != nil { return graphql.Null } @@ -630,7 +1337,7 @@ func (ec *executionContext) _Block_proposer_address_raw(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.ProposerAddressRaw(), nil + return obj.Version(), nil }) if err != nil { ec.Error(ctx, err) @@ -647,7 +1354,7 @@ func (ec *executionContext) _Block_proposer_address_raw(ctx context.Context, fie return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Block_proposer_address_raw(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Block_version(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Block", Field: field, @@ -660,8 +1367,8 @@ func (ec *executionContext) fieldContext_Block_proposer_address_raw(ctx context. return fc, nil } -func (ec *executionContext) _Query_transactions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_transactions(ctx, field) +func (ec *executionContext) _Block_chain_id(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Block_chain_id(ctx, field) if err != nil { return graphql.Null } @@ -674,60 +1381,38 @@ func (ec *executionContext) _Query_transactions(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Transactions(rctx, fc.Args["filter"].(model.TransactionFilter)) + return obj.ChainID(), 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.Transaction) + res := resTmp.(string) fc.Result = res - return ec.marshalOTransaction2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_transactions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Block_chain_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Block", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "index": - return ec.fieldContext_Transaction_index(ctx, field) - case "hash": - return ec.fieldContext_Transaction_hash(ctx, field) - case "block_height": - return ec.fieldContext_Transaction_block_height(ctx, field) - case "gas_wanted": - return ec.fieldContext_Transaction_gas_wanted(ctx, field) - case "gas_used": - return ec.fieldContext_Transaction_gas_used(ctx, field) - case "content_raw": - return ec.fieldContext_Transaction_content_raw(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Transaction", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_transactions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_blocks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_blocks(ctx, field) +func (ec *executionContext) _Block_time(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Block_time(ctx, field) if err != nil { return graphql.Null } @@ -740,58 +1425,38 @@ func (ec *executionContext) _Query_blocks(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Blocks(rctx, fc.Args["filter"].(model.BlockFilter)) + return obj.Time(), 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.Block) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOBlock2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlockᚄ(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_blocks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Block_time(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Block", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "height": - return ec.fieldContext_Block_height(ctx, field) - case "version": - return ec.fieldContext_Block_version(ctx, field) - case "chain_id": - return ec.fieldContext_Block_chain_id(ctx, field) - case "time": - return ec.fieldContext_Block_time(ctx, field) - case "proposer_address_raw": - return ec.fieldContext_Block_proposer_address_raw(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Block", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_blocks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_latestBlockHeight(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_latestBlockHeight(ctx, field) +func (ec *executionContext) _Block_proposer_address_raw(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Block_proposer_address_raw(ctx, field) if err != nil { return graphql.Null } @@ -804,7 +1469,7 @@ func (ec *executionContext) _Query_latestBlockHeight(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 ec.resolvers.Query().LatestBlockHeight(rctx) + return obj.ProposerAddressRaw(), nil }) if err != nil { ec.Error(ctx, err) @@ -816,26 +1481,26 @@ func (ec *executionContext) _Query_latestBlockHeight(ctx context.Context, field } 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_Query_latestBlockHeight(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Block_proposer_address_raw(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Block", 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 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) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _MemFile_Name(ctx context.Context, field graphql.CollectedField, obj *model.MemFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemFile_Name(ctx, field) if err != nil { return graphql.Null } @@ -848,68 +1513,38 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return obj.Name, 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.(*introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemFile_Name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "MemFile", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) +func (ec *executionContext) _MemFile_Body(ctx context.Context, field graphql.CollectedField, obj *model.MemFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemFile_Body(ctx, field) if err != nil { return graphql.Null } @@ -922,191 +1557,126 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.Body, 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.(*introspection.Schema) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemFile_Body(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "MemFile", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Subscription_transactions(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { - fc, err := ec.fieldContext_Subscription_transactions(ctx, field) +func (ec *executionContext) _MemPackage_Name(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemPackage_Name(ctx, field) if err != nil { - return nil + return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + 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.Subscription().Transactions(rctx) + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) - return nil + return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } - return nil - } - return func(ctx context.Context) graphql.Marshaler { - select { - case res, ok := <-resTmp.(<-chan *model.Transaction): - if !ok { - return nil - } - return graphql.WriterFunc(func(w io.Writer) { - w.Write([]byte{'{'}) - graphql.MarshalString(field.Alias).MarshalGQL(w) - w.Write([]byte{':'}) - ec.marshalNTransaction2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransaction(ctx, field.Selections, res).MarshalGQL(w) - w.Write([]byte{'}'}) - }) - case <-ctx.Done(): - return nil - } + return graphql.Null } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subscription_transactions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemPackage_Name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Subscription", + Object: "MemPackage", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "index": - return ec.fieldContext_Transaction_index(ctx, field) - case "hash": - return ec.fieldContext_Transaction_hash(ctx, field) - case "block_height": - return ec.fieldContext_Transaction_block_height(ctx, field) - case "gas_wanted": - return ec.fieldContext_Transaction_gas_wanted(ctx, field) - case "gas_used": - return ec.fieldContext_Transaction_gas_used(ctx, field) - case "content_raw": - return ec.fieldContext_Transaction_content_raw(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Transaction", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Subscription_blocks(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { - fc, err := ec.fieldContext_Subscription_blocks(ctx, field) +func (ec *executionContext) _MemPackage_Path(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemPackage_Path(ctx, field) if err != nil { - return nil + return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + 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.Subscription().Blocks(rctx) + return obj.Path, nil }) if err != nil { ec.Error(ctx, err) - return nil + return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } - return nil - } - return func(ctx context.Context) graphql.Marshaler { - select { - case res, ok := <-resTmp.(<-chan *model.Block): - if !ok { - return nil - } - return graphql.WriterFunc(func(w io.Writer) { - w.Write([]byte{'{'}) - graphql.MarshalString(field.Alias).MarshalGQL(w) - w.Write([]byte{':'}) - ec.marshalNBlock2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlock(ctx, field.Selections, res).MarshalGQL(w) - w.Write([]byte{'}'}) - }) - case <-ctx.Done(): - return nil - } + return graphql.Null } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subscription_blocks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemPackage_Path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Subscription", + Object: "MemPackage", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "height": - return ec.fieldContext_Block_height(ctx, field) - case "version": - return ec.fieldContext_Block_version(ctx, field) - case "chain_id": - return ec.fieldContext_Block_chain_id(ctx, field) - case "time": - return ec.fieldContext_Block_time(ctx, field) - case "proposer_address_raw": - return ec.fieldContext_Block_proposer_address_raw(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Block", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Transaction_index(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_index(ctx, field) +func (ec *executionContext) _MemPackage_Files(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemPackage_Files(ctx, field) if err != nil { return graphql.Null } @@ -1119,38 +1689,41 @@ func (ec *executionContext) _Transaction_index(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.Index(), nil + return obj.Files, 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.(int) + res := resTmp.([]*model.MemFile) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOMemFile2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_index(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemPackage_Files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MemPackage", 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") + switch field.Name { + case "Name": + return ec.fieldContext_MemFile_Name(ctx, field) + case "Body": + return ec.fieldContext_MemFile_Body(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MemFile", field.Name) }, } return fc, nil } -func (ec *executionContext) _Transaction_hash(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_hash(ctx, field) +func (ec *executionContext) _MsgAddPackage_creator(ctx context.Context, field graphql.CollectedField, obj *model.MsgAddPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgAddPackage_creator(ctx, field) if err != nil { return graphql.Null } @@ -1163,7 +1736,7 @@ func (ec *executionContext) _Transaction_hash(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.Hash(), nil + return obj.Creator, nil }) if err != nil { ec.Error(ctx, err) @@ -1180,11 +1753,11 @@ func (ec *executionContext) _Transaction_hash(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_hash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgAddPackage_creator(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MsgAddPackage", 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") @@ -1193,8 +1766,8 @@ func (ec *executionContext) fieldContext_Transaction_hash(ctx context.Context, f return fc, nil } -func (ec *executionContext) _Transaction_block_height(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_block_height(ctx, field) +func (ec *executionContext) _MsgAddPackage_package(ctx context.Context, field graphql.CollectedField, obj *model.MsgAddPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgAddPackage_package(ctx, field) if err != nil { return graphql.Null } @@ -1207,7 +1780,7 @@ func (ec *executionContext) _Transaction_block_height(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.BlockHeight(), nil + return obj.Package, nil }) if err != nil { ec.Error(ctx, err) @@ -1219,26 +1792,34 @@ func (ec *executionContext) _Transaction_block_height(ctx context.Context, field } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*model.MemPackage) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNMemPackage2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackage(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_block_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgAddPackage_package(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MsgAddPackage", 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") + switch field.Name { + case "Name": + return ec.fieldContext_MemPackage_Name(ctx, field) + case "Path": + return ec.fieldContext_MemPackage_Path(ctx, field) + case "Files": + return ec.fieldContext_MemPackage_Files(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MemPackage", field.Name) }, } 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) _MsgAddPackage_deposit(ctx context.Context, field graphql.CollectedField, obj *model.MsgAddPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgAddPackage_deposit(ctx, field) if err != nil { return graphql.Null } @@ -1251,7 +1832,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.Deposit, nil }) if err != nil { ec.Error(ctx, err) @@ -1263,26 +1844,26 @@ func (ec *executionContext) _Transaction_gas_wanted(ctx context.Context, field g } 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_wanted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgAddPackage_deposit(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MsgAddPackage", 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_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) _MsgCall_caller(ctx context.Context, field graphql.CollectedField, obj *model.MsgCall) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgCall_caller(ctx, field) if err != nil { return graphql.Null } @@ -1295,7 +1876,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.Caller, nil }) if err != nil { ec.Error(ctx, err) @@ -1307,26 +1888,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_MsgCall_caller(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MsgCall", 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) _MsgCall_send(ctx context.Context, field graphql.CollectedField, obj *model.MsgCall) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgCall_send(ctx, field) if err != nil { return graphql.Null } @@ -1339,7 +1920,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.Send, nil }) if err != nil { ec.Error(ctx, err) @@ -1356,11 +1937,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_MsgCall_send(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MsgCall", 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") @@ -1369,8 +1950,8 @@ func (ec *executionContext) fieldContext_Transaction_content_raw(ctx context.Con return fc, nil } -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_name(ctx, field) +func (ec *executionContext) _MsgCall_pkg_path(ctx context.Context, field graphql.CollectedField, obj *model.MsgCall) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgCall_pkg_path(ctx, field) if err != nil { return graphql.Null } @@ -1383,7 +1964,7 @@ func (ec *executionContext) ___Directive_name(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.Name, nil + return obj.PkgPath, nil }) if err != nil { ec.Error(ctx, err) @@ -1400,9 +1981,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgCall_pkg_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "MsgCall", Field: field, IsMethod: false, IsResolver: false, @@ -1413,8 +1994,8 @@ func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, f return fc, nil } -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_description(ctx, field) +func (ec *executionContext) _MsgCall_func(ctx context.Context, field graphql.CollectedField, obj *model.MsgCall) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgCall_func(ctx, field) if err != nil { return graphql.Null } @@ -1427,25 +2008,28 @@ func (ec *executionContext) ___Directive_description(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.Description(), nil + return obj.Func, 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) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgCall_func(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "MsgCall", 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") @@ -1454,8 +2038,8 @@ func (ec *executionContext) fieldContext___Directive_description(ctx context.Con return fc, nil } -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_locations(ctx, field) +func (ec *executionContext) _MsgCall_args(ctx context.Context, field graphql.CollectedField, obj *model.MsgCall) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgCall_args(ctx, field) if err != nil { return graphql.Null } @@ -1468,38 +2052,35 @@ func (ec *executionContext) ___Directive_locations(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.Locations, nil + return obj.Args, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgCall_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "MsgCall", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __DirectiveLocation does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_args(ctx, field) +func (ec *executionContext) _MsgRun_caller(ctx context.Context, field graphql.CollectedField, obj *model.MsgRun) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgRun_caller(ctx, field) if err != nil { return graphql.Null } @@ -1512,7 +2093,7 @@ func (ec *executionContext) ___Directive_args(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.Args, nil + return obj.Caller, nil }) if err != nil { ec.Error(ctx, err) @@ -1524,36 +2105,26 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(string) fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgRun_caller(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "MsgRun", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) +func (ec *executionContext) _MsgRun_send(ctx context.Context, field graphql.CollectedField, obj *model.MsgRun) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgRun_send(ctx, field) if err != nil { return graphql.Null } @@ -1566,7 +2137,7 @@ func (ec *executionContext) ___Directive_isRepeatable(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.IsRepeatable, nil + return obj.Send, nil }) if err != nil { ec.Error(ctx, err) @@ -1578,26 +2149,26 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgRun_send(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "MsgRun", 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 nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_name(ctx, field) +func (ec *executionContext) _MsgRun_package(ctx context.Context, field graphql.CollectedField, obj *model.MsgRun) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgRun_package(ctx, field) if err != nil { return graphql.Null } @@ -1610,7 +2181,7 @@ func (ec *executionContext) ___EnumValue_name(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.Name, nil + return obj.Package, nil }) if err != nil { ec.Error(ctx, err) @@ -1622,26 +2193,34 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.MemPackage) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNMemPackage2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackage(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgRun_package(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "MsgRun", 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") + switch field.Name { + case "Name": + return ec.fieldContext_MemPackage_Name(ctx, field) + case "Path": + return ec.fieldContext_MemPackage_Path(ctx, field) + case "Files": + return ec.fieldContext_MemPackage_Files(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MemPackage", field.Name) }, } return fc, nil } -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_description(ctx, field) +func (ec *executionContext) _Query_transactions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_transactions(ctx, field) if err != nil { return graphql.Null } @@ -1654,7 +2233,7 @@ func (ec *executionContext) ___EnumValue_description(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.Description(), nil + return ec.resolvers.Query().Transactions(rctx, fc.Args["filter"].(model.TransactionFilter)) }) if err != nil { ec.Error(ctx, err) @@ -1663,26 +2242,55 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]*model.Transaction) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOTransaction2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_transactions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + 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") + switch field.Name { + case "index": + return ec.fieldContext_Transaction_index(ctx, field) + case "hash": + return ec.fieldContext_Transaction_hash(ctx, field) + case "block_height": + return ec.fieldContext_Transaction_block_height(ctx, field) + case "gas_wanted": + return ec.fieldContext_Transaction_gas_wanted(ctx, field) + case "gas_used": + return ec.fieldContext_Transaction_gas_used(ctx, field) + case "content_raw": + return ec.fieldContext_Transaction_content_raw(ctx, field) + case "messages": + return ec.fieldContext_Transaction_messages(ctx, field) + case "memo": + return ec.fieldContext_Transaction_memo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Transaction", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_transactions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) +func (ec *executionContext) _Query_blocks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_blocks(ctx, field) if err != nil { return graphql.Null } @@ -1695,38 +2303,58 @@ func (ec *executionContext) ___EnumValue_isDeprecated(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.IsDeprecated(), nil + return ec.resolvers.Query().Blocks(rctx, fc.Args["filter"].(model.BlockFilter)) }) 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) + res := resTmp.([]*model.Block) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOBlock2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlockᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_blocks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "height": + return ec.fieldContext_Block_height(ctx, field) + case "version": + return ec.fieldContext_Block_version(ctx, field) + case "chain_id": + return ec.fieldContext_Block_chain_id(ctx, field) + case "time": + return ec.fieldContext_Block_time(ctx, field) + case "proposer_address_raw": + return ec.fieldContext_Block_proposer_address_raw(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Block", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_blocks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) +func (ec *executionContext) _Query_latestBlockHeight(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_latestBlockHeight(ctx, field) if err != nil { return graphql.Null } @@ -1739,35 +2367,38 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return ec.resolvers.Query().LatestBlockHeight(rctx) }) 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) + res := resTmp.(int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_latestBlockHeight(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + 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 nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_name(ctx, field) +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } @@ -1780,38 +2411,68 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.introspectType(fc.Args["name"].(string)) }) 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) + res := resTmp.(*introspection.Type) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Query", 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") + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_description(ctx, field) +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) if err != nil { return graphql.Null } @@ -1824,7 +2485,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) @@ -1833,146 +2494,208 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Schema) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Query", 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") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_args(ctx, field) +func (ec *executionContext) _Subscription_transactions(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_transactions(ctx, field) if err != nil { - return graphql.Null + return nil } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + ret = nil } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return ec.resolvers.Subscription().Transactions(rctx, fc.Args["filter"].(model.TransactionFilter)) }) if err != nil { ec.Error(ctx, err) - return graphql.Null + return nil } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } - return graphql.Null + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case res, ok := <-resTmp.(<-chan *model.Transaction): + if !ok { + return nil + } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + ec.marshalNTransaction2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransaction(ctx, field.Selections, res).MarshalGQL(w) + w.Write([]byte{'}'}) + }) + case <-ctx.Done(): + return nil + } } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subscription_transactions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Subscription", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) + case "index": + return ec.fieldContext_Transaction_index(ctx, field) + case "hash": + return ec.fieldContext_Transaction_hash(ctx, field) + case "block_height": + return ec.fieldContext_Transaction_block_height(ctx, field) + case "gas_wanted": + return ec.fieldContext_Transaction_gas_wanted(ctx, field) + case "gas_used": + return ec.fieldContext_Transaction_gas_used(ctx, field) + case "content_raw": + return ec.fieldContext_Transaction_content_raw(ctx, field) + case "messages": + return ec.fieldContext_Transaction_messages(ctx, field) + case "memo": + return ec.fieldContext_Transaction_memo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Transaction", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Subscription_transactions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_type(ctx, field) +func (ec *executionContext) _Subscription_blocks(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_blocks(ctx, field) if err != nil { - return graphql.Null + return nil } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + ret = nil } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return ec.resolvers.Subscription().Blocks(rctx, fc.Args["filter"].(model.BlockFilter)) }) if err != nil { ec.Error(ctx, err) - return graphql.Null + return nil } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } - return graphql.Null + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case res, ok := <-resTmp.(<-chan *model.Block): + if !ok { + return nil + } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + ec.marshalNBlock2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlock(ctx, field.Selections, res).MarshalGQL(w) + w.Write([]byte{'}'}) + }) + case <-ctx.Done(): + return nil + } } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subscription_blocks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Subscription", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "height": + return ec.fieldContext_Block_height(ctx, field) + case "version": + return ec.fieldContext_Block_version(ctx, field) + case "chain_id": + return ec.fieldContext_Block_chain_id(ctx, field) + case "time": + return ec.fieldContext_Block_time(ctx, field) + case "proposer_address_raw": + return ec.fieldContext_Block_proposer_address_raw(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Block", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Subscription_blocks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) +func (ec *executionContext) _Transaction_index(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_index(ctx, field) if err != nil { return graphql.Null } @@ -1985,7 +2708,7 @@ func (ec *executionContext) ___Field_isDeprecated(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.IsDeprecated(), nil + return obj.Index(), nil }) if err != nil { ec.Error(ctx, err) @@ -1997,26 +2720,26 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(int) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_index(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + 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 Boolean does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) +func (ec *executionContext) _Transaction_hash(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_hash(ctx, field) if err != nil { return graphql.Null } @@ -2029,23 +2752,26 @@ func (ec *executionContext) ___Field_deprecationReason(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.DeprecationReason(), nil + return obj.Hash(), 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) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_hash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Transaction", Field: field, IsMethod: true, IsResolver: false, @@ -2056,8 +2782,8 @@ func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.C return fc, nil } -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_name(ctx, field) +func (ec *executionContext) _Transaction_block_height(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_block_height(ctx, field) if err != nil { return graphql.Null } @@ -2070,7 +2796,7 @@ func (ec *executionContext) ___InputValue_name(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.Name, nil + return obj.BlockHeight(), nil }) if err != nil { ec.Error(ctx, err) @@ -2082,26 +2808,26 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } 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___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_block_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Transaction", 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") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_description(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 } @@ -2114,35 +2840,38 @@ func (ec *executionContext) ___InputValue_description(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.Description(), nil + return obj.GasWanted(), 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) + res := resTmp.(int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_description(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: "__InputValue", + 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) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_type(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 } @@ -2155,7 +2884,7 @@ func (ec *executionContext) ___InputValue_type(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.Type, nil + return obj.GasUsed(), nil }) if err != nil { ec.Error(ctx, err) @@ -2167,48 +2896,26 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(int) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_type(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: "__InputValue", + Object: "Transaction", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_defaultValue(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 } @@ -2221,25 +2928,28 @@ func (ec *executionContext) ___InputValue_defaultValue(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.DefaultValue, nil + return obj.ContentRaw(), 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) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_defaultValue(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: "__InputValue", + Object: "Transaction", 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") @@ -2248,8 +2958,8 @@ func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.C return fc, nil } -func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_description(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 } @@ -2262,35 +2972,46 @@ func (ec *executionContext) ___Schema_description(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.Description(), nil + 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.(*string) + res := resTmp.([]*model.TransactionMessage) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNTransactionMessage2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessage(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_messages(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + 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") + 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) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_types(ctx, field) +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 } @@ -2303,7 +3024,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Memo(), nil }) if err != nil { ec.Error(ctx, err) @@ -2315,48 +3036,26 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_types(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: "__Schema", + Object: "Transaction", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_queryType(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 } @@ -2369,7 +3068,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.TypeUrl, nil }) if err != nil { ec.Error(ctx, err) @@ -2381,48 +3080,26 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(model.MessageType) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNMessageType2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_queryType(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: "__Schema", + 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 "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type MessageType does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_mutationType(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 } @@ -2435,57 +3112,38 @@ func (ec *executionContext) ___Schema_mutationType(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.MutationType(), nil + return obj.Route, 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.(*introspection.Type) + res := resTmp.(model.MessageRoute) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNMessageRoute2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_mutationType(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: "__Schema", + 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 "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type MessageRoute does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_subscriptionType(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 } @@ -2498,57 +3156,38 @@ func (ec *executionContext) ___Schema_subscriptionType(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.SubscriptionType(), nil + return obj.Value, 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.(*introspection.Type) + res := resTmp.(model.MessageValue) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNMessageValue2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageValue(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_subscriptionType(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: "__Schema", + 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 "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type MessageValue does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_directives(ctx, field) +func (ec *executionContext) _TxFee_gas_wanted(ctx context.Context, field graphql.CollectedField, obj *model.TxFee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TxFee_gas_wanted(ctx, field) if err != nil { return graphql.Null } @@ -2561,7 +3200,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.GasWanted, nil }) if err != nil { ec.Error(ctx, err) @@ -2573,38 +3212,26 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(int) fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TxFee_gas_wanted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "TxFee", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Directive_name(ctx, field) - case "description": - return ec.fieldContext___Directive_description(ctx, field) - case "locations": - return ec.fieldContext___Directive_locations(ctx, field) - case "args": - return ec.fieldContext___Directive_args(ctx, field) - case "isRepeatable": - return ec.fieldContext___Directive_isRepeatable(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_kind(ctx, field) +func (ec *executionContext) _TxFee_gas_fee(ctx context.Context, field graphql.CollectedField, obj *model.TxFee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TxFee_gas_fee(ctx, field) if err != nil { return graphql.Null } @@ -2617,7 +3244,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.GasFee, nil }) if err != nil { ec.Error(ctx, err) @@ -2629,26 +3256,26 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalN__TypeKind2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TxFee_gas_fee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "TxFee", 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 __TypeKind does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_name(ctx, field) +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { return graphql.Null } @@ -2661,25 +3288,28 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Name, 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) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", 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") @@ -2688,8 +3318,8 @@ func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field return fc, nil } -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_description(ctx, field) +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) if err != nil { return graphql.Null } @@ -2716,9 +3346,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, IsMethod: true, IsResolver: false, @@ -2729,8 +3359,8 @@ func (ec *executionContext) fieldContext___Type_description(ctx context.Context, return fc, nil } -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_fields(ctx, field) +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) if err != nil { return graphql.Null } @@ -2743,60 +3373,38 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + return obj.Locations, 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.([]introspection.Field) + res := resTmp.([]string) fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Field_name(ctx, field) - case "description": - return ec.fieldContext___Field_description(ctx, field) - case "args": - return ec.fieldContext___Field_args(ctx, field) - case "type": - return ec.fieldContext___Field_type(ctx, field) - case "isDeprecated": - return ec.fieldContext___Field_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___Field_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + return nil, errors.New("field of type __DirectiveLocation does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_interfaces(ctx, field) +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) if err != nil { return graphql.Null } @@ -2809,57 +3417,48 @@ func (ec *executionContext) ___Type_interfaces(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.Interfaces(), nil + return obj.Args, 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.([]introspection.Type) + res := resTmp.([]introspection.InputValue) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) case "name": - return ec.fieldContext___Type_name(ctx, field) + return ec.fieldContext___InputValue_name(ctx, field) case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) if err != nil { return graphql.Null } @@ -2872,57 +3471,38 @@ func (ec *executionContext) ___Type_possibleTypes(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.PossibleTypes(), nil + return obj.IsRepeatable, 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.([]introspection.Type) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_enumValues(ctx, field) +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) if err != nil { return graphql.Null } @@ -2935,56 +3515,123 @@ func (ec *executionContext) ___Type_enumValues(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.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + return obj.Name, 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.([]introspection.EnumValue) + res := resTmp.(string) fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___EnumValue_name(ctx, field) - case "description": - return ec.fieldContext___EnumValue_description(ctx, field) - case "isDeprecated": - return ec.fieldContext___EnumValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___EnumValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + 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.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + 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) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + 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.IsDeprecated(), nil + }) + if err != nil { ec.Error(ctx, err) - return fc, 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___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + 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) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_inputFields(ctx, field) +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) if err != nil { return graphql.Null } @@ -2997,7 +3644,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.DeprecationReason(), nil }) if err != nil { ec.Error(ctx, err) @@ -3006,17 +3653,146 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*string) fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", + 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) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(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.Name, 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___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + 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) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(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.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", 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) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(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.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": @@ -3034,8 +3810,8 @@ func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, return fc, nil } -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_ofType(ctx, field) +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) if err != nil { return graphql.Null } @@ -3048,25 +3824,28 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.Type, 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.(*introspection.Type) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Field", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { @@ -3097,8 +3876,8 @@ func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, fiel return fc, nil } -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) if err != nil { return graphql.Null } @@ -3111,209 +3890,2048 @@ func (ec *executionContext) ___Type_specifiedByURL(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.SpecifiedByURL(), nil + return obj.IsDeprecated(), 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) + res := resTmp.(bool) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Field", 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 Boolean does not have child fields") }, } return fc, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputBlockFilter(ctx context.Context, obj interface{}) (model.BlockFilter, error) { - var it model.BlockFilter - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(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.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + 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) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(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.Name, 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___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + 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) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(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.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + 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) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(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.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(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.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(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.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + 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) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(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.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(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.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(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.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(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.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(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.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(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.Name(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + 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) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(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.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + 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) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(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.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(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.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(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.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(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.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(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.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(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.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(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.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + 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 +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputBankMsgSendInput(ctx context.Context, obj interface{}) (model.BankMsgSendInput, error) { + var it model.BankMsgSendInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"from_address", "to_address", "amount"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "from_address": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_address")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.FromAddress = data + case "to_address": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_address")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ToAddress = data + case "amount": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("amount")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Amount = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputBlockFilter(ctx context.Context, obj interface{}) (model.BlockFilter, error) { + var it model.BlockFilter + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"from_height", "to_height", "from_time", "to_time"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "from_height": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_height")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.FromHeight = data + case "to_height": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_height")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ToHeight = data + case "from_time": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_time")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.FromTime = data + case "to_time": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_time")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.ToTime = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMemFileInput(ctx context.Context, obj interface{}) (model.MemFileInput, error) { + var it model.MemFileInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"Name", "Body"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "Name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "Body": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Body")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Body = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMemPackageInput(ctx context.Context, obj interface{}) (model.MemPackageInput, error) { + var it model.MemPackageInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"Name", "Path", "Files"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "Name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "Path": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Path")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Path = data + case "Files": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Files")) + data, err := ec.unmarshalOMemFileInput2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileInput(ctx, v) + if err != nil { + return it, err + } + it.Files = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMsgAddPackageInput(ctx context.Context, obj interface{}) (model.MsgAddPackageInput, error) { + var it model.MsgAddPackageInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"creator", "package", "deposit"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "creator": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creator")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Creator = data + case "package": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("package")) + data, err := ec.unmarshalOMemPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackageInput(ctx, v) + if err != nil { + return it, err + } + it.Package = data + case "deposit": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("deposit")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Deposit = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMsgCallInput(ctx context.Context, obj interface{}) (model.MsgCallInput, error) { + var it model.MsgCallInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"caller", "send", "pkg_path", "func", "args"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "caller": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("caller")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Caller = data + case "send": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("send")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Send = data + case "pkg_path": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pkg_path")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PkgPath = data + case "func": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("func")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Func = data + case "args": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("args")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Args = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMsgRunInput(ctx context.Context, obj interface{}) (model.MsgRunInput, error) { + var it model.MsgRunInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"caller", "send", "package"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "caller": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("caller")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Caller = data + case "send": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("send")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Send = data + case "package": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("package")) + data, err := ec.unmarshalOMemPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackageInput(ctx, v) + if err != nil { + return it, err + } + it.Package = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTransactionBankMessageInput(ctx context.Context, obj interface{}) (model.TransactionBankMessageInput, error) { + var it model.TransactionBankMessageInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"send"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "send": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("send")) + data, err := ec.unmarshalOBankMsgSendInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBankMsgSendInput(ctx, v) + if err != nil { + return it, err + } + it.Send = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTransactionFilter(ctx context.Context, obj interface{}) (model.TransactionFilter, error) { + var it model.TransactionFilter + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"from_block_height", "to_block_height", "from_index", "to_index", "from_gas_wanted", "to_gas_wanted", "from_gas_used", "to_gas_used", "hash", "message", "memo"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "from_block_height": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_block_height")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.FromBlockHeight = data + case "to_block_height": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_block_height")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ToBlockHeight = data + case "from_index": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_index")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.FromIndex = data + case "to_index": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_index")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ToIndex = data + case "from_gas_wanted": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_gas_wanted")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.FromGasWanted = data + case "to_gas_wanted": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_gas_wanted")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ToGasWanted = data + case "from_gas_used": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_gas_used")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.FromGasUsed = data + case "to_gas_used": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_gas_used")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ToGasUsed = data + case "hash": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Hash = data + case "message": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("message")) + data, err := ec.unmarshalOTransactionMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessageInput(ctx, v) + if err != nil { + return it, err + } + it.Message = data + case "memo": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("memo")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Memo = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTransactionMessageInput(ctx context.Context, obj interface{}) (model.TransactionMessageInput, error) { + var it model.TransactionMessageInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"from_height", "to_height", "from_time", "to_time"} + fieldsInOrder := [...]string{"type_url", "route", "bank_param", "vm_param"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "from_height": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_height")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + case "type_url": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type_url")) + data, err := ec.unmarshalOMessageType2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx, v) if err != nil { return it, err } - it.FromHeight = data - case "to_height": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_height")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.TypeURL = data + case "route": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("route")) + data, err := ec.unmarshalOMessageRoute2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx, v) if err != nil { return it, err } - it.ToHeight = data - case "from_time": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_time")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.Route = data + case "bank_param": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bank_param")) + data, err := ec.unmarshalOTransactionBankMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionBankMessageInput(ctx, v) if err != nil { return it, err } - it.FromTime = data - case "to_time": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_time")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.BankParam = data + case "vm_param": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("vm_param")) + data, err := ec.unmarshalOTransactionVmMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionVMMessageInput(ctx, v) if err != nil { return it, err } - it.ToTime = data + it.VMParam = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTransactionVmMessageInput(ctx context.Context, obj interface{}) (model.TransactionVMMessageInput, error) { + var it model.TransactionVMMessageInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"m_call", "m_addpkg", "m_run"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "m_call": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("m_call")) + data, err := ec.unmarshalOMsgCallInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgCallInput(ctx, v) + if err != nil { + return it, err + } + it.MCall = data + case "m_addpkg": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("m_addpkg")) + data, err := ec.unmarshalOMsgAddPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgAddPackageInput(ctx, v) + if err != nil { + return it, err + } + it.MAddpkg = data + case "m_run": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("m_run")) + data, err := ec.unmarshalOMsgRunInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgRunInput(ctx, v) + if err != nil { + return it, err + } + it.MRun = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) _MessageValue(ctx context.Context, sel ast.SelectionSet, obj model.MessageValue) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case model.BankMsgSend: + return ec._BankMsgSend(ctx, sel, &obj) + case *model.BankMsgSend: + if obj == nil { + return graphql.Null + } + return ec._BankMsgSend(ctx, sel, obj) + case model.MsgCall: + return ec._MsgCall(ctx, sel, &obj) + case *model.MsgCall: + if obj == nil { + return graphql.Null + } + return ec._MsgCall(ctx, sel, obj) + case model.MsgAddPackage: + return ec._MsgAddPackage(ctx, sel, &obj) + case *model.MsgAddPackage: + if obj == nil { + return graphql.Null + } + return ec._MsgAddPackage(ctx, sel, obj) + case model.MsgRun: + return ec._MsgRun(ctx, sel, &obj) + case *model.MsgRun: + if obj == nil { + return graphql.Null + } + return ec._MsgRun(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var bankMsgSendImplementors = []string{"BankMsgSend", "MessageValue"} + +func (ec *executionContext) _BankMsgSend(ctx context.Context, sel ast.SelectionSet, obj *model.BankMsgSend) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, bankMsgSendImplementors) + + 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("BankMsgSend") + case "from_address": + out.Values[i] = ec._BankMsgSend_from_address(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "to_address": + out.Values[i] = ec._BankMsgSend_to_address(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "amount": + out.Values[i] = ec._BankMsgSend_amount(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 blockImplementors = []string{"Block"} + +func (ec *executionContext) _Block(ctx context.Context, sel ast.SelectionSet, obj *model.Block) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, blockImplementors) + + 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("Block") + case "height": + out.Values[i] = ec._Block_height(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "version": + out.Values[i] = ec._Block_version(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "chain_id": + out.Values[i] = ec._Block_chain_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "time": + out.Values[i] = ec._Block_time(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "proposer_address_raw": + out.Values[i] = ec._Block_proposer_address_raw(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 memFileImplementors = []string{"MemFile"} + +func (ec *executionContext) _MemFile(ctx context.Context, sel ast.SelectionSet, obj *model.MemFile) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, memFileImplementors) + + 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("MemFile") + case "Name": + out.Values[i] = ec._MemFile_Name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Body": + out.Values[i] = ec._MemFile_Body(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 memPackageImplementors = []string{"MemPackage"} + +func (ec *executionContext) _MemPackage(ctx context.Context, sel ast.SelectionSet, obj *model.MemPackage) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, memPackageImplementors) + + 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("MemPackage") + case "Name": + out.Values[i] = ec._MemPackage_Name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Path": + out.Values[i] = ec._MemPackage_Path(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Files": + out.Values[i] = ec._MemPackage_Files(ctx, field, obj) + 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 it, nil + return out } -func (ec *executionContext) unmarshalInputTransactionFilter(ctx context.Context, obj interface{}) (model.TransactionFilter, error) { - var it model.TransactionFilter - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } +var msgAddPackageImplementors = []string{"MsgAddPackage", "MessageValue"} - fieldsInOrder := [...]string{"from_block_height", "to_block_height", "from_index", "to_index", "from_gas_wanted", "to_gas_wanted", "from_gas_used", "to_gas_used", "hash"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "from_block_height": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_block_height")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.FromBlockHeight = data - case "to_block_height": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_block_height")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ToBlockHeight = data - case "from_index": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_index")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.FromIndex = data - case "to_index": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_index")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ToIndex = data - case "from_gas_wanted": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_gas_wanted")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.FromGasWanted = data - case "to_gas_wanted": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_gas_wanted")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ToGasWanted = data - case "from_gas_used": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_gas_used")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err +func (ec *executionContext) _MsgAddPackage(ctx context.Context, sel ast.SelectionSet, obj *model.MsgAddPackage) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, msgAddPackageImplementors) + + 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("MsgAddPackage") + case "creator": + out.Values[i] = ec._MsgAddPackage_creator(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - it.FromGasUsed = data - case "to_gas_used": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_gas_used")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err + case "package": + out.Values[i] = ec._MsgAddPackage_package(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - it.ToGasUsed = data - case "hash": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err + case "deposit": + out.Values[i] = ec._MsgAddPackage_deposit(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - it.Hash = data + default: + panic("unknown field " + strconv.Quote(field.Name)) } } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } - return it, nil -} - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** + atomic.AddInt32(&ec.deferred, int32(len(deferred))) -// endregion ************************** interface.gotpl *************************** + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } -// region **************************** object.gotpl **************************** + return out +} -var blockImplementors = []string{"Block"} +var msgCallImplementors = []string{"MsgCall", "MessageValue"} -func (ec *executionContext) _Block(ctx context.Context, sel ast.SelectionSet, obj *model.Block) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, blockImplementors) +func (ec *executionContext) _MsgCall(ctx context.Context, sel ast.SelectionSet, obj *model.MsgCall) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, msgCallImplementors) 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("Block") - case "height": - out.Values[i] = ec._Block_height(ctx, field, obj) + out.Values[i] = graphql.MarshalString("MsgCall") + case "caller": + out.Values[i] = ec._MsgCall_caller(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "version": - out.Values[i] = ec._Block_version(ctx, field, obj) + case "send": + out.Values[i] = ec._MsgCall_send(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "chain_id": - out.Values[i] = ec._Block_chain_id(ctx, field, obj) + case "pkg_path": + out.Values[i] = ec._MsgCall_pkg_path(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "time": - out.Values[i] = ec._Block_time(ctx, field, obj) + case "func": + out.Values[i] = ec._MsgCall_func(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "proposer_address_raw": - out.Values[i] = ec._Block_proposer_address_raw(ctx, field, obj) + case "args": + out.Values[i] = ec._MsgCall_args(ctx, field, obj) + 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 msgRunImplementors = []string{"MsgRun", "MessageValue"} + +func (ec *executionContext) _MsgRun(ctx context.Context, sel ast.SelectionSet, obj *model.MsgRun) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, msgRunImplementors) + + 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("MsgRun") + case "caller": + out.Values[i] = ec._MsgRun_caller(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "send": + out.Values[i] = ec._MsgRun_send(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "package": + out.Values[i] = ec._MsgRun_package(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -3499,17 +6117,120 @@ func (ec *executionContext) _Transaction(ctx context.Context, sel ast.SelectionS out.Invalids++ } case "gas_wanted": - out.Values[i] = ec._Transaction_gas_wanted(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "gas_used": - out.Values[i] = ec._Transaction_gas_used(ctx, field, obj) + out.Values[i] = ec._Transaction_gas_wanted(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "gas_used": + out.Values[i] = ec._Transaction_gas_used(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "content_raw": + out.Values[i] = ec._Transaction_content_raw(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "messages": + out.Values[i] = ec._Transaction_messages(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "memo": + out.Values[i] = ec._Transaction_memo(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 transactionMessageImplementors = []string{"TransactionMessage"} + +func (ec *executionContext) _TransactionMessage(ctx context.Context, sel ast.SelectionSet, obj *model.TransactionMessage) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, transactionMessageImplementors) + + 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("TransactionMessage") + case "typeUrl": + out.Values[i] = ec._TransactionMessage_typeUrl(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "route": + out.Values[i] = ec._TransactionMessage_route(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "value": + out.Values[i] = ec._TransactionMessage_value(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 { + fields := graphql.CollectFields(ec.OperationContext, sel, txFeeImplementors) + + 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("TxFee") + case "gas_wanted": + out.Values[i] = ec._TxFee_gas_wanted(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "content_raw": - out.Values[i] = ec._Transaction_content_raw(ctx, field, obj) + case "gas_fee": + out.Values[i] = ec._TxFee_gas_fee(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -3926,6 +6647,56 @@ func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.Selec return res } +func (ec *executionContext) marshalNMemFile2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFile(ctx context.Context, sel ast.SelectionSet, v *model.MemFile) 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._MemFile(ctx, sel, v) +} + +func (ec *executionContext) marshalNMemPackage2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackage(ctx context.Context, sel ast.SelectionSet, v *model.MemPackage) 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._MemPackage(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNMessageRoute2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx context.Context, v interface{}) (model.MessageRoute, error) { + var res model.MessageRoute + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNMessageRoute2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx context.Context, sel ast.SelectionSet, v model.MessageRoute) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNMessageType2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx context.Context, v interface{}) (model.MessageType, error) { + var res model.MessageType + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNMessageType2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx context.Context, sel ast.SelectionSet, v model.MessageType) graphql.Marshaler { + return v +} + +func (ec *executionContext) marshalNMessageValue2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageValue(ctx context.Context, sel ast.SelectionSet, v model.MessageValue) 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._MessageValue(ctx, sel, v) +} + func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) @@ -3975,6 +6746,44 @@ func (ec *executionContext) unmarshalNTransactionFilter2githubᚗcomᚋgnolang return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNTransactionMessage2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessage(ctx context.Context, sel ast.SelectionSet, v []*model.TransactionMessage) 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.marshalOTransactionMessage2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessage(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + 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) } @@ -4228,6 +7037,14 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return res } +func (ec *executionContext) unmarshalOBankMsgSendInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBankMsgSendInput(ctx context.Context, v interface{}) (*model.BankMsgSendInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputBankMsgSendInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOBlock2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlockᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Block) graphql.Marshaler { if v == nil { return graphql.Null @@ -4317,6 +7134,183 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return res } +func (ec *executionContext) marshalOMemFile2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.MemFile) 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.marshalNMemFile2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFile(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) unmarshalOMemFileInput2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileInput(ctx context.Context, v interface{}) ([]*model.MemFileInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*model.MemFileInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOMemFileInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOMemFileInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileInput(ctx context.Context, v interface{}) (*model.MemFileInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMemFileInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOMemPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackageInput(ctx context.Context, v interface{}) (*model.MemPackageInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMemPackageInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOMessageRoute2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx context.Context, v interface{}) (*model.MessageRoute, error) { + if v == nil { + return nil, nil + } + var res = new(model.MessageRoute) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOMessageRoute2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx context.Context, sel ast.SelectionSet, v *model.MessageRoute) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOMessageType2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx context.Context, v interface{}) (*model.MessageType, error) { + if v == nil { + return nil, nil + } + var res = new(model.MessageType) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOMessageType2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx context.Context, sel ast.SelectionSet, v *model.MessageType) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOMsgAddPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgAddPackageInput(ctx context.Context, v interface{}) (*model.MsgAddPackageInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMsgAddPackageInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOMsgCallInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgCallInput(ctx context.Context, v interface{}) (*model.MsgCallInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMsgCallInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOMsgRunInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgRunInput(ctx context.Context, v interface{}) (*model.MsgRunInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMsgRunInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + if v == nil { + return nil, nil + } + 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) marshalOString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + 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) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil @@ -4396,6 +7390,37 @@ func (ec *executionContext) marshalOTransaction2ᚕᚖgithubᚗcomᚋgnolangᚋt return ret } +func (ec *executionContext) unmarshalOTransactionBankMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionBankMessageInput(ctx context.Context, v interface{}) (*model.TransactionBankMessageInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputTransactionBankMessageInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOTransactionMessage2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessage(ctx context.Context, sel ast.SelectionSet, v *model.TransactionMessage) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._TransactionMessage(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOTransactionMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessageInput(ctx context.Context, v interface{}) (*model.TransactionMessageInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputTransactionMessageInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOTransactionVmMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionVMMessageInput(ctx context.Context, v interface{}) (*model.TransactionVMMessageInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputTransactionVmMessageInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/serve/graph/resolver.go b/serve/graph/resolver.go deleted file mode 100644 index 8241fc3b..00000000 --- a/serve/graph/resolver.go +++ /dev/null @@ -1,77 +0,0 @@ -//go:generate go run github.com/99designs/gqlgen generate - -package graph - -import ( - "context" - "fmt" - - "github.com/99designs/gqlgen/graphql" - - "github.com/gnolang/tx-indexer/events" - "github.com/gnolang/tx-indexer/storage" - "github.com/gnolang/tx-indexer/types" -) - -// This file will not be regenerated automatically. -// -// It serves as dependency injection for your app, add any dependencies you require here. - -const maxElementsPerQuery = 10000 - -func deref[T any](v *T) T { - if v == nil { - var zero T - - return zero - } - - return *v -} - -func handleChannel[T any]( - ctx context.Context, - m *events.Manager, - writeToChannel func(*types.NewBlock, chan<- T), -) <-chan T { - ch := make(chan T) - go func() { - defer close(ch) - - sub := m.Subscribe([]events.Type{types.NewBlockEvent}) - defer m.CancelSubscription(sub.ID) - - for { - select { - case <-ctx.Done(): - graphql.AddError(ctx, ctx.Err()) - - return - case rawE, ok := <-sub.SubCh: - if !ok { - return - } - - e, ok := rawE.GetData().(*types.NewBlock) - if !ok { - graphql.AddError(ctx, fmt.Errorf("error casting event data. Obtained event ID: %q", rawE.GetType())) - - return - } - - writeToChannel(e, ch) - } - } - }() - - return ch -} - -type Resolver struct { - store storage.Storage - manager *events.Manager -} - -func NewResolver(s storage.Storage, m *events.Manager) *Resolver { - return &Resolver{store: s, manager: m} -} diff --git a/serve/graph/schema.graphql b/serve/graph/schema.graphql deleted file mode 100644 index b166c06c..00000000 --- a/serve/graph/schema.graphql +++ /dev/null @@ -1,205 +0,0 @@ -""" -Represents a blockchain block with various attributes detailing its creation and content. -""" -type Block { - - """ - A unique identifier for the Block determined by its position in the blockchain. - This integer is strictly increasing with each new Block. - """ - height: Int! - - """ - The software version of the node that created this Block, indicating the specific - implementation and versioning of the blockchain protocol used. - """ - version: String! - - """ - An identifier for the specific blockchain network this Block belongs to. Helps in - distinguishing between different networks like mainnet, testnet, etc. - """ - chain_id: String! - - """ - The timestamp at which this Block was proposed and finalized in the blockchain. Represented in UTC. - """ - time: Time! - - """ - Encoded data representing the blockchain address of the proposer who submitted this Block. - It is raw and requires decoding to be human-readable. - """ - proposer_address_raw: String! -} - -""" -Defines a transaction within a block, detailing its execution specifics and content. -""" -type Transaction { - - """ - A sequential index representing the order of this Transaction within its Block. Unique within the context of its Block. - """ - index: Int! - - """ - Hash from Transaction content in base64 encoding. - """ - hash: String! - - """ - The height of the Block in which this Transaction is included. Links the Transaction to its containing Block. - """ - block_height: Int! - - """ - The declared amount of computational effort the sender is willing to pay for executing this Transaction. - """ - gas_wanted: Int! - - """ - The actual amount of computational effort consumed to execute this Transaction. It could be less or equal to `gas_wanted`. - """ - gas_used: Int! - - """ - The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. - """ - content_raw: String! -} - -""" -Filters for querying Blocks within specified criteria related to their attributes. -""" -input BlockFilter { - - """ - Minimum block height from which to start fetching Blocks, inclusive. If unspecified, there is no lower bound. - """ - from_height: Int - - """ - Maximum block height up to which Blocks should be fetched, exclusive. If unspecified, there is no upper bound. - """ - to_height: Int - - """ - Minimum timestamp from which to start fetching Blocks, inclusive. Blocks created at or after this time will be included. - """ - from_time: Time - - """ - Maximum timestamp up to which to fetch Blocks, exclusive. Only Blocks created before this time are included. - """ - to_time: Time -} - -""" -Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. -""" -input TransactionFilter { - - """ - Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. - """ - from_block_height: Int - - """ - Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. - """ - to_block_height: Int - - """ - Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. - """ - from_index: Int - - """ - Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. - """ - to_index: Int - - """ - Minimum `gas_wanted` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. - """ - from_gas_wanted: Int - - """ - Maximum `gas_wanted` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. - """ - to_gas_wanted: Int - - """ - Minimum `gas_used` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. - """ - from_gas_used: Int - - """ - Maximum `gas_used` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. - """ - to_gas_used: Int - - """ - Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. - """ - hash: String - -} - -""" -Root Query type to fetch data about Blocks and Transactions based on filters or retrieve the latest block height. -""" -type Query { - - """ - Retrieves a list of Transactions that match the given filter criteria. If the result is incomplete due to errors, both partial results and errors are returned. - """ - transactions(filter: TransactionFilter!): [Transaction!] - - """ - Fetches Blocks matching the specified filter criteria. Incomplete results due to errors return both the partial Blocks and the associated errors. - """ - blocks(filter: BlockFilter!): [Block!] - - """ - Returns the height of the most recently processed Block by the blockchain indexer, indicating the current length of the blockchain. - """ - latestBlockHeight: Int! -} - -""" -Subscriptions provide a way for clients to receive real-time updates about Transactions and Blocks based on specified filter criteria. -Subscribers will only receive updates for events occurring after the subscription is established. -""" -type Subscription { - - """ - Subscribes to real-time updates of Transactions that match the provided filter criteria. - This subscription starts immediately and only includes Transactions added to the blockchain after the subscription is active. - - This is useful for applications needing to track Transactions in real-time, such as wallets tracking incoming transactions - or analytics platforms monitoring blockchain activity. - - Returns: - - Transaction: Each received update is a Transaction object that matches the filter criteria. - """ - transactions: Transaction! - - """ - Subscribes to real-time updates of Blocks that match the provided filter criteria. Similar to the Transactions subscription, - this subscription is active immediately upon creation and only includes Blocks added after the subscription begins. - - This subscription is ideal for services that need to be notified of new Blocks for processing or analysis, such as block explorers, - data aggregators, or security monitoring tools. - - Returns: - - Block: Each update consists of a Block object that satisfies the filter criteria, allowing subscribers to process or analyze new Blocks in real time. - """ - blocks: Block! -} - -""" -Field representing a point on time. It is following the RFC3339Nano format ("2006-01-02T15:04:05.999999999Z07:00") -""" -scalar Time diff --git a/serve/graph/schema.resolvers.go b/serve/graph/schema.resolvers.go deleted file mode 100644 index 0e2180bd..00000000 --- a/serve/graph/schema.resolvers.go +++ /dev/null @@ -1,167 +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.43 - -import ( - "context" - "math" - - "github.com/99designs/gqlgen/graphql" - "github.com/gnolang/tx-indexer/serve/graph/model" - "github.com/gnolang/tx-indexer/types" - "github.com/vektah/gqlparser/v2/gqlerror" -) - -// Transactions is the resolver for the transactions field. -func (r *queryResolver) Transactions(ctx context.Context, filter model.TransactionFilter) ([]*model.Transaction, error) { - if filter.Hash != nil { - tx, err := r.store.GetTxByHash(*filter.Hash) - if err != nil { - return nil, gqlerror.Wrap(err) - } - - return []*model.Transaction{model.NewTransaction(tx)}, nil - } - - it, err := r. - store. - TxIterator( - uint64(deref(filter.FromBlockHeight)), - uint64(deref(filter.ToBlockHeight)), - uint32(deref(filter.FromIndex)), - uint32(deref(filter.ToIndex)), - ) - if err != nil { - return nil, gqlerror.Wrap(err) - } - defer it.Close() - - fgw := deref(filter.FromGasUsed) - tgw := deref(filter.ToGasWanted) - if tgw == 0 { - tgw = math.MaxInt - } - fgu := deref(filter.FromGasUsed) - tgu := deref(filter.ToGasUsed) - if tgu == 0 { - tgu = math.MaxInt - } - - var out []*model.Transaction - i := 0 - for { - if i == maxElementsPerQuery { - graphql.AddErrorf(ctx, "max elements per query reached (%d)", maxElementsPerQuery) - return out, nil - } - - if !it.Next() { - return out, it.Error() - } - - select { - case <-ctx.Done(): - graphql.AddError(ctx, ctx.Err()) - return out, nil - default: - t, err := it.Value() - if err != nil { - graphql.AddError(ctx, err) - return out, nil - } - - if !(t.Response.GasUsed >= int64(fgu) && (t.Response.GasUsed <= int64(tgu))) { - continue - } - if !(t.Response.GasWanted >= int64(fgw) && (t.Response.GasWanted <= int64(tgw))) { - continue - } - - out = append(out, model.NewTransaction(t)) - i++ - } - } -} - -// Blocks is the resolver for the blocks field. -func (r *queryResolver) Blocks(ctx context.Context, filter model.BlockFilter) ([]*model.Block, error) { - it, err := r. - store. - BlockIterator( - uint64(deref(filter.FromHeight)), - uint64(deref(filter.ToHeight)), - ) - if err != nil { - return nil, gqlerror.Wrap(err) - } - defer it.Close() - - var out []*model.Block - - i := 0 - for { - if i == maxElementsPerQuery { - graphql.AddErrorf(ctx, "max elements per query reached (%d)", maxElementsPerQuery) - return out, nil - } - - if !it.Next() { - return out, it.Error() - } - - select { - case <-ctx.Done(): - graphql.AddError(ctx, ctx.Err()) - return out, nil - default: - b, err := it.Value() - if err != nil { - graphql.AddError(ctx, err) - return out, nil - } - - dft := deref(filter.FromTime) - dtt := deref(filter.ToTime) - - if !((b.Time.After(dft) || b.Time.Equal(dft)) && (dtt.IsZero() || b.Time.Before(dtt))) { - continue - } - - out = append(out, model.NewBlock(b)) - i++ - } - } -} - -// LatestBlockHeight is the resolver for the latestBlockHeight field. -func (r *queryResolver) LatestBlockHeight(ctx context.Context) (int, error) { - h, err := r.store.GetLatestHeight() - return int(h), err -} - -// Transactions is the resolver for the transactions field. -func (r *subscriptionResolver) Transactions(ctx context.Context) (<-chan *model.Transaction, error) { - return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Transaction) { - for _, tx := range nb.Results { - c <- model.NewTransaction(tx) - } - }), nil -} - -// Blocks is the resolver for the blocks field. -func (r *subscriptionResolver) Blocks(ctx context.Context) (<-chan *model.Block, error) { - return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Block) { - c <- model.NewBlock(nb.Block) - }), nil -} - -// Query returns QueryResolver implementation. -func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } - -// Subscription returns SubscriptionResolver implementation. -func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } - -type queryResolver struct{ *Resolver } -type subscriptionResolver struct{ *Resolver } diff --git a/serve/graph/schema/filter/block_filter.graphql b/serve/graph/schema/filter/block_filter.graphql new file mode 100644 index 00000000..b1eac178 --- /dev/null +++ b/serve/graph/schema/filter/block_filter.graphql @@ -0,0 +1,24 @@ +""" +Filters for querying Blocks within specified criteria related to their attributes. +""" +input BlockFilter { + """ + Minimum block height from which to start fetching Blocks, inclusive. If unspecified, there is no lower bound. + """ + from_height: Int + + """ + Maximum block height up to which Blocks should be fetched, exclusive. If unspecified, there is no upper bound. + """ + to_height: Int + + """ + Minimum timestamp from which to start fetching Blocks, inclusive. Blocks created at or after this time will be included. + """ + from_time: Time + + """ + Maximum timestamp up to which to fetch Blocks, exclusive. Only Blocks created before this time are included. + """ + to_time: Time +} diff --git a/serve/graph/schema/filter/transaction_filter.graphql b/serve/graph/schema/filter/transaction_filter.graphql new file mode 100644 index 00000000..1711ca51 --- /dev/null +++ b/serve/graph/schema/filter/transaction_filter.graphql @@ -0,0 +1,215 @@ +""" +Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. +""" +input TransactionFilter { + """ + Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. + """ + from_block_height: Int + + """ + Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. + """ + to_block_height: Int + + """ + Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. + """ + from_index: Int + + """ + Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. + """ + to_index: Int + + """ + Minimum `gas_wanted` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. + """ + from_gas_wanted: Int + + """ + Maximum `gas_wanted` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. + """ + to_gas_wanted: Int + + """ + Minimum `gas_used` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. + """ + from_gas_used: Int + + """ + Maximum `gas_used` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. + """ + to_gas_used: Int + + """ + Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. + """ + hash: String + + """ + Transaction's message to filter Transactions. + """ + message: TransactionMessageInput + + """ + `memo` value to filter Transaction's memo. + """ + memo: String +} + +""" +Input for filters by transaction message. +""" +input TransactionMessageInput { + """ + The type of transaction message. + """ + type_url: MessageType + + """ + The route of transaction message. + """ + route: MessageRoute + + """ + Input parameters required when the message router type is `bank`. + """ + bank_param: TransactionBankMessageInput + + """ + Input parameters required when the message router type is `vm`. + """ + vm_param: TransactionVmMessageInput +} + +""" +Input parameters required when the message router is `bank`. +""" +input TransactionBankMessageInput { + """ + Input parameters required when the message type is `send`. + """ + send: BankMsgSendInput +} + +""" +Input parameters required when the message type is `send`. +""" +input BankMsgSendInput { + """ + Filter by `from_address`. + """ + from_address: String + + """ + Filter by `to_address`. + """ + to_address: String + + """ + Filter by `amount`. + """ + amount: String +} + +""" +Input parameters required when the message router is `vm`. +""" +input TransactionVmMessageInput { + """ + Input parameters required when the message type is `exec`. + """ + m_call: MsgCallInput + + """ + Input parameters required when the message type is `add_package`. + """ + m_addpkg: MsgAddPackageInput + + """ + Input parameters required when the message type is `run`. + """ + m_run: MsgRunInput +} + +""" +Input parameters required when the message type is `exec`. +""" +input MsgCallInput { + """ + Filter by `caller`. + """ + caller: String + + """ + Filter by `send`. + """ + send: String + + """ + Filter by `pkg_path`. + """ + pkg_path: String + + """ + Filter by `func`. + """ + func: String + + """ + Filter by `args`, Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + """ + args: [String!] +} + +""" +Input parameters required when the message type is `add_package`. +""" +input MsgAddPackageInput { + """ + Filter by `creator`. + """ + creator: String + + """ + Filter by `package`. + """ + package: MemPackageInput + + """ + Filter by `deposit`. + """ + deposit: String +} + +""" +Input parameters required when the message type is `run`. +""" +input MsgRunInput { + """ + Filter by `caller`. + """ + caller: String + + """ + Filter by `send`. + """ + send: String + + """ + Filter by `package`. + """ + package: MemPackageInput +} + +input MemPackageInput { + Name: String + Path: String + Files: [MemFileInput] +} + +input MemFileInput { + Name: String + Body: String +} diff --git a/serve/graph/schema/query.graphql b/serve/graph/schema/query.graphql new file mode 100644 index 00000000..5ab9c837 --- /dev/null +++ b/serve/graph/schema/query.graphql @@ -0,0 +1,19 @@ +""" +Root Query type to fetch data about Blocks and Transactions based on filters or retrieve the latest block height. +""" +type Query { + """ + Retrieves a list of Transactions that match the given filter criteria. If the result is incomplete due to errors, both partial results and errors are returned. + """ + transactions(filter: TransactionFilter!): [Transaction!] + + """ + Fetches Blocks matching the specified filter criteria. Incomplete results due to errors return both the partial Blocks and the associated errors. + """ + blocks(filter: BlockFilter!): [Block!] + + """ + Returns the height of the most recently processed Block by the blockchain indexer, indicating the current length of the blockchain. + """ + latestBlockHeight: Int! +} diff --git a/serve/graph/schema/schema.graphql b/serve/graph/schema/schema.graphql new file mode 100644 index 00000000..2b8bc3ff --- /dev/null +++ b/serve/graph/schema/schema.graphql @@ -0,0 +1,9 @@ +schema { + query: Query + subscription: Subscription +} + +""" +Field representing a point on time. It is following the RFC3339Nano format ("2006-01-02T15:04:05.999999999Z07:00") +""" +scalar Time diff --git a/serve/graph/schema/subscription.graphql b/serve/graph/schema/subscription.graphql new file mode 100644 index 00000000..f363c8d1 --- /dev/null +++ b/serve/graph/schema/subscription.graphql @@ -0,0 +1,29 @@ +""" +Subscriptions provide a way for clients to receive real-time updates about Transactions and Blocks based on specified filter criteria. +Subscribers will only receive updates for events occurring after the subscription is established. +""" +type Subscription { + """ + Subscribes to real-time updates of Transactions that match the provided filter criteria. + This subscription starts immediately and only includes Transactions added to the blockchain after the subscription is active. + + This is useful for applications needing to track Transactions in real-time, such as wallets tracking incoming transactions + or analytics platforms monitoring blockchain activity. + + Returns: + - Transaction: Each received update is a Transaction object that matches the filter criteria. + """ + transactions(filter: TransactionFilter!): Transaction! + + """ + Subscribes to real-time updates of Blocks that match the provided filter criteria. Similar to the Transactions subscription, + this subscription is active immediately upon creation and only includes Blocks added after the subscription begins. + + This subscription is ideal for services that need to be notified of new Blocks for processing or analysis, such as block explorers, + data aggregators, or security monitoring tools. + + Returns: + - Block: Each update consists of a Block object that satisfies the filter criteria, allowing subscribers to process or analyze new Blocks in real time. + """ + blocks(filter: BlockFilter!): Block! +} diff --git a/serve/graph/schema/types/block.graphql b/serve/graph/schema/types/block.graphql new file mode 100644 index 00000000..3747ff5e --- /dev/null +++ b/serve/graph/schema/types/block.graphql @@ -0,0 +1,33 @@ +""" +Represents a blockchain block with various attributes detailing its creation and content. +""" +type Block { + """ + A unique identifier for the Block determined by its position in the blockchain. + This integer is strictly increasing with each new Block. + """ + height: Int! + + """ + The software version of the node that created this Block, indicating the specific + implementation and versioning of the blockchain protocol used. + """ + version: String! + + """ + An identifier for the specific blockchain network this Block belongs to. Helps in + distinguishing between different networks like mainnet, testnet, etc. + """ + chain_id: String! + + """ + The timestamp at which this Block was proposed and finalized in the blockchain. Represented in UTC. + """ + time: Time! + + """ + Encoded data representing the blockchain address of the proposer who submitted this Block. + It is raw and requires decoding to be human-readable. + """ + proposer_address_raw: String! +} diff --git a/serve/graph/schema/types/transaction.graphql b/serve/graph/schema/types/transaction.graphql new file mode 100644 index 00000000..1aff39ea --- /dev/null +++ b/serve/graph/schema/types/transaction.graphql @@ -0,0 +1,103 @@ +""" +Defines a transaction within a block, detailing its execution specifics and content. +""" +type Transaction { + """ + A sequential index representing the order of this Transaction within its Block. Unique within the context of its Block. + """ + index: Int! + + """ + Hash from Transaction content in base64 encoding. + """ + hash: String! + + """ + The height of the Block in which this Transaction is included. Links the Transaction to its containing Block. + """ + block_height: Int! + + """ + The declared amount of computational effort the sender is willing to pay for executing this Transaction. + """ + gas_wanted: Int! + + """ + The actual amount of computational effort consumed to execute this Transaction. It could be less or equal to `gas_wanted`. + """ + gas_used: Int! + + """ + The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. + """ + content_raw: String! + + """ + The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. + """ + messages: [TransactionMessage]! + + memo: String! +} + +enum MessageRoute { + vm + bank +} + +enum MessageType { + send + exec + add_package + run +} + +type TransactionMessage { + typeUrl: MessageType! + route: MessageRoute! + value: MessageValue! +} + +union MessageValue = BankMsgSend | MsgCall | MsgAddPackage | MsgRun + +type BankMsgSend { + from_address: String! + to_address: String! + amount: String! +} + +type MsgCall { + caller: String! + send: String! + pkg_path: String! + func: String! + args: [String!] +} + +type MsgAddPackage { + creator: String! + package: MemPackage! + deposit: String! +} + +type MsgRun { + caller: String! + send: String! + package: MemPackage! +} + +type MemPackage { + Name: String! + Path: String! + Files: [MemFile!] +} + +type MemFile { + Name: String! + Body: String! +} + +type TxFee { + gas_wanted: Int! + gas_fee: Int! +} diff --git a/serve/graph/setup.go b/serve/graph/setup.go index 787fbefc..6bc0eb76 100644 --- a/serve/graph/setup.go +++ b/serve/graph/setup.go @@ -4,14 +4,15 @@ import ( "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" - "github.com/go-chi/chi/v5" - "github.com/gnolang/tx-indexer/events" + "github.com/gnolang/tx-indexer/serve/graph/generated" + "github.com/gnolang/tx-indexer/serve/graph/resolvers" "github.com/gnolang/tx-indexer/storage" + "github.com/go-chi/chi/v5" ) func Setup(s storage.Storage, manager *events.Manager, m *chi.Mux) *chi.Mux { - srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: NewResolver(s, manager)})) + srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: resolvers.NewResolver(s, manager)})) srv.AddTransport(&transport.Websocket{}) From e687f843622d1dacb3ceb12254fe0ba569e9aa76 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Mon, 1 Apr 2024 06:52:02 +0900 Subject: [PATCH 02/25] chore: mod tidy --- go.mod | 1 + go.sum | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/go.mod b/go.mod index fb99c4a7..d1fcca45 100644 --- a/go.mod +++ b/go.mod @@ -24,6 +24,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cockroachdb/apd/v3 v3.2.1 // indirect github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect diff --git a/go.sum b/go.sum index 602516b3..dba027c7 100644 --- a/go.sum +++ b/go.sum @@ -51,6 +51,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEaIwg= +github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= @@ -176,6 +178,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= +github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/linxGnu/grocksdb v1.8.5 h1:Okfk5B1h0ikCYdDM7Tc5yJUS8LTwAmMBq5IPWTmOLPs= From 525fd6a8d2fbec5e12aaf159cbab6959d7dfeb4d Mon Sep 17 00:00:00 2001 From: jinoosss Date: Mon, 1 Apr 2024 07:02:28 +0900 Subject: [PATCH 03/25] feat: Implements transaction message encoding and message filter --- serve/graph/model/block_filter.go | 44 +++ serve/graph/model/models_gen.go | 253 ++++++++++++++--- serve/graph/model/transaction.go | 109 +++++++- serve/graph/model/transaction_filter.go | 258 ++++++++++++++++++ serve/graph/model/utils.go | 111 ++++++++ serve/graph/resolvers/query.resolvers.go | 128 +++++++++ serve/graph/resolvers/resolver.go | 76 ++++++ .../graph/resolvers/subscription.resolvers.go | 39 +++ 8 files changed, 977 insertions(+), 41 deletions(-) create mode 100644 serve/graph/model/block_filter.go create mode 100644 serve/graph/model/transaction_filter.go create mode 100644 serve/graph/model/utils.go create mode 100644 serve/graph/resolvers/query.resolvers.go create mode 100644 serve/graph/resolvers/resolver.go create mode 100644 serve/graph/resolvers/subscription.resolvers.go diff --git a/serve/graph/model/block_filter.go b/serve/graph/model/block_filter.go new file mode 100644 index 00000000..5577650e --- /dev/null +++ b/serve/graph/model/block_filter.go @@ -0,0 +1,44 @@ +package model + +import ( + "time" + + "github.com/gnolang/gno/tm2/pkg/bft/types" +) + +type BlockFilter struct { + // Minimum block height from which to start fetching Blocks, inclusive. Aids in scoping the search to recent Blocks. + FromHeight *int `json:"from_height,omitempty"` + // Maximum block height up to which Blocks should be fetched, exclusive. Helps in limiting the search to older Blocks. + ToHeight *int `json:"to_height,omitempty"` + // Minimum block create time from which to start fetching Blocks, inclusive. Aids in scoping the search to recent Blocks. + FromTime *time.Time `json:"from_time,omitempty"` + // Maximum block create time up to which Blocks should be fetched, exclusive. Helps in limiting the search to older Blocks. + ToTime *time.Time `json:"to_time,omitempty"` +} + +func (filter *BlockFilter) GetFromHeight() uint64 { + return uint64(Deref(filter.FromHeight)) +} + +func (filter *BlockFilter) GetToHeight() uint64 { + return uint64(Deref(filter.ToHeight)) +} + +func (filter *BlockFilter) GetFromTime() time.Time { + return Deref(filter.FromTime) +} + +func (filter *BlockFilter) GetToTime() time.Time { + return Deref(filter.ToTime) +} + +func (filter *BlockFilter) FilterBy(block *types.Block) bool { + return filter.filterByBlockTime(block.Time) +} + +func (filter *BlockFilter) filterByBlockTime(blockTime time.Time) bool { + fromTime := filter.GetFromTime() + toTIme := filter.GetToTime() + return (blockTime.After(fromTime) || blockTime.Equal(fromTime)) && (toTIme.IsZero() || blockTime.Before(toTIme)) +} diff --git a/serve/graph/model/models_gen.go b/serve/graph/model/models_gen.go index cd99b076..100e1de5 100644 --- a/serve/graph/model/models_gen.go +++ b/serve/graph/model/models_gen.go @@ -3,19 +3,113 @@ package model import ( - "time" + "fmt" + "io" + "strconv" ) -// Filters for querying Blocks within specified criteria related to their attributes. -type BlockFilter struct { - // Minimum block height from which to start fetching Blocks, inclusive. If unspecified, there is no lower bound. - FromHeight *int `json:"from_height,omitempty"` - // Maximum block height up to which Blocks should be fetched, exclusive. If unspecified, there is no upper bound. - ToHeight *int `json:"to_height,omitempty"` - // Minimum timestamp from which to start fetching Blocks, inclusive. Blocks created at or after this time will be included. - FromTime *time.Time `json:"from_time,omitempty"` - // Maximum timestamp up to which to fetch Blocks, exclusive. Only Blocks created before this time are included. - ToTime *time.Time `json:"to_time,omitempty"` +type MessageValue interface { + IsMessageValue() +} + +type BankMsgSend struct { + FromAddress string `json:"from_address"` + ToAddress string `json:"to_address"` + Amount string `json:"amount"` +} + +func (BankMsgSend) IsMessageValue() {} + +// Input parameters required when the message type is `send`. +type BankMsgSendInput struct { + // Filter by `from_address`. + FromAddress *string `json:"from_address,omitempty"` + // Filter by `to_address`. + ToAddress *string `json:"to_address,omitempty"` + // Filter by `amount`. + Amount *string `json:"amount,omitempty"` +} + +type MemFile struct { + Name string `json:"Name"` + Body string `json:"Body"` +} + +type MemFileInput struct { + Name *string `json:"Name,omitempty"` + Body *string `json:"Body,omitempty"` +} + +type MemPackage struct { + Name string `json:"Name"` + Path string `json:"Path"` + Files []*MemFile `json:"Files,omitempty"` +} + +type MemPackageInput struct { + Name *string `json:"Name,omitempty"` + Path *string `json:"Path,omitempty"` + Files []*MemFileInput `json:"Files,omitempty"` +} + +type MsgAddPackage struct { + Creator string `json:"creator"` + Package *MemPackage `json:"package"` + Deposit string `json:"deposit"` +} + +func (MsgAddPackage) IsMessageValue() {} + +// Input parameters required when the message type is `add_package`. +type MsgAddPackageInput struct { + // Filter by `creator`. + Creator *string `json:"creator,omitempty"` + // Filter by `package`. + Package *MemPackageInput `json:"package,omitempty"` + // Filter by `deposit`. + Deposit *string `json:"deposit,omitempty"` +} + +type MsgCall struct { + Caller string `json:"caller"` + Send string `json:"send"` + PkgPath string `json:"pkg_path"` + Func string `json:"func"` + Args []string `json:"args,omitempty"` +} + +func (MsgCall) IsMessageValue() {} + +// Input parameters required when the message type is `exec`. +type MsgCallInput struct { + // Filter by `caller`. + Caller *string `json:"caller,omitempty"` + // Filter by `send`. + Send *string `json:"send,omitempty"` + // Filter by `pkg_path`. + PkgPath *string `json:"pkg_path,omitempty"` + // Filter by `func`. + Func *string `json:"func,omitempty"` + // Filter by `args`, Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + Args []string `json:"args,omitempty"` +} + +type MsgRun struct { + Caller string `json:"caller"` + Send string `json:"send"` + Package *MemPackage `json:"package"` +} + +func (MsgRun) IsMessageValue() {} + +// Input parameters required when the message type is `run`. +type MsgRunInput struct { + // Filter by `caller`. + Caller *string `json:"caller,omitempty"` + // Filter by `send`. + Send *string `json:"send,omitempty"` + // Filter by `package`. + Package *MemPackageInput `json:"package,omitempty"` } // Root Query type to fetch data about Blocks and Transactions based on filters or retrieve the latest block height. @@ -27,24 +121,121 @@ type Query struct { type Subscription struct { } -// Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. -type TransactionFilter struct { - // Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. - FromBlockHeight *int `json:"from_block_height,omitempty"` - // Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. - ToBlockHeight *int `json:"to_block_height,omitempty"` - // Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. - FromIndex *int `json:"from_index,omitempty"` - // Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. - ToIndex *int `json:"to_index,omitempty"` - // Minimum `gas_wanted` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. - FromGasWanted *int `json:"from_gas_wanted,omitempty"` - // Maximum `gas_wanted` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. - ToGasWanted *int `json:"to_gas_wanted,omitempty"` - // Minimum `gas_used` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. - FromGasUsed *int `json:"from_gas_used,omitempty"` - // Maximum `gas_used` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. - ToGasUsed *int `json:"to_gas_used,omitempty"` - // Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. - Hash *string `json:"hash,omitempty"` +// Input parameters required when the message router is `bank`. +type TransactionBankMessageInput struct { + // Input parameters required when the message type is `send`. + Send *BankMsgSendInput `json:"send,omitempty"` +} + +// Input for filters by transaction message. +type TransactionMessageInput struct { + // The type of transaction message. + TypeURL *MessageType `json:"type_url,omitempty"` + // The route of transaction message. + Route *MessageRoute `json:"route,omitempty"` + // Input parameters required when the message router type is `bank`. + BankParam *TransactionBankMessageInput `json:"bank_param,omitempty"` + // Input parameters required when the message router type is `vm`. + VMParam *TransactionVMMessageInput `json:"vm_param,omitempty"` +} + +// Input parameters required when the message router is `vm`. +type TransactionVMMessageInput struct { + // Input parameters required when the message type is `exec`. + MCall *MsgCallInput `json:"m_call,omitempty"` + // Input parameters required when the message type is `add_package`. + MAddpkg *MsgAddPackageInput `json:"m_addpkg,omitempty"` + // Input parameters required when the message type is `run`. + MRun *MsgRunInput `json:"m_run,omitempty"` +} + +type TxFee struct { + GasWanted int `json:"gas_wanted"` + GasFee int `json:"gas_fee"` +} + +type MessageRoute string + +const ( + MessageRouteVM MessageRoute = "vm" + MessageRouteBank MessageRoute = "bank" +) + +var AllMessageRoute = []MessageRoute{ + MessageRouteVM, + MessageRouteBank, +} + +func (e MessageRoute) IsValid() bool { + switch e { + case MessageRouteVM, MessageRouteBank: + return true + } + return false +} + +func (e MessageRoute) String() string { + return string(e) +} + +func (e *MessageRoute) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MessageRoute(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MessageRoute", str) + } + return nil +} + +func (e MessageRoute) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type MessageType string + +const ( + MessageTypeSend MessageType = "send" + MessageTypeExec MessageType = "exec" + MessageTypeAddPackage MessageType = "add_package" + MessageTypeRun MessageType = "run" +) + +var AllMessageType = []MessageType{ + MessageTypeSend, + MessageTypeExec, + MessageTypeAddPackage, + MessageTypeRun, +} + +func (e MessageType) IsValid() bool { + switch e { + case MessageTypeSend, MessageTypeExec, MessageTypeAddPackage, MessageTypeRun: + return true + } + return false +} + +func (e MessageType) String() string { + return string(e) +} + +func (e *MessageType) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MessageType(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MessageType", str) + } + return nil +} + +func (e MessageType) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) } diff --git a/serve/graph/model/transaction.go b/serve/graph/model/transaction.go index ab4b9173..026d5d64 100644 --- a/serve/graph/model/transaction.go +++ b/serve/graph/model/transaction.go @@ -4,41 +4,130 @@ import ( "encoding/base64" "fmt" + "github.com/gnolang/gno/gno.land/pkg/sdk/vm" + "github.com/gnolang/gno/tm2/pkg/amino" "github.com/gnolang/gno/tm2/pkg/bft/types" + "github.com/gnolang/gno/tm2/pkg/sdk/bank" + "github.com/gnolang/gno/tm2/pkg/std" ) type Transaction struct { - t *types.TxResult + txResult *types.TxResult + messages []*TransactionMessage + memo string } -func NewTransaction(t *types.TxResult) *Transaction { - return &Transaction{t: t} +func NewTransaction(txResult *types.TxResult) *Transaction { + var stdTx std.Tx + amino.Unmarshal(txResult.Tx, &stdTx) + + messages := make([]*TransactionMessage, 0) + for _, message := range stdTx.GetMsgs() { + messages = append(messages, NewTransactionMessage(message)) + } + return &Transaction{txResult: txResult, messages: messages, memo: stdTx.GetMemo()} } func (t *Transaction) ID() string { - return fmt.Sprintf("%d_%d", t.t.Height, t.t.Index) + return fmt.Sprintf("%d_%d", t.txResult.Height, t.txResult.Index) } func (t *Transaction) Index() int { - return int(t.t.Index) + return int(t.txResult.Index) } func (t *Transaction) Hash() string { - return base64.StdEncoding.EncodeToString(t.t.Tx.Hash()) + return base64.StdEncoding.EncodeToString(t.txResult.Tx.Hash()) } func (t *Transaction) BlockHeight() int { - return int(t.t.Height) + return int(t.txResult.Height) } func (t *Transaction) GasWanted() int { - return int(t.t.Response.GasWanted) + return int(t.txResult.Response.GasWanted) } func (t *Transaction) GasUsed() int { - return int(t.t.Response.GasUsed) + return int(t.txResult.Response.GasUsed) } func (t *Transaction) ContentRaw() string { - return t.t.Tx.String() + return t.txResult.Tx.String() +} + +func (t *Transaction) Memo() string { + return t.memo +} + +func (t *Transaction) Messages() []*TransactionMessage { + return t.messages +} + +func (t *Transaction) Fee() *TxFee { + return &TxFee{ + GasWanted: t.GasWanted(), + GasFee: t.GasUsed(), + } +} + +type TransactionMessage struct { + TypeUrl MessageType + Route MessageRoute + Value MessageValue +} + +func NewTransactionMessage(message std.Msg) *TransactionMessage { + var contentMessage *TransactionMessage + + switch message.Route() { + case bank.RouterKey: + if message.Type() == MessageTypeSend.String() { + contentMessage = &TransactionMessage{ + Route: MessageRouteBank, + TypeUrl: MessageTypeSend, + Value: ParseBankMsgSend(message), + } + } + case vm.RouterKey: + if message.Type() == MessageTypeExec.String() { + contentMessage = &TransactionMessage{ + Route: MessageRouteVM, + TypeUrl: MessageTypeExec, + Value: ParseVmMsgCall(message), + } + } + if message.Type() == MessageTypeAddPackage.String() { + contentMessage = &TransactionMessage{ + Route: MessageRouteVM, + TypeUrl: MessageTypeAddPackage, + Value: ParseVmAddPackage(message), + } + } + if message.Type() == MessageTypeRun.String() { + contentMessage = &TransactionMessage{ + Route: MessageRouteVM, + TypeUrl: MessageTypeRun, + Value: ParseVmMsgRun(message), + } + } + } + + return contentMessage +} + +func (tm *TransactionMessage) BankMsgSend() BankMsgSend { + return tm.Value.(BankMsgSend) +} + +func (tm *TransactionMessage) VmMsgCall() MsgCall { + return tm.Value.(MsgCall) +} + +func (tm *TransactionMessage) VmAddPackage() MsgAddPackage { + return tm.Value.(MsgAddPackage) +} + +func (tm *TransactionMessage) VmMsgRun() MsgRun { + return tm.Value.(MsgRun) } diff --git a/serve/graph/model/transaction_filter.go b/serve/graph/model/transaction_filter.go new file mode 100644 index 00000000..0915e437 --- /dev/null +++ b/serve/graph/model/transaction_filter.go @@ -0,0 +1,258 @@ +package model + +import "math" + +// Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. +type TransactionFilter struct { + // Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. + FromBlockHeight *int `json:"from_block_height,omitempty"` + // Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. + ToBlockHeight *int `json:"to_block_height,omitempty"` + // Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. + FromIndex *int `json:"from_index,omitempty"` + // Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. + ToIndex *int `json:"to_index,omitempty"` + // Minimum `gas_wanted` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. + FromGasWanted *int `json:"from_gas_wanted,omitempty"` + // Maximum `gas_wanted` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. + ToGasWanted *int `json:"to_gas_wanted,omitempty"` + // Minimum `gas_used` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. + FromGasUsed *int `json:"from_gas_used,omitempty"` + // Maximum `gas_used` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. + ToGasUsed *int `json:"to_gas_used,omitempty"` + // Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. + Hash *string `json:"hash,omitempty"` + // Transaction's message to filter Transactions. + Message *TransactionMessageInput `json:"message,omitempty"` + // `memo` value to filter Transaction's memo. + Memo *string `json:"memo,omitempty"` +} + +func (filter *TransactionFilter) GetFromBlockHeight() uint64 { + return uint64(Deref(filter.FromBlockHeight)) +} + +func (filter *TransactionFilter) GetToBlockHeight() uint64 { + return uint64(Deref(filter.ToBlockHeight)) +} + +func (filter *TransactionFilter) GetFromIndex() uint32 { + return uint32(Deref(filter.FromIndex)) +} + +func (filter *TransactionFilter) GetToIndex() uint32 { + return uint32(Deref(filter.ToIndex)) +} + +func (filter *TransactionFilter) FilterBy(tx *Transaction) bool { + if filter == nil { + return true + } + if !filter.filterByGasUsed(tx) { + return false + } + if !filter.filterByGasWanted(tx) { + return false + } + if !filter.filterByMemo(tx) { + return false + } + if !filter.filterByMessages(tx) { + return false + } + return true +} + +func (filter *TransactionFilter) filterByGasUsed(tx *Transaction) bool { + fromGasUsed := Deref(filter.FromGasUsed) + toGasUsed := Deref(filter.ToGasUsed) + if toGasUsed == 0 { + toGasUsed = math.MaxInt + } + return tx.GasUsed() >= fromGasUsed && tx.GasUsed() <= toGasUsed +} + +func (filter *TransactionFilter) filterByGasWanted(tx *Transaction) bool { + fromGasWanted := Deref(filter.FromGasWanted) + toGasWanted := Deref(filter.ToGasWanted) + if toGasWanted == 0 { + toGasWanted = math.MaxInt + } + return tx.GasWanted() >= fromGasWanted && tx.GasWanted() <= toGasWanted +} + +func (filter *TransactionFilter) filterByMessages(tx *Transaction) bool { + if filter.Message == nil { + return true + } + if !filter.hasMessageTypes(tx) { + return false + } + for _, message := range tx.messages { + if !filter.filterByMessageContent(message) { + return false + } + } + return true +} + +func (filter *TransactionFilter) hasMessageTypes(tx *Transaction) bool { + if filter.Message.TypeURL == nil { + return true + } + for _, message := range tx.messages { + if message.TypeUrl.String() == filter.Message.TypeURL.String() { + return true + } + } + return false +} + +func (filter *TransactionFilter) filterByMessageContent(tm *TransactionMessage) bool { + if filter.Message.TypeURL != nil && filter.Message.TypeURL.String() != tm.TypeUrl.String() { + return false + } + + if filter.Message.BankParam == nil && filter.Message.VMParam == nil { + return true + } + + switch tm.Route { + case MessageRouteBank: + if filter.Message.BankParam == nil { + return false + } + case MessageRouteVM: + if filter.Message.VMParam == nil { + return false + } + } + + switch tm.TypeUrl { + case MessageTypeSend: + if !filter.validMessageOfBankMsgSend(tm.BankMsgSend()) { + return false + } + case MessageTypeExec: + if !filter.validMessageOfMsgCall(tm.VmMsgCall()) { + return false + } + case MessageTypeAddPackage: + if !filter.validMessageOfMsgAddPackage(tm.VmAddPackage()) { + return false + } + case MessageTypeRun: + if !filter.validMessageOfMsgRun(tm.VmMsgRun()) { + return false + } + } + return true +} + +func (filter *TransactionFilter) filterByMemo(tx *Transaction) bool { + if filter.Memo == nil { + return true + } + return *filter.Memo == tx.Memo() +} + +func (filter *TransactionFilter) validMessageOfBankMsgSend(messageValue BankMsgSend) bool { + params := filter.Message.BankParam + if params == nil || params.Send == nil { + return true + } + if params.Send.Amount != nil && *params.Send.Amount != messageValue.Amount { + return false + } + if params.Send.FromAddress != nil && *params.Send.FromAddress != messageValue.FromAddress { + return false + } + if params.Send.ToAddress != nil && *params.Send.ToAddress != messageValue.ToAddress { + return false + } + return true +} + +func (filter *TransactionFilter) validMessageOfMsgCall(messageValue MsgCall) bool { + params := filter.Message.VMParam + if params == nil { + return true + } + if params.MCall == nil { + return false + } + if params.MCall.Caller != nil && *params.MCall.Caller != messageValue.Caller { + return false + } + if params.MCall.Func != nil && *params.MCall.Func != messageValue.Func { + return false + } + if params.MCall.PkgPath != nil && *params.MCall.PkgPath != messageValue.PkgPath { + return false + } + if params.MCall.Send != nil && *params.MCall.Send != messageValue.Send { + return false + } + if params.MCall.Args != nil { + messageArgs := messageValue.Args + messageFilterArgs := params.MCall.Args + for index, arg := range messageArgs { + if index < len(messageFilterArgs) { + if arg != "" && messageFilterArgs[index] != arg { + return false + } + } + } + } + return true +} + +func (filter *TransactionFilter) validMessageOfMsgAddPackage(messageValue MsgAddPackage) bool { + params := filter.Message.VMParam + if params == nil { + return true + } + if params.MAddpkg == nil { + return false + } + if params.MAddpkg.Creator != nil && *params.MAddpkg.Creator != messageValue.Creator { + return false + } + if params.MAddpkg.Deposit != nil && *params.MAddpkg.Deposit != messageValue.Deposit { + return false + } + if params.MAddpkg.Package != nil { + if params.MAddpkg.Package.Name != nil && *params.MAddpkg.Package.Name != messageValue.Package.Name { + return false + } + if params.MAddpkg.Package.Path != nil && *params.MAddpkg.Package.Path != messageValue.Package.Path { + return false + } + } + return true +} + +func (filter *TransactionFilter) validMessageOfMsgRun(messageValue MsgRun) bool { + params := filter.Message.VMParam + if params == nil { + return true + } + if params.MRun == nil { + return false + } + if params.MRun.Caller != nil && *params.MRun.Caller != messageValue.Caller { + return false + } + if params.MRun.Send != nil && *params.MRun.Send != messageValue.Send { + return false + } + if params.MRun.Package != nil { + if params.MRun.Package.Name != nil && *params.MRun.Package.Name != messageValue.Package.Name { + return false + } + if params.MRun.Package.Path != nil && *params.MRun.Package.Path != messageValue.Package.Path { + return false + } + } + return true +} diff --git a/serve/graph/model/utils.go b/serve/graph/model/utils.go new file mode 100644 index 00000000..c228fa1d --- /dev/null +++ b/serve/graph/model/utils.go @@ -0,0 +1,111 @@ +package model + +import ( + "encoding/json" + + "github.com/gnolang/gno/gno.land/pkg/sdk/vm" + "github.com/gnolang/gno/tm2/pkg/sdk/bank" + "github.com/gnolang/gno/tm2/pkg/std" +) + +func Deref[T any](v *T) T { + if v == nil { + var zero T + + return zero + } + return *v + +} + +func Cast[T any](input any) (*T, error) { + encoded, err := json.Marshal(input) + if err != nil { + return nil, err + } + + var data T + if err = json.Unmarshal(encoded, &data); err != nil { + return nil, err + } + + return &data, nil +} + +func ParseBankMsgSend(value std.Msg) BankMsgSend { + decodedMessage, err := Cast[bank.MsgSend](value) + if err != nil { + return BankMsgSend{} + } + + return BankMsgSend{ + FromAddress: decodedMessage.FromAddress.String(), + ToAddress: decodedMessage.ToAddress.String(), + Amount: decodedMessage.Amount.String(), + } +} + +func ParseVmMsgCall(value std.Msg) MsgCall { + decodedMessage, err := Cast[vm.MsgCall](value) + if err != nil { + return MsgCall{} + } + + return MsgCall{ + Caller: decodedMessage.Caller.String(), + Send: decodedMessage.Send.String(), + PkgPath: decodedMessage.PkgPath, + Func: decodedMessage.Func, + Args: decodedMessage.Args, + } +} + +func ParseVmAddPackage(value std.Msg) MsgAddPackage { + decodedMessage, err := Cast[vm.MsgAddPackage](value) + if err != nil { + return MsgAddPackage{} + } + + memFiles := make([]*MemFile, 0) + for _, file := range decodedMessage.Package.Files { + memFiles = append(memFiles, &MemFile{ + Name: file.Name, + Body: file.Body, + }) + } + + return MsgAddPackage{ + Creator: decodedMessage.Creator.String(), + Package: &MemPackage{ + Name: decodedMessage.Package.Name, + Path: decodedMessage.Package.Path, + Files: memFiles, + }, + Deposit: decodedMessage.Deposit.String(), + } +} + +func ParseVmMsgRun(value std.Msg) MsgRun { + decodedMessage, err := Cast[vm.MsgRun](value) + if err != nil { + return MsgRun{} + } + + memFiles := make([]*MemFile, 0) + for _, file := range decodedMessage.Package.Files { + memFiles = append(memFiles, &MemFile{ + Name: file.Name, + Body: file.Body, + }) + } + + return MsgRun{ + Caller: decodedMessage.Caller.String(), + Send: decodedMessage.Send.String(), + Package: &MemPackage{ + Name: decodedMessage.Package.Name, + Path: decodedMessage.Package.Path, + Files: memFiles, + }, + } +} diff --git a/serve/graph/resolvers/query.resolvers.go b/serve/graph/resolvers/query.resolvers.go new file mode 100644 index 00000000..198bc51d --- /dev/null +++ b/serve/graph/resolvers/query.resolvers.go @@ -0,0 +1,128 @@ +package resolvers + +// 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.43 + +import ( + "context" + + "github.com/99designs/gqlgen/graphql" + "github.com/gnolang/tx-indexer/serve/graph/generated" + "github.com/gnolang/tx-indexer/serve/graph/model" + "github.com/vektah/gqlparser/v2/gqlerror" +) + +// Transactions is the resolver for the transactions field. +func (r *queryResolver) Transactions(ctx context.Context, filter model.TransactionFilter) ([]*model.Transaction, error) { + if filter.Hash != nil { + tx, err := r.store.GetTxByHash(*filter.Hash) + if err != nil { + return nil, gqlerror.Wrap(err) + } + return []*model.Transaction{model.NewTransaction(tx)}, nil + } + + it, err := r. + store. + TxIterator( + filter.GetFromBlockHeight(), + filter.GetToBlockHeight(), + filter.GetFromIndex(), + filter.GetToIndex(), + ) + if err != nil { + return nil, gqlerror.Wrap(err) + } + defer it.Close() + + var out []*model.Transaction + i := 0 + for { + if i == maxElementsPerQuery { + graphql.AddErrorf(ctx, "max elements per query reached (%d)", maxElementsPerQuery) + return out, nil + } + + if !it.Next() { + return out, it.Error() + } + + select { + case <-ctx.Done(): + graphql.AddError(ctx, ctx.Err()) + return out, nil + default: + t, err := it.Value() + if err != nil { + graphql.AddError(ctx, err) + return out, nil + } + + transaction := model.NewTransaction(t) + if !filter.FilterBy(transaction) { + continue + } + out = append(out, transaction) + i++ + } + } +} + +// Blocks is the resolver for the blocks field. +func (r *queryResolver) Blocks(ctx context.Context, filter model.BlockFilter) ([]*model.Block, error) { + it, err := r. + store. + BlockIterator( + filter.GetFromHeight(), + filter.GetToHeight(), + ) + if err != nil { + return nil, gqlerror.Wrap(err) + } + defer it.Close() + + var out []*model.Block + + i := 0 + for { + if i == maxElementsPerQuery { + graphql.AddErrorf(ctx, "max elements per query reached (%d)", maxElementsPerQuery) + return out, nil + } + + if !it.Next() { + return out, it.Error() + } + + select { + case <-ctx.Done(): + graphql.AddError(ctx, ctx.Err()) + return out, nil + default: + b, err := it.Value() + if err != nil { + graphql.AddError(ctx, err) + return out, nil + } + + if !filter.FilterBy(b) { + continue + } + + out = append(out, model.NewBlock(b)) + i++ + } + } +} + +// LatestBlockHeight is the resolver for the latestBlockHeight field. +func (r *queryResolver) LatestBlockHeight(ctx context.Context) (int, error) { + h, err := r.store.GetLatestHeight() + return int(h), err +} + +// Query returns generated.QueryResolver implementation. +func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } + +type queryResolver struct{ *Resolver } diff --git a/serve/graph/resolvers/resolver.go b/serve/graph/resolvers/resolver.go new file mode 100644 index 00000000..65c5f972 --- /dev/null +++ b/serve/graph/resolvers/resolver.go @@ -0,0 +1,76 @@ +//go:generate go run github.com/99designs/gqlgen generate + +package resolvers + +import ( + "context" + "fmt" + + "github.com/99designs/gqlgen/graphql" + "github.com/gnolang/tx-indexer/events" + "github.com/gnolang/tx-indexer/storage" + "github.com/gnolang/tx-indexer/types" +) + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +const maxElementsPerQuery = 10000 + +func deref[T any](v *T) T { + if v == nil { + var zero T + + return zero + } + + return *v +} + +type Resolver struct { + store storage.Storage + manager *events.Manager +} + +func handleChannel[T any]( + ctx context.Context, + m *events.Manager, + writeToChannel func(*types.NewBlock, chan<- T), +) <-chan T { + ch := make(chan T) + go func() { + defer close(ch) + + sub := m.Subscribe([]events.Type{types.NewBlockEvent}) + defer m.CancelSubscription(sub.ID) + + for { + select { + case <-ctx.Done(): + graphql.AddError(ctx, ctx.Err()) + + return + case rawE, ok := <-sub.SubCh: + if !ok { + return + } + + e, ok := rawE.GetData().(*types.NewBlock) + if !ok { + graphql.AddError(ctx, fmt.Errorf("error casting event data. Obtained event ID: %q", rawE.GetType())) + + return + } + + writeToChannel(e, ch) + } + } + }() + + return ch +} + +func NewResolver(s storage.Storage, m *events.Manager) *Resolver { + return &Resolver{store: s, manager: m} +} diff --git a/serve/graph/resolvers/subscription.resolvers.go b/serve/graph/resolvers/subscription.resolvers.go new file mode 100644 index 00000000..cb16f045 --- /dev/null +++ b/serve/graph/resolvers/subscription.resolvers.go @@ -0,0 +1,39 @@ +package resolvers + +// 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.43 + +import ( + "context" + + "github.com/gnolang/tx-indexer/serve/graph/generated" + "github.com/gnolang/tx-indexer/serve/graph/model" + "github.com/gnolang/tx-indexer/types" +) + +// Transactions is the resolver for the transactions field. +func (r *subscriptionResolver) Transactions(ctx context.Context, filter model.TransactionFilter) (<-chan *model.Transaction, error) { + return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Transaction) { + for _, tx := range nb.Results { + transaction := model.NewTransaction(tx) + if filter.FilterBy(transaction) { + c <- transaction + } + } + }), nil +} + +// Blocks is the resolver for the blocks field. +func (r *subscriptionResolver) Blocks(ctx context.Context, filter model.BlockFilter) (<-chan *model.Block, error) { + return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Block) { + if filter.FilterBy(nb.Block) { + c <- model.NewBlock(nb.Block) + } + }), nil +} + +// Subscription returns generated.SubscriptionResolver implementation. +func (r *Resolver) Subscription() generated.SubscriptionResolver { return &subscriptionResolver{r} } + +type subscriptionResolver struct{ *Resolver } From 207ddb4cb717647db6c719efcdf3f1a23ef025b4 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Mon, 1 Apr 2024 07:11:08 +0900 Subject: [PATCH 04/25] chore: Separate Graphql schemas --- gqlgen.yml | 22 +- serve/graph/{ => generated}/generated.go | 5025 +++++++++++++---- serve/graph/resolver.go | 77 - serve/graph/schema.graphql | 205 - serve/graph/schema.resolvers.go | 167 - .../graph/schema/filter/block_filter.graphql | 24 + .../schema/filter/transaction_filter.graphql | 215 + serve/graph/schema/query.graphql | 19 + serve/graph/schema/schema.graphql | 9 + serve/graph/schema/subscription.graphql | 29 + serve/graph/schema/types/block.graphql | 33 + serve/graph/schema/types/transaction.graphql | 106 + serve/graph/setup.go | 7 +- 13 files changed, 4480 insertions(+), 1458 deletions(-) rename serve/graph/{ => generated}/generated.go (60%) delete mode 100644 serve/graph/resolver.go delete mode 100644 serve/graph/schema.graphql delete mode 100644 serve/graph/schema.resolvers.go create mode 100644 serve/graph/schema/filter/block_filter.graphql create mode 100644 serve/graph/schema/filter/transaction_filter.graphql create mode 100644 serve/graph/schema/query.graphql create mode 100644 serve/graph/schema/schema.graphql create mode 100644 serve/graph/schema/subscription.graphql create mode 100644 serve/graph/schema/types/block.graphql create mode 100644 serve/graph/schema/types/transaction.graphql diff --git a/gqlgen.yml b/gqlgen.yml index 41131de2..aec6660b 100644 --- a/gqlgen.yml +++ b/gqlgen.yml @@ -1,11 +1,12 @@ # Where are all the schema files located? globs are supported eg src/**/*.graphql schema: - - serve/graph/*.graphql + - serve/graph/schema/*.graphql + - serve/graph/schema/**/*.graphql # Where should the generated server code go? exec: - filename: serve/graph/generated.go - package: graph + filename: serve/graph/generated/generated.go + package: generated # Where should any generated models go? model: @@ -15,8 +16,8 @@ model: # Where should the resolver implementations go? resolver: layout: follow-schema - dir: serve/graph - package: graph + dir: serve/graph/resolvers + package: resolvers filename_template: "{name}.resolvers.go" # Optional: turn on to not generate template comments above resolvers # omit_template_comment: false @@ -85,4 +86,13 @@ models: - github.com/gnolang/tx-indexer/serve/graph/model.Block Transaction: model: - - github.com/gnolang/tx-indexer/serve/graph/model.Transaction \ No newline at end of file + - github.com/gnolang/tx-indexer/serve/graph/model.Transaction + TransactionMessage: + model: + - github.com/gnolang/tx-indexer/serve/graph/model.TransactionMessage + BlockFilter: + model: + - github.com/gnolang/tx-indexer/serve/graph/model.BlockFilter + TransactionFilter: + model: + - github.com/gnolang/tx-indexer/serve/graph/model.TransactionFilter diff --git a/serve/graph/generated.go b/serve/graph/generated/generated.go similarity index 60% rename from serve/graph/generated.go rename to serve/graph/generated/generated.go index 69694fb5..281ff65d 100644 --- a/serve/graph/generated.go +++ b/serve/graph/generated/generated.go @@ -1,11 +1,10 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package graph +package generated import ( "bytes" "context" - "embed" "errors" "fmt" "io" @@ -49,6 +48,12 @@ type DirectiveRoot struct { } type ComplexityRoot struct { + BankMsgSend struct { + Amount func(childComplexity int) int + FromAddress func(childComplexity int) int + ToAddress func(childComplexity int) int + } + Block struct { ChainID func(childComplexity int) int Height func(childComplexity int) int @@ -57,6 +62,37 @@ type ComplexityRoot struct { Version func(childComplexity int) int } + MemFile struct { + Body func(childComplexity int) int + Name func(childComplexity int) int + } + + MemPackage struct { + Files func(childComplexity int) int + Name func(childComplexity int) int + Path func(childComplexity int) int + } + + MsgAddPackage struct { + Creator func(childComplexity int) int + Deposit func(childComplexity int) int + Package func(childComplexity int) int + } + + MsgCall struct { + Args func(childComplexity int) int + Caller func(childComplexity int) int + Func func(childComplexity int) int + PkgPath func(childComplexity int) int + Send func(childComplexity int) int + } + + MsgRun struct { + Caller func(childComplexity int) int + Package func(childComplexity int) int + Send func(childComplexity int) int + } + Query struct { Blocks func(childComplexity int, filter model.BlockFilter) int LatestBlockHeight func(childComplexity int) int @@ -64,8 +100,8 @@ type ComplexityRoot struct { } Subscription struct { - Blocks func(childComplexity int) int - Transactions func(childComplexity int) int + Blocks func(childComplexity int, filter model.BlockFilter) int + Transactions func(childComplexity int, filter model.TransactionFilter) int } Transaction struct { @@ -75,6 +111,19 @@ type ComplexityRoot struct { 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 + } + + TransactionMessage struct { + Route func(childComplexity int) int + TypeUrl func(childComplexity int) int + Value func(childComplexity int) int + } + + TxFee struct { + GasFee func(childComplexity int) int + GasWanted func(childComplexity int) int } } @@ -84,8 +133,8 @@ type QueryResolver interface { LatestBlockHeight(ctx context.Context) (int, error) } type SubscriptionResolver interface { - Transactions(ctx context.Context) (<-chan *model.Transaction, error) - Blocks(ctx context.Context) (<-chan *model.Block, error) + Transactions(ctx context.Context, filter model.TransactionFilter) (<-chan *model.Transaction, error) + Blocks(ctx context.Context, filter model.BlockFilter) (<-chan *model.Block, error) } type executableSchema struct { @@ -107,6 +156,27 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { + case "BankMsgSend.amount": + if e.complexity.BankMsgSend.Amount == nil { + break + } + + return e.complexity.BankMsgSend.Amount(childComplexity), true + + case "BankMsgSend.from_address": + if e.complexity.BankMsgSend.FromAddress == nil { + break + } + + return e.complexity.BankMsgSend.FromAddress(childComplexity), true + + case "BankMsgSend.to_address": + if e.complexity.BankMsgSend.ToAddress == nil { + break + } + + return e.complexity.BankMsgSend.ToAddress(childComplexity), true + case "Block.chain_id": if e.complexity.Block.ChainID == nil { break @@ -142,6 +212,118 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Block.Version(childComplexity), true + case "MemFile.Body": + if e.complexity.MemFile.Body == nil { + break + } + + return e.complexity.MemFile.Body(childComplexity), true + + case "MemFile.Name": + if e.complexity.MemFile.Name == nil { + break + } + + return e.complexity.MemFile.Name(childComplexity), true + + case "MemPackage.Files": + if e.complexity.MemPackage.Files == nil { + break + } + + return e.complexity.MemPackage.Files(childComplexity), true + + case "MemPackage.Name": + if e.complexity.MemPackage.Name == nil { + break + } + + return e.complexity.MemPackage.Name(childComplexity), true + + case "MemPackage.Path": + if e.complexity.MemPackage.Path == nil { + break + } + + return e.complexity.MemPackage.Path(childComplexity), true + + case "MsgAddPackage.creator": + if e.complexity.MsgAddPackage.Creator == nil { + break + } + + return e.complexity.MsgAddPackage.Creator(childComplexity), true + + case "MsgAddPackage.deposit": + if e.complexity.MsgAddPackage.Deposit == nil { + break + } + + return e.complexity.MsgAddPackage.Deposit(childComplexity), true + + case "MsgAddPackage.package": + if e.complexity.MsgAddPackage.Package == nil { + break + } + + return e.complexity.MsgAddPackage.Package(childComplexity), true + + case "MsgCall.args": + if e.complexity.MsgCall.Args == nil { + break + } + + return e.complexity.MsgCall.Args(childComplexity), true + + case "MsgCall.caller": + if e.complexity.MsgCall.Caller == nil { + break + } + + return e.complexity.MsgCall.Caller(childComplexity), true + + case "MsgCall.func": + if e.complexity.MsgCall.Func == nil { + break + } + + return e.complexity.MsgCall.Func(childComplexity), true + + case "MsgCall.pkg_path": + if e.complexity.MsgCall.PkgPath == nil { + break + } + + return e.complexity.MsgCall.PkgPath(childComplexity), true + + case "MsgCall.send": + if e.complexity.MsgCall.Send == nil { + break + } + + return e.complexity.MsgCall.Send(childComplexity), true + + case "MsgRun.caller": + if e.complexity.MsgRun.Caller == nil { + break + } + + return e.complexity.MsgRun.Caller(childComplexity), true + + case "MsgRun.package": + if e.complexity.MsgRun.Package == nil { + break + } + + return e.complexity.MsgRun.Package(childComplexity), true + + case "MsgRun.send": + if e.complexity.MsgRun.Send == nil { + break + } + + return e.complexity.MsgRun.Send(childComplexity), true + case "Query.blocks": if e.complexity.Query.Blocks == nil { break @@ -178,14 +360,24 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - return e.complexity.Subscription.Blocks(childComplexity), true + args, err := ec.field_Subscription_blocks_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Subscription.Blocks(childComplexity, args["filter"].(model.BlockFilter)), true case "Subscription.transactions": if e.complexity.Subscription.Transactions == nil { break } - return e.complexity.Subscription.Transactions(childComplexity), true + args, err := ec.field_Subscription_transactions_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Subscription.Transactions(childComplexity, args["filter"].(model.TransactionFilter)), true case "Transaction.block_height": if e.complexity.Transaction.BlockHeight == nil { @@ -229,6 +421,55 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Transaction.Index(childComplexity), true + case "Transaction.memo": + if e.complexity.Transaction.Memo == nil { + break + } + + return e.complexity.Transaction.Memo(childComplexity), true + + case "Transaction.messages": + if e.complexity.Transaction.Messages == nil { + break + } + + return e.complexity.Transaction.Messages(childComplexity), true + + case "TransactionMessage.route": + if e.complexity.TransactionMessage.Route == nil { + break + } + + return e.complexity.TransactionMessage.Route(childComplexity), true + + case "TransactionMessage.typeUrl": + if e.complexity.TransactionMessage.TypeUrl == nil { + break + } + + return e.complexity.TransactionMessage.TypeUrl(childComplexity), true + + case "TransactionMessage.value": + if e.complexity.TransactionMessage.Value == nil { + break + } + + return e.complexity.TransactionMessage.Value(childComplexity), true + + case "TxFee.gas_fee": + if e.complexity.TxFee.GasFee == nil { + break + } + + return e.complexity.TxFee.GasFee(childComplexity), true + + case "TxFee.gas_wanted": + if e.complexity.TxFee.GasWanted == nil { + break + } + + return e.complexity.TxFee.GasWanted(childComplexity), true + } return 0, false } @@ -237,8 +478,17 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputBankMsgSendInput, ec.unmarshalInputBlockFilter, + ec.unmarshalInputMemFileInput, + ec.unmarshalInputMemPackageInput, + ec.unmarshalInputMsgAddPackageInput, + ec.unmarshalInputMsgCallInput, + ec.unmarshalInputMsgRunInput, + ec.unmarshalInputTransactionBankMessageInput, ec.unmarshalInputTransactionFilter, + ec.unmarshalInputTransactionMessageInput, + ec.unmarshalInputTransactionVmMessageInput, ) first := true @@ -337,19 +587,446 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } -//go:embed "schema.graphql" -var sourcesFS embed.FS +var sources = []*ast.Source{ + {Name: "../schema/query.graphql", Input: `""" +Root Query type to fetch data about Blocks and Transactions based on filters or retrieve the latest block height. +""" +type Query { + """ + Retrieves a list of Transactions that match the given filter criteria. If the result is incomplete due to errors, both partial results and errors are returned. + """ + transactions(filter: TransactionFilter!): [Transaction!] + + """ + Fetches Blocks matching the specified filter criteria. Incomplete results due to errors return both the partial Blocks and the associated errors. + """ + blocks(filter: BlockFilter!): [Block!] + + """ + Returns the height of the most recently processed Block by the blockchain indexer, indicating the current length of the blockchain. + """ + latestBlockHeight: Int! +} +`, BuiltIn: false}, + {Name: "../schema/schema.graphql", Input: `schema { + query: Query + subscription: Subscription +} + +""" +Field representing a point on time. It is following the RFC3339Nano format ("2006-01-02T15:04:05.999999999Z07:00") +""" +scalar Time +`, BuiltIn: false}, + {Name: "../schema/subscription.graphql", Input: `""" +Subscriptions provide a way for clients to receive real-time updates about Transactions and Blocks based on specified filter criteria. +Subscribers will only receive updates for events occurring after the subscription is established. +""" +type Subscription { + """ + Subscribes to real-time updates of Transactions that match the provided filter criteria. + This subscription starts immediately and only includes Transactions added to the blockchain after the subscription is active. + + This is useful for applications needing to track Transactions in real-time, such as wallets tracking incoming transactions + or analytics platforms monitoring blockchain activity. + + Returns: + - Transaction: Each received update is a Transaction object that matches the filter criteria. + """ + transactions(filter: TransactionFilter!): Transaction! + + """ + Subscribes to real-time updates of Blocks that match the provided filter criteria. Similar to the Transactions subscription, + this subscription is active immediately upon creation and only includes Blocks added after the subscription begins. + + This subscription is ideal for services that need to be notified of new Blocks for processing or analysis, such as block explorers, + data aggregators, or security monitoring tools. + + Returns: + - Block: Each update consists of a Block object that satisfies the filter criteria, allowing subscribers to process or analyze new Blocks in real time. + """ + blocks(filter: BlockFilter!): Block! +} +`, BuiltIn: false}, + {Name: "../schema/filter/block_filter.graphql", Input: `""" +Filters for querying Blocks within specified criteria related to their attributes. +""" +input BlockFilter { + """ + Minimum block height from which to start fetching Blocks, inclusive. If unspecified, there is no lower bound. + """ + from_height: Int + + """ + Maximum block height up to which Blocks should be fetched, exclusive. If unspecified, there is no upper bound. + """ + to_height: Int + + """ + Minimum timestamp from which to start fetching Blocks, inclusive. Blocks created at or after this time will be included. + """ + from_time: Time + + """ + Maximum timestamp up to which to fetch Blocks, exclusive. Only Blocks created before this time are included. + """ + to_time: Time +} +`, BuiltIn: false}, + {Name: "../schema/filter/transaction_filter.graphql", Input: `""" +Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. +""" +input TransactionFilter { + """ + Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. + """ + from_block_height: Int + + """ + Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. + """ + to_block_height: Int + + """ + Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. + """ + from_index: Int + + """ + Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. + """ + to_index: Int + + """ + Minimum ` + "`" + `gas_wanted` + "`" + ` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. + """ + from_gas_wanted: Int + + """ + Maximum ` + "`" + `gas_wanted` + "`" + ` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. + """ + to_gas_wanted: Int + + """ + Minimum ` + "`" + `gas_used` + "`" + ` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. + """ + from_gas_used: Int + + """ + Maximum ` + "`" + `gas_used` + "`" + ` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. + """ + to_gas_used: Int + + """ + Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. + """ + hash: String + + """ + Transaction's message to filter Transactions. + """ + message: TransactionMessageInput + + """ + ` + "`" + `memo` + "`" + ` value to filter Transaction's memo. + """ + memo: String +} + +""" +Input for filters by transaction message. +""" +input TransactionMessageInput { + """ + The type of transaction message. + """ + type_url: MessageType + + """ + The route of transaction message. + """ + route: MessageRoute + + """ + Input parameters required when the message router type is ` + "`" + `bank` + "`" + `. + """ + bank_param: TransactionBankMessageInput + + """ + Input parameters required when the message router type is ` + "`" + `vm` + "`" + `. + """ + vm_param: TransactionVmMessageInput +} + +""" +Input parameters required when the message router is ` + "`" + `bank` + "`" + `. +""" +input TransactionBankMessageInput { + """ + Input parameters required when the message type is ` + "`" + `send` + "`" + `. + """ + send: BankMsgSendInput +} + +""" +Input parameters required when the message type is ` + "`" + `send` + "`" + `. +""" +input BankMsgSendInput { + """ + Filter by ` + "`" + `from_address` + "`" + `. + """ + from_address: String + + """ + Filter by ` + "`" + `to_address` + "`" + `. + """ + to_address: String + + """ + Filter by ` + "`" + `amount` + "`" + `. + """ + amount: String +} + +""" +Input parameters required when the message router is ` + "`" + `vm` + "`" + `. +""" +input TransactionVmMessageInput { + """ + Input parameters required when the message type is ` + "`" + `exec` + "`" + `. + """ + m_call: MsgCallInput + + """ + Input parameters required when the message type is ` + "`" + `add_package` + "`" + `. + """ + m_addpkg: MsgAddPackageInput + + """ + Input parameters required when the message type is ` + "`" + `run` + "`" + `. + """ + m_run: MsgRunInput +} + +""" +Input parameters required when the message type is ` + "`" + `exec` + "`" + `. +""" +input MsgCallInput { + """ + Filter by ` + "`" + `caller` + "`" + `. + """ + caller: String + + """ + Filter by ` + "`" + `send` + "`" + `. + """ + send: String + + """ + Filter by ` + "`" + `pkg_path` + "`" + `. + """ + pkg_path: String + + """ + Filter by ` + "`" + `func` + "`" + `. + """ + func: String + + """ + Filter by ` + "`" + `args` + "`" + `, Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + """ + args: [String!] +} + +""" +Input parameters required when the message type is ` + "`" + `add_package` + "`" + `. +""" +input MsgAddPackageInput { + """ + Filter by ` + "`" + `creator` + "`" + `. + """ + creator: String + + """ + Filter by ` + "`" + `package` + "`" + `. + """ + package: MemPackageInput + + """ + Filter by ` + "`" + `deposit` + "`" + `. + """ + deposit: String +} + +""" +Input parameters required when the message type is ` + "`" + `run` + "`" + `. +""" +input MsgRunInput { + """ + Filter by ` + "`" + `caller` + "`" + `. + """ + caller: String + + """ + Filter by ` + "`" + `send` + "`" + `. + """ + send: String + + """ + Filter by ` + "`" + `package` + "`" + `. + """ + package: MemPackageInput +} + +input MemPackageInput { + Name: String + Path: String + Files: [MemFileInput] +} + +input MemFileInput { + Name: String + Body: String +} +`, BuiltIn: false}, + {Name: "../schema/types/block.graphql", Input: `""" +Represents a blockchain block with various attributes detailing its creation and content. +""" +type Block { + """ + A unique identifier for the Block determined by its position in the blockchain. + This integer is strictly increasing with each new Block. + """ + height: Int! + + """ + The software version of the node that created this Block, indicating the specific + implementation and versioning of the blockchain protocol used. + """ + version: String! + + """ + An identifier for the specific blockchain network this Block belongs to. Helps in + distinguishing between different networks like mainnet, testnet, etc. + """ + chain_id: String! + + """ + The timestamp at which this Block was proposed and finalized in the blockchain. Represented in UTC. + """ + time: Time! + + """ + Encoded data representing the blockchain address of the proposer who submitted this Block. + It is raw and requires decoding to be human-readable. + """ + proposer_address_raw: String! +} +`, BuiltIn: false}, + {Name: "../schema/types/transaction.graphql", Input: `""" +Defines a transaction within a block, detailing its execution specifics and content. +""" +type Transaction { + """ + A sequential index representing the order of this Transaction within its Block. Unique within the context of its Block. + """ + index: Int! -func sourceData(filename string) string { - data, err := sourcesFS.ReadFile(filename) - if err != nil { - panic(fmt.Sprintf("codegen problem: %s not available", filename)) - } - return string(data) + """ + Hash from Transaction content in base64 encoding. + """ + hash: String! + + """ + The height of the Block in which this Transaction is included. Links the Transaction to its containing Block. + """ + block_height: Int! + + """ + The declared amount of computational effort the sender is willing to pay for executing this Transaction. + """ + gas_wanted: Int! + + """ + The actual amount of computational effort consumed to execute this Transaction. It could be less or equal to ` + "`" + `gas_wanted` + "`" + `. + """ + gas_used: Int! + + """ + The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. + """ + content_raw: String! + + """ + The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. + """ + messages: [TransactionMessage]! + + memo: String! } -var sources = []*ast.Source{ - {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, +enum MessageRoute { + vm + bank +} + +enum MessageType { + send + exec + add_package + run +} + +type TransactionMessage { + typeUrl: MessageType! + route: MessageRoute! + value: MessageValue! +} + +union MessageValue = BankMsgSend | MsgCall | MsgAddPackage | MsgRun + +type BankMsgSend { + from_address: String! + to_address: String! + amount: String! +} + +type MsgCall { + caller: String! + send: String! + pkg_path: String! + func: String! + args: [String!] +} + +type MsgAddPackage { + creator: String! + package: MemPackage! + deposit: String! +} + +type MsgRun { + caller: String! + send: String! + package: MemPackage! +} + +type MemPackage { + Name: String! + Path: String! + Files: [MemFile!] +} + +type MemFile { + Name: String! + Body: String! +} + +type TxFee { + gas_wanted: Int! + gas_fee: Int! +} +`, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) @@ -402,6 +1079,36 @@ func (ec *executionContext) field_Query_transactions_args(ctx context.Context, r return args, nil } +func (ec *executionContext) field_Subscription_blocks_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.BlockFilter + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalNBlockFilter2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlockFilter(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Subscription_transactions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.TransactionFilter + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalNTransactionFilter2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionFilter(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -440,8 +1147,8 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** -func (ec *executionContext) _Block_height(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_height(ctx, field) +func (ec *executionContext) _BankMsgSend_from_address(ctx context.Context, field graphql.CollectedField, obj *model.BankMsgSend) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BankMsgSend_from_address(ctx, field) if err != nil { return graphql.Null } @@ -454,7 +1161,7 @@ func (ec *executionContext) _Block_height(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Height(), nil + return obj.FromAddress, nil }) if err != nil { ec.Error(ctx, err) @@ -466,26 +1173,26 @@ func (ec *executionContext) _Block_height(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(int64) + res := resTmp.(string) fc.Result = res - return ec.marshalNInt2int64(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Block_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BankMsgSend_from_address(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Block", + Object: "BankMsgSend", 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) _Block_version(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_version(ctx, field) +func (ec *executionContext) _BankMsgSend_to_address(ctx context.Context, field graphql.CollectedField, obj *model.BankMsgSend) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BankMsgSend_to_address(ctx, field) if err != nil { return graphql.Null } @@ -498,7 +1205,7 @@ func (ec *executionContext) _Block_version(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Version(), nil + return obj.ToAddress, nil }) if err != nil { ec.Error(ctx, err) @@ -515,11 +1222,11 @@ func (ec *executionContext) _Block_version(ctx context.Context, field graphql.Co return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Block_version(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BankMsgSend_to_address(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Block", + Object: "BankMsgSend", 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") @@ -528,8 +1235,8 @@ func (ec *executionContext) fieldContext_Block_version(ctx context.Context, fiel return fc, nil } -func (ec *executionContext) _Block_chain_id(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_chain_id(ctx, field) +func (ec *executionContext) _BankMsgSend_amount(ctx context.Context, field graphql.CollectedField, obj *model.BankMsgSend) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BankMsgSend_amount(ctx, field) if err != nil { return graphql.Null } @@ -542,7 +1249,7 @@ func (ec *executionContext) _Block_chain_id(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ChainID(), nil + return obj.Amount, nil }) if err != nil { ec.Error(ctx, err) @@ -559,11 +1266,11 @@ func (ec *executionContext) _Block_chain_id(ctx context.Context, field graphql.C return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Block_chain_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BankMsgSend_amount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Block", + Object: "BankMsgSend", 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") @@ -572,8 +1279,8 @@ func (ec *executionContext) fieldContext_Block_chain_id(ctx context.Context, fie return fc, nil } -func (ec *executionContext) _Block_time(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_time(ctx, field) +func (ec *executionContext) _Block_height(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Block_height(ctx, field) if err != nil { return graphql.Null } @@ -586,7 +1293,7 @@ func (ec *executionContext) _Block_time(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Time(), nil + return obj.Height(), nil }) if err != nil { ec.Error(ctx, err) @@ -598,26 +1305,26 @@ func (ec *executionContext) _Block_time(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(int64) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNInt2int64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Block_time(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Block_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Block", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Block_proposer_address_raw(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Block_proposer_address_raw(ctx, field) +func (ec *executionContext) _Block_version(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Block_version(ctx, field) if err != nil { return graphql.Null } @@ -630,7 +1337,7 @@ func (ec *executionContext) _Block_proposer_address_raw(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.ProposerAddressRaw(), nil + return obj.Version(), nil }) if err != nil { ec.Error(ctx, err) @@ -647,7 +1354,7 @@ func (ec *executionContext) _Block_proposer_address_raw(ctx context.Context, fie return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Block_proposer_address_raw(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Block_version(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Block", Field: field, @@ -660,8 +1367,8 @@ func (ec *executionContext) fieldContext_Block_proposer_address_raw(ctx context. return fc, nil } -func (ec *executionContext) _Query_transactions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_transactions(ctx, field) +func (ec *executionContext) _Block_chain_id(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Block_chain_id(ctx, field) if err != nil { return graphql.Null } @@ -674,60 +1381,38 @@ func (ec *executionContext) _Query_transactions(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Transactions(rctx, fc.Args["filter"].(model.TransactionFilter)) + return obj.ChainID(), 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.Transaction) + res := resTmp.(string) fc.Result = res - return ec.marshalOTransaction2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_transactions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Block_chain_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Block", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "index": - return ec.fieldContext_Transaction_index(ctx, field) - case "hash": - return ec.fieldContext_Transaction_hash(ctx, field) - case "block_height": - return ec.fieldContext_Transaction_block_height(ctx, field) - case "gas_wanted": - return ec.fieldContext_Transaction_gas_wanted(ctx, field) - case "gas_used": - return ec.fieldContext_Transaction_gas_used(ctx, field) - case "content_raw": - return ec.fieldContext_Transaction_content_raw(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Transaction", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_transactions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_blocks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_blocks(ctx, field) +func (ec *executionContext) _Block_time(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Block_time(ctx, field) if err != nil { return graphql.Null } @@ -740,58 +1425,38 @@ func (ec *executionContext) _Query_blocks(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Blocks(rctx, fc.Args["filter"].(model.BlockFilter)) + return obj.Time(), 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.Block) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOBlock2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlockᚄ(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_blocks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Block_time(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Block", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "height": - return ec.fieldContext_Block_height(ctx, field) - case "version": - return ec.fieldContext_Block_version(ctx, field) - case "chain_id": - return ec.fieldContext_Block_chain_id(ctx, field) - case "time": - return ec.fieldContext_Block_time(ctx, field) - case "proposer_address_raw": - return ec.fieldContext_Block_proposer_address_raw(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Block", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_blocks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_latestBlockHeight(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_latestBlockHeight(ctx, field) +func (ec *executionContext) _Block_proposer_address_raw(ctx context.Context, field graphql.CollectedField, obj *model.Block) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Block_proposer_address_raw(ctx, field) if err != nil { return graphql.Null } @@ -804,7 +1469,7 @@ func (ec *executionContext) _Query_latestBlockHeight(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 ec.resolvers.Query().LatestBlockHeight(rctx) + return obj.ProposerAddressRaw(), nil }) if err != nil { ec.Error(ctx, err) @@ -816,26 +1481,26 @@ func (ec *executionContext) _Query_latestBlockHeight(ctx context.Context, field } 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_Query_latestBlockHeight(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Block_proposer_address_raw(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Block", 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 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) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _MemFile_Name(ctx context.Context, field graphql.CollectedField, obj *model.MemFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemFile_Name(ctx, field) if err != nil { return graphql.Null } @@ -848,68 +1513,38 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return obj.Name, 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.(*introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemFile_Name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "MemFile", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) +func (ec *executionContext) _MemFile_Body(ctx context.Context, field graphql.CollectedField, obj *model.MemFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemFile_Body(ctx, field) if err != nil { return graphql.Null } @@ -922,191 +1557,126 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.Body, 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.(*introspection.Schema) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemFile_Body(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "MemFile", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Subscription_transactions(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { - fc, err := ec.fieldContext_Subscription_transactions(ctx, field) +func (ec *executionContext) _MemPackage_Name(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemPackage_Name(ctx, field) if err != nil { - return nil + return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + 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.Subscription().Transactions(rctx) + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) - return nil + return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } - return nil - } - return func(ctx context.Context) graphql.Marshaler { - select { - case res, ok := <-resTmp.(<-chan *model.Transaction): - if !ok { - return nil - } - return graphql.WriterFunc(func(w io.Writer) { - w.Write([]byte{'{'}) - graphql.MarshalString(field.Alias).MarshalGQL(w) - w.Write([]byte{':'}) - ec.marshalNTransaction2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransaction(ctx, field.Selections, res).MarshalGQL(w) - w.Write([]byte{'}'}) - }) - case <-ctx.Done(): - return nil - } + return graphql.Null } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subscription_transactions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemPackage_Name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Subscription", + Object: "MemPackage", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "index": - return ec.fieldContext_Transaction_index(ctx, field) - case "hash": - return ec.fieldContext_Transaction_hash(ctx, field) - case "block_height": - return ec.fieldContext_Transaction_block_height(ctx, field) - case "gas_wanted": - return ec.fieldContext_Transaction_gas_wanted(ctx, field) - case "gas_used": - return ec.fieldContext_Transaction_gas_used(ctx, field) - case "content_raw": - return ec.fieldContext_Transaction_content_raw(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Transaction", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Subscription_blocks(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { - fc, err := ec.fieldContext_Subscription_blocks(ctx, field) +func (ec *executionContext) _MemPackage_Path(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemPackage_Path(ctx, field) if err != nil { - return nil + return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + 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.Subscription().Blocks(rctx) + return obj.Path, nil }) if err != nil { ec.Error(ctx, err) - return nil + return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } - return nil - } - return func(ctx context.Context) graphql.Marshaler { - select { - case res, ok := <-resTmp.(<-chan *model.Block): - if !ok { - return nil - } - return graphql.WriterFunc(func(w io.Writer) { - w.Write([]byte{'{'}) - graphql.MarshalString(field.Alias).MarshalGQL(w) - w.Write([]byte{':'}) - ec.marshalNBlock2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlock(ctx, field.Selections, res).MarshalGQL(w) - w.Write([]byte{'}'}) - }) - case <-ctx.Done(): - return nil - } + return graphql.Null } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subscription_blocks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemPackage_Path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Subscription", + Object: "MemPackage", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "height": - return ec.fieldContext_Block_height(ctx, field) - case "version": - return ec.fieldContext_Block_version(ctx, field) - case "chain_id": - return ec.fieldContext_Block_chain_id(ctx, field) - case "time": - return ec.fieldContext_Block_time(ctx, field) - case "proposer_address_raw": - return ec.fieldContext_Block_proposer_address_raw(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Block", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Transaction_index(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_index(ctx, field) +func (ec *executionContext) _MemPackage_Files(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemPackage_Files(ctx, field) if err != nil { return graphql.Null } @@ -1119,38 +1689,41 @@ func (ec *executionContext) _Transaction_index(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.Index(), nil + return obj.Files, 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.(int) + res := resTmp.([]*model.MemFile) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOMemFile2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_index(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemPackage_Files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MemPackage", 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") + switch field.Name { + case "Name": + return ec.fieldContext_MemFile_Name(ctx, field) + case "Body": + return ec.fieldContext_MemFile_Body(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MemFile", field.Name) }, } return fc, nil } -func (ec *executionContext) _Transaction_hash(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_hash(ctx, field) +func (ec *executionContext) _MsgAddPackage_creator(ctx context.Context, field graphql.CollectedField, obj *model.MsgAddPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgAddPackage_creator(ctx, field) if err != nil { return graphql.Null } @@ -1163,7 +1736,7 @@ func (ec *executionContext) _Transaction_hash(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.Hash(), nil + return obj.Creator, nil }) if err != nil { ec.Error(ctx, err) @@ -1180,11 +1753,11 @@ func (ec *executionContext) _Transaction_hash(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_hash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgAddPackage_creator(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MsgAddPackage", 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") @@ -1193,8 +1766,8 @@ func (ec *executionContext) fieldContext_Transaction_hash(ctx context.Context, f return fc, nil } -func (ec *executionContext) _Transaction_block_height(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Transaction_block_height(ctx, field) +func (ec *executionContext) _MsgAddPackage_package(ctx context.Context, field graphql.CollectedField, obj *model.MsgAddPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgAddPackage_package(ctx, field) if err != nil { return graphql.Null } @@ -1207,7 +1780,7 @@ func (ec *executionContext) _Transaction_block_height(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.BlockHeight(), nil + return obj.Package, nil }) if err != nil { ec.Error(ctx, err) @@ -1219,26 +1792,34 @@ func (ec *executionContext) _Transaction_block_height(ctx context.Context, field } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*model.MemPackage) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNMemPackage2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackage(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Transaction_block_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgAddPackage_package(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MsgAddPackage", 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") + switch field.Name { + case "Name": + return ec.fieldContext_MemPackage_Name(ctx, field) + case "Path": + return ec.fieldContext_MemPackage_Path(ctx, field) + case "Files": + return ec.fieldContext_MemPackage_Files(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MemPackage", field.Name) }, } 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) _MsgAddPackage_deposit(ctx context.Context, field graphql.CollectedField, obj *model.MsgAddPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgAddPackage_deposit(ctx, field) if err != nil { return graphql.Null } @@ -1251,7 +1832,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.Deposit, nil }) if err != nil { ec.Error(ctx, err) @@ -1263,26 +1844,26 @@ func (ec *executionContext) _Transaction_gas_wanted(ctx context.Context, field g } 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_wanted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgAddPackage_deposit(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MsgAddPackage", 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_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) _MsgCall_caller(ctx context.Context, field graphql.CollectedField, obj *model.MsgCall) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgCall_caller(ctx, field) if err != nil { return graphql.Null } @@ -1295,7 +1876,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.Caller, nil }) if err != nil { ec.Error(ctx, err) @@ -1307,26 +1888,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_MsgCall_caller(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MsgCall", 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) _MsgCall_send(ctx context.Context, field graphql.CollectedField, obj *model.MsgCall) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgCall_send(ctx, field) if err != nil { return graphql.Null } @@ -1339,7 +1920,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.Send, nil }) if err != nil { ec.Error(ctx, err) @@ -1356,11 +1937,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_MsgCall_send(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Transaction", + Object: "MsgCall", 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") @@ -1369,8 +1950,8 @@ func (ec *executionContext) fieldContext_Transaction_content_raw(ctx context.Con return fc, nil } -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_name(ctx, field) +func (ec *executionContext) _MsgCall_pkg_path(ctx context.Context, field graphql.CollectedField, obj *model.MsgCall) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgCall_pkg_path(ctx, field) if err != nil { return graphql.Null } @@ -1383,7 +1964,7 @@ func (ec *executionContext) ___Directive_name(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.Name, nil + return obj.PkgPath, nil }) if err != nil { ec.Error(ctx, err) @@ -1400,9 +1981,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgCall_pkg_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "MsgCall", Field: field, IsMethod: false, IsResolver: false, @@ -1413,8 +1994,8 @@ func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, f return fc, nil } -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_description(ctx, field) +func (ec *executionContext) _MsgCall_func(ctx context.Context, field graphql.CollectedField, obj *model.MsgCall) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgCall_func(ctx, field) if err != nil { return graphql.Null } @@ -1427,25 +2008,28 @@ func (ec *executionContext) ___Directive_description(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.Description(), nil + return obj.Func, 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) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgCall_func(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "MsgCall", 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") @@ -1454,8 +2038,8 @@ func (ec *executionContext) fieldContext___Directive_description(ctx context.Con return fc, nil } -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_locations(ctx, field) +func (ec *executionContext) _MsgCall_args(ctx context.Context, field graphql.CollectedField, obj *model.MsgCall) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgCall_args(ctx, field) if err != nil { return graphql.Null } @@ -1468,38 +2052,35 @@ func (ec *executionContext) ___Directive_locations(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.Locations, nil + return obj.Args, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgCall_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "MsgCall", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __DirectiveLocation does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_args(ctx, field) +func (ec *executionContext) _MsgRun_caller(ctx context.Context, field graphql.CollectedField, obj *model.MsgRun) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgRun_caller(ctx, field) if err != nil { return graphql.Null } @@ -1512,7 +2093,7 @@ func (ec *executionContext) ___Directive_args(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.Args, nil + return obj.Caller, nil }) if err != nil { ec.Error(ctx, err) @@ -1524,36 +2105,26 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(string) fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgRun_caller(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "MsgRun", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) +func (ec *executionContext) _MsgRun_send(ctx context.Context, field graphql.CollectedField, obj *model.MsgRun) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgRun_send(ctx, field) if err != nil { return graphql.Null } @@ -1566,7 +2137,7 @@ func (ec *executionContext) ___Directive_isRepeatable(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.IsRepeatable, nil + return obj.Send, nil }) if err != nil { ec.Error(ctx, err) @@ -1578,26 +2149,26 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgRun_send(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "MsgRun", 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 nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_name(ctx, field) +func (ec *executionContext) _MsgRun_package(ctx context.Context, field graphql.CollectedField, obj *model.MsgRun) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MsgRun_package(ctx, field) if err != nil { return graphql.Null } @@ -1610,7 +2181,7 @@ func (ec *executionContext) ___EnumValue_name(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.Name, nil + return obj.Package, nil }) if err != nil { ec.Error(ctx, err) @@ -1622,26 +2193,34 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.MemPackage) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNMemPackage2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackage(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MsgRun_package(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "MsgRun", 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") + switch field.Name { + case "Name": + return ec.fieldContext_MemPackage_Name(ctx, field) + case "Path": + return ec.fieldContext_MemPackage_Path(ctx, field) + case "Files": + return ec.fieldContext_MemPackage_Files(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MemPackage", field.Name) }, } return fc, nil } -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_description(ctx, field) +func (ec *executionContext) _Query_transactions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_transactions(ctx, field) if err != nil { return graphql.Null } @@ -1654,7 +2233,7 @@ func (ec *executionContext) ___EnumValue_description(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.Description(), nil + return ec.resolvers.Query().Transactions(rctx, fc.Args["filter"].(model.TransactionFilter)) }) if err != nil { ec.Error(ctx, err) @@ -1663,26 +2242,55 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]*model.Transaction) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOTransaction2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_transactions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + 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") + switch field.Name { + case "index": + return ec.fieldContext_Transaction_index(ctx, field) + case "hash": + return ec.fieldContext_Transaction_hash(ctx, field) + case "block_height": + return ec.fieldContext_Transaction_block_height(ctx, field) + case "gas_wanted": + return ec.fieldContext_Transaction_gas_wanted(ctx, field) + case "gas_used": + return ec.fieldContext_Transaction_gas_used(ctx, field) + case "content_raw": + return ec.fieldContext_Transaction_content_raw(ctx, field) + case "messages": + return ec.fieldContext_Transaction_messages(ctx, field) + case "memo": + return ec.fieldContext_Transaction_memo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Transaction", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_transactions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) +func (ec *executionContext) _Query_blocks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_blocks(ctx, field) if err != nil { return graphql.Null } @@ -1695,38 +2303,58 @@ func (ec *executionContext) ___EnumValue_isDeprecated(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.IsDeprecated(), nil + return ec.resolvers.Query().Blocks(rctx, fc.Args["filter"].(model.BlockFilter)) }) 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) + res := resTmp.([]*model.Block) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOBlock2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlockᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_blocks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "height": + return ec.fieldContext_Block_height(ctx, field) + case "version": + return ec.fieldContext_Block_version(ctx, field) + case "chain_id": + return ec.fieldContext_Block_chain_id(ctx, field) + case "time": + return ec.fieldContext_Block_time(ctx, field) + case "proposer_address_raw": + return ec.fieldContext_Block_proposer_address_raw(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Block", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_blocks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) +func (ec *executionContext) _Query_latestBlockHeight(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_latestBlockHeight(ctx, field) if err != nil { return graphql.Null } @@ -1739,35 +2367,38 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return ec.resolvers.Query().LatestBlockHeight(rctx) }) 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) + res := resTmp.(int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_latestBlockHeight(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + 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 nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_name(ctx, field) +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } @@ -1780,38 +2411,68 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.introspectType(fc.Args["name"].(string)) }) 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) + res := resTmp.(*introspection.Type) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Query", 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") + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_description(ctx, field) +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) if err != nil { return graphql.Null } @@ -1824,7 +2485,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) @@ -1833,146 +2494,208 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Schema) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Query", 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") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_args(ctx, field) +func (ec *executionContext) _Subscription_transactions(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_transactions(ctx, field) if err != nil { - return graphql.Null + return nil } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + ret = nil } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return ec.resolvers.Subscription().Transactions(rctx, fc.Args["filter"].(model.TransactionFilter)) }) if err != nil { ec.Error(ctx, err) - return graphql.Null + return nil } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } - return graphql.Null + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case res, ok := <-resTmp.(<-chan *model.Transaction): + if !ok { + return nil + } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + ec.marshalNTransaction2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransaction(ctx, field.Selections, res).MarshalGQL(w) + w.Write([]byte{'}'}) + }) + case <-ctx.Done(): + return nil + } } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subscription_transactions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Subscription", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) + case "index": + return ec.fieldContext_Transaction_index(ctx, field) + case "hash": + return ec.fieldContext_Transaction_hash(ctx, field) + case "block_height": + return ec.fieldContext_Transaction_block_height(ctx, field) + case "gas_wanted": + return ec.fieldContext_Transaction_gas_wanted(ctx, field) + case "gas_used": + return ec.fieldContext_Transaction_gas_used(ctx, field) + case "content_raw": + return ec.fieldContext_Transaction_content_raw(ctx, field) + case "messages": + return ec.fieldContext_Transaction_messages(ctx, field) + case "memo": + return ec.fieldContext_Transaction_memo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Transaction", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Subscription_transactions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_type(ctx, field) +func (ec *executionContext) _Subscription_blocks(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_blocks(ctx, field) if err != nil { - return graphql.Null + return nil } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + ret = nil } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return ec.resolvers.Subscription().Blocks(rctx, fc.Args["filter"].(model.BlockFilter)) }) if err != nil { ec.Error(ctx, err) - return graphql.Null + return nil } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } - return graphql.Null + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case res, ok := <-resTmp.(<-chan *model.Block): + if !ok { + return nil + } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + ec.marshalNBlock2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlock(ctx, field.Selections, res).MarshalGQL(w) + w.Write([]byte{'}'}) + }) + case <-ctx.Done(): + return nil + } } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subscription_blocks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Subscription", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "height": + return ec.fieldContext_Block_height(ctx, field) + case "version": + return ec.fieldContext_Block_version(ctx, field) + case "chain_id": + return ec.fieldContext_Block_chain_id(ctx, field) + case "time": + return ec.fieldContext_Block_time(ctx, field) + case "proposer_address_raw": + return ec.fieldContext_Block_proposer_address_raw(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Block", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Subscription_blocks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) +func (ec *executionContext) _Transaction_index(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_index(ctx, field) if err != nil { return graphql.Null } @@ -1985,7 +2708,7 @@ func (ec *executionContext) ___Field_isDeprecated(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.IsDeprecated(), nil + return obj.Index(), nil }) if err != nil { ec.Error(ctx, err) @@ -1997,26 +2720,26 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(int) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_index(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + 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 Boolean does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) +func (ec *executionContext) _Transaction_hash(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_hash(ctx, field) if err != nil { return graphql.Null } @@ -2029,23 +2752,26 @@ func (ec *executionContext) ___Field_deprecationReason(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.DeprecationReason(), nil + return obj.Hash(), 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) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_hash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Transaction", Field: field, IsMethod: true, IsResolver: false, @@ -2056,8 +2782,8 @@ func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.C return fc, nil } -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_name(ctx, field) +func (ec *executionContext) _Transaction_block_height(ctx context.Context, field graphql.CollectedField, obj *model.Transaction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Transaction_block_height(ctx, field) if err != nil { return graphql.Null } @@ -2070,7 +2796,7 @@ func (ec *executionContext) ___InputValue_name(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.Name, nil + return obj.BlockHeight(), nil }) if err != nil { ec.Error(ctx, err) @@ -2082,26 +2808,26 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } 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___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_block_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Transaction", 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") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_description(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 } @@ -2114,35 +2840,38 @@ func (ec *executionContext) ___InputValue_description(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.Description(), nil + return obj.GasWanted(), 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) + res := resTmp.(int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_description(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: "__InputValue", + 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) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_type(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 } @@ -2155,7 +2884,7 @@ func (ec *executionContext) ___InputValue_type(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.Type, nil + return obj.GasUsed(), nil }) if err != nil { ec.Error(ctx, err) @@ -2167,48 +2896,26 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(int) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_type(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: "__InputValue", + Object: "Transaction", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_defaultValue(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 } @@ -2221,25 +2928,28 @@ func (ec *executionContext) ___InputValue_defaultValue(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.DefaultValue, nil + return obj.ContentRaw(), 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) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_defaultValue(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: "__InputValue", + Object: "Transaction", 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") @@ -2248,8 +2958,8 @@ func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.C return fc, nil } -func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_description(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 } @@ -2262,35 +2972,46 @@ func (ec *executionContext) ___Schema_description(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.Description(), nil + 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.(*string) + res := resTmp.([]*model.TransactionMessage) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNTransactionMessage2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessage(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Transaction_messages(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + 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") + 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) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_types(ctx, field) +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 } @@ -2303,7 +3024,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Memo(), nil }) if err != nil { ec.Error(ctx, err) @@ -2315,48 +3036,26 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_types(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: "__Schema", + Object: "Transaction", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_queryType(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 } @@ -2369,7 +3068,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.TypeUrl, nil }) if err != nil { ec.Error(ctx, err) @@ -2381,48 +3080,26 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(model.MessageType) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNMessageType2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_queryType(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: "__Schema", + 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 "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type MessageType does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_mutationType(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 } @@ -2435,57 +3112,38 @@ func (ec *executionContext) ___Schema_mutationType(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.MutationType(), nil + return obj.Route, 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.(*introspection.Type) + res := resTmp.(model.MessageRoute) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNMessageRoute2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_mutationType(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: "__Schema", + 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 "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type MessageRoute does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_subscriptionType(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 } @@ -2498,57 +3156,38 @@ func (ec *executionContext) ___Schema_subscriptionType(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.SubscriptionType(), nil + return obj.Value, 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.(*introspection.Type) + res := resTmp.(model.MessageValue) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNMessageValue2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageValue(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_subscriptionType(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: "__Schema", + 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 "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type MessageValue does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_directives(ctx, field) +func (ec *executionContext) _TxFee_gas_wanted(ctx context.Context, field graphql.CollectedField, obj *model.TxFee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TxFee_gas_wanted(ctx, field) if err != nil { return graphql.Null } @@ -2561,7 +3200,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.GasWanted, nil }) if err != nil { ec.Error(ctx, err) @@ -2573,38 +3212,26 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(int) fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TxFee_gas_wanted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "TxFee", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Directive_name(ctx, field) - case "description": - return ec.fieldContext___Directive_description(ctx, field) - case "locations": - return ec.fieldContext___Directive_locations(ctx, field) - case "args": - return ec.fieldContext___Directive_args(ctx, field) - case "isRepeatable": - return ec.fieldContext___Directive_isRepeatable(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_kind(ctx, field) +func (ec *executionContext) _TxFee_gas_fee(ctx context.Context, field graphql.CollectedField, obj *model.TxFee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TxFee_gas_fee(ctx, field) if err != nil { return graphql.Null } @@ -2617,7 +3244,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.GasFee, nil }) if err != nil { ec.Error(ctx, err) @@ -2629,26 +3256,26 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalN__TypeKind2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TxFee_gas_fee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "TxFee", 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 __TypeKind does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_name(ctx, field) +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { return graphql.Null } @@ -2661,25 +3288,28 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Name, 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) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", 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") @@ -2688,8 +3318,8 @@ func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field return fc, nil } -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_description(ctx, field) +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) if err != nil { return graphql.Null } @@ -2716,9 +3346,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, IsMethod: true, IsResolver: false, @@ -2729,8 +3359,8 @@ func (ec *executionContext) fieldContext___Type_description(ctx context.Context, return fc, nil } -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_fields(ctx, field) +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) if err != nil { return graphql.Null } @@ -2743,60 +3373,38 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + return obj.Locations, 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.([]introspection.Field) + res := resTmp.([]string) fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Field_name(ctx, field) - case "description": - return ec.fieldContext___Field_description(ctx, field) - case "args": - return ec.fieldContext___Field_args(ctx, field) - case "type": - return ec.fieldContext___Field_type(ctx, field) - case "isDeprecated": - return ec.fieldContext___Field_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___Field_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + return nil, errors.New("field of type __DirectiveLocation does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_interfaces(ctx, field) +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) if err != nil { return graphql.Null } @@ -2809,57 +3417,48 @@ func (ec *executionContext) ___Type_interfaces(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.Interfaces(), nil + return obj.Args, 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.([]introspection.Type) + res := resTmp.([]introspection.InputValue) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) case "name": - return ec.fieldContext___Type_name(ctx, field) + return ec.fieldContext___InputValue_name(ctx, field) case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) if err != nil { return graphql.Null } @@ -2872,57 +3471,38 @@ func (ec *executionContext) ___Type_possibleTypes(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.PossibleTypes(), nil + return obj.IsRepeatable, 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.([]introspection.Type) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_enumValues(ctx, field) +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) if err != nil { return graphql.Null } @@ -2935,56 +3515,123 @@ func (ec *executionContext) ___Type_enumValues(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.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + return obj.Name, 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.([]introspection.EnumValue) + res := resTmp.(string) fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___EnumValue_name(ctx, field) - case "description": - return ec.fieldContext___EnumValue_description(ctx, field) - case "isDeprecated": - return ec.fieldContext___EnumValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___EnumValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + 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.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + 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) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + 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.IsDeprecated(), nil + }) + if err != nil { ec.Error(ctx, err) - return fc, 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___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + 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) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_inputFields(ctx, field) +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) if err != nil { return graphql.Null } @@ -2997,7 +3644,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.DeprecationReason(), nil }) if err != nil { ec.Error(ctx, err) @@ -3006,17 +3653,146 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*string) fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", + 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) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(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.Name, 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___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + 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) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(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.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", 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) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(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.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": @@ -3034,8 +3810,8 @@ func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, return fc, nil } -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_ofType(ctx, field) +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) if err != nil { return graphql.Null } @@ -3048,25 +3824,28 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.Type, 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.(*introspection.Type) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Field", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { @@ -3097,8 +3876,8 @@ func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, fiel return fc, nil } -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) if err != nil { return graphql.Null } @@ -3111,209 +3890,2048 @@ func (ec *executionContext) ___Type_specifiedByURL(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.SpecifiedByURL(), nil + return obj.IsDeprecated(), 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) + res := resTmp.(bool) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Field", 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 Boolean does not have child fields") }, } return fc, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputBlockFilter(ctx context.Context, obj interface{}) (model.BlockFilter, error) { - var it model.BlockFilter - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(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.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + 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) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(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.Name, 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___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + 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) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(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.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + 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) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(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.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(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.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(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.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + 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) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(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.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(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.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(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.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(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.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(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.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(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.Name(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + 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) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(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.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + 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) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(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.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(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.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(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.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(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.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(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.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(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.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(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.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + 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 +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputBankMsgSendInput(ctx context.Context, obj interface{}) (model.BankMsgSendInput, error) { + var it model.BankMsgSendInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"from_address", "to_address", "amount"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "from_address": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_address")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.FromAddress = data + case "to_address": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_address")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ToAddress = data + case "amount": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("amount")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Amount = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputBlockFilter(ctx context.Context, obj interface{}) (model.BlockFilter, error) { + var it model.BlockFilter + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"from_height", "to_height", "from_time", "to_time"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "from_height": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_height")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.FromHeight = data + case "to_height": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_height")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ToHeight = data + case "from_time": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_time")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.FromTime = data + case "to_time": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_time")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.ToTime = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMemFileInput(ctx context.Context, obj interface{}) (model.MemFileInput, error) { + var it model.MemFileInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"Name", "Body"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "Name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "Body": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Body")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Body = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMemPackageInput(ctx context.Context, obj interface{}) (model.MemPackageInput, error) { + var it model.MemPackageInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"Name", "Path", "Files"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "Name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "Path": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Path")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Path = data + case "Files": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Files")) + data, err := ec.unmarshalOMemFileInput2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileInput(ctx, v) + if err != nil { + return it, err + } + it.Files = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMsgAddPackageInput(ctx context.Context, obj interface{}) (model.MsgAddPackageInput, error) { + var it model.MsgAddPackageInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"creator", "package", "deposit"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "creator": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("creator")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Creator = data + case "package": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("package")) + data, err := ec.unmarshalOMemPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackageInput(ctx, v) + if err != nil { + return it, err + } + it.Package = data + case "deposit": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("deposit")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Deposit = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMsgCallInput(ctx context.Context, obj interface{}) (model.MsgCallInput, error) { + var it model.MsgCallInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"caller", "send", "pkg_path", "func", "args"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "caller": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("caller")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Caller = data + case "send": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("send")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Send = data + case "pkg_path": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pkg_path")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PkgPath = data + case "func": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("func")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Func = data + case "args": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("args")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Args = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMsgRunInput(ctx context.Context, obj interface{}) (model.MsgRunInput, error) { + var it model.MsgRunInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"caller", "send", "package"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "caller": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("caller")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Caller = data + case "send": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("send")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Send = data + case "package": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("package")) + data, err := ec.unmarshalOMemPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackageInput(ctx, v) + if err != nil { + return it, err + } + it.Package = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTransactionBankMessageInput(ctx context.Context, obj interface{}) (model.TransactionBankMessageInput, error) { + var it model.TransactionBankMessageInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"send"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "send": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("send")) + data, err := ec.unmarshalOBankMsgSendInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBankMsgSendInput(ctx, v) + if err != nil { + return it, err + } + it.Send = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTransactionFilter(ctx context.Context, obj interface{}) (model.TransactionFilter, error) { + var it model.TransactionFilter + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"from_block_height", "to_block_height", "from_index", "to_index", "from_gas_wanted", "to_gas_wanted", "from_gas_used", "to_gas_used", "hash", "message", "memo"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "from_block_height": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_block_height")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.FromBlockHeight = data + case "to_block_height": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_block_height")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ToBlockHeight = data + case "from_index": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_index")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.FromIndex = data + case "to_index": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_index")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ToIndex = data + case "from_gas_wanted": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_gas_wanted")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.FromGasWanted = data + case "to_gas_wanted": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_gas_wanted")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ToGasWanted = data + case "from_gas_used": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_gas_used")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.FromGasUsed = data + case "to_gas_used": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_gas_used")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ToGasUsed = data + case "hash": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Hash = data + case "message": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("message")) + data, err := ec.unmarshalOTransactionMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessageInput(ctx, v) + if err != nil { + return it, err + } + it.Message = data + case "memo": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("memo")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Memo = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTransactionMessageInput(ctx context.Context, obj interface{}) (model.TransactionMessageInput, error) { + var it model.TransactionMessageInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"from_height", "to_height", "from_time", "to_time"} + fieldsInOrder := [...]string{"type_url", "route", "bank_param", "vm_param"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "from_height": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_height")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + case "type_url": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type_url")) + data, err := ec.unmarshalOMessageType2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx, v) if err != nil { return it, err } - it.FromHeight = data - case "to_height": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_height")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.TypeURL = data + case "route": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("route")) + data, err := ec.unmarshalOMessageRoute2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx, v) if err != nil { return it, err } - it.ToHeight = data - case "from_time": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_time")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.Route = data + case "bank_param": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bank_param")) + data, err := ec.unmarshalOTransactionBankMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionBankMessageInput(ctx, v) if err != nil { return it, err } - it.FromTime = data - case "to_time": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_time")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.BankParam = data + case "vm_param": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("vm_param")) + data, err := ec.unmarshalOTransactionVmMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionVMMessageInput(ctx, v) if err != nil { return it, err } - it.ToTime = data + it.VMParam = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTransactionVmMessageInput(ctx context.Context, obj interface{}) (model.TransactionVMMessageInput, error) { + var it model.TransactionVMMessageInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"m_call", "m_addpkg", "m_run"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "m_call": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("m_call")) + data, err := ec.unmarshalOMsgCallInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgCallInput(ctx, v) + if err != nil { + return it, err + } + it.MCall = data + case "m_addpkg": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("m_addpkg")) + data, err := ec.unmarshalOMsgAddPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgAddPackageInput(ctx, v) + if err != nil { + return it, err + } + it.MAddpkg = data + case "m_run": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("m_run")) + data, err := ec.unmarshalOMsgRunInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgRunInput(ctx, v) + if err != nil { + return it, err + } + it.MRun = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) _MessageValue(ctx context.Context, sel ast.SelectionSet, obj model.MessageValue) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case model.BankMsgSend: + return ec._BankMsgSend(ctx, sel, &obj) + case *model.BankMsgSend: + if obj == nil { + return graphql.Null + } + return ec._BankMsgSend(ctx, sel, obj) + case model.MsgCall: + return ec._MsgCall(ctx, sel, &obj) + case *model.MsgCall: + if obj == nil { + return graphql.Null + } + return ec._MsgCall(ctx, sel, obj) + case model.MsgAddPackage: + return ec._MsgAddPackage(ctx, sel, &obj) + case *model.MsgAddPackage: + if obj == nil { + return graphql.Null + } + return ec._MsgAddPackage(ctx, sel, obj) + case model.MsgRun: + return ec._MsgRun(ctx, sel, &obj) + case *model.MsgRun: + if obj == nil { + return graphql.Null + } + return ec._MsgRun(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var bankMsgSendImplementors = []string{"BankMsgSend", "MessageValue"} + +func (ec *executionContext) _BankMsgSend(ctx context.Context, sel ast.SelectionSet, obj *model.BankMsgSend) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, bankMsgSendImplementors) + + 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("BankMsgSend") + case "from_address": + out.Values[i] = ec._BankMsgSend_from_address(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "to_address": + out.Values[i] = ec._BankMsgSend_to_address(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "amount": + out.Values[i] = ec._BankMsgSend_amount(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 blockImplementors = []string{"Block"} + +func (ec *executionContext) _Block(ctx context.Context, sel ast.SelectionSet, obj *model.Block) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, blockImplementors) + + 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("Block") + case "height": + out.Values[i] = ec._Block_height(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "version": + out.Values[i] = ec._Block_version(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "chain_id": + out.Values[i] = ec._Block_chain_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "time": + out.Values[i] = ec._Block_time(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "proposer_address_raw": + out.Values[i] = ec._Block_proposer_address_raw(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 memFileImplementors = []string{"MemFile"} + +func (ec *executionContext) _MemFile(ctx context.Context, sel ast.SelectionSet, obj *model.MemFile) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, memFileImplementors) + + 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("MemFile") + case "Name": + out.Values[i] = ec._MemFile_Name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Body": + out.Values[i] = ec._MemFile_Body(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 memPackageImplementors = []string{"MemPackage"} + +func (ec *executionContext) _MemPackage(ctx context.Context, sel ast.SelectionSet, obj *model.MemPackage) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, memPackageImplementors) + + 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("MemPackage") + case "Name": + out.Values[i] = ec._MemPackage_Name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Path": + out.Values[i] = ec._MemPackage_Path(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "Files": + out.Values[i] = ec._MemPackage_Files(ctx, field, obj) + 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 it, nil + return out } -func (ec *executionContext) unmarshalInputTransactionFilter(ctx context.Context, obj interface{}) (model.TransactionFilter, error) { - var it model.TransactionFilter - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } +var msgAddPackageImplementors = []string{"MsgAddPackage", "MessageValue"} - fieldsInOrder := [...]string{"from_block_height", "to_block_height", "from_index", "to_index", "from_gas_wanted", "to_gas_wanted", "from_gas_used", "to_gas_used", "hash"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "from_block_height": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_block_height")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.FromBlockHeight = data - case "to_block_height": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_block_height")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ToBlockHeight = data - case "from_index": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_index")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.FromIndex = data - case "to_index": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_index")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ToIndex = data - case "from_gas_wanted": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_gas_wanted")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.FromGasWanted = data - case "to_gas_wanted": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_gas_wanted")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ToGasWanted = data - case "from_gas_used": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from_gas_used")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err +func (ec *executionContext) _MsgAddPackage(ctx context.Context, sel ast.SelectionSet, obj *model.MsgAddPackage) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, msgAddPackageImplementors) + + 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("MsgAddPackage") + case "creator": + out.Values[i] = ec._MsgAddPackage_creator(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - it.FromGasUsed = data - case "to_gas_used": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to_gas_used")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err + case "package": + out.Values[i] = ec._MsgAddPackage_package(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - it.ToGasUsed = data - case "hash": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err + case "deposit": + out.Values[i] = ec._MsgAddPackage_deposit(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - it.Hash = data + default: + panic("unknown field " + strconv.Quote(field.Name)) } } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } - return it, nil -} - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** + atomic.AddInt32(&ec.deferred, int32(len(deferred))) -// endregion ************************** interface.gotpl *************************** + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } -// region **************************** object.gotpl **************************** + return out +} -var blockImplementors = []string{"Block"} +var msgCallImplementors = []string{"MsgCall", "MessageValue"} -func (ec *executionContext) _Block(ctx context.Context, sel ast.SelectionSet, obj *model.Block) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, blockImplementors) +func (ec *executionContext) _MsgCall(ctx context.Context, sel ast.SelectionSet, obj *model.MsgCall) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, msgCallImplementors) 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("Block") - case "height": - out.Values[i] = ec._Block_height(ctx, field, obj) + out.Values[i] = graphql.MarshalString("MsgCall") + case "caller": + out.Values[i] = ec._MsgCall_caller(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "version": - out.Values[i] = ec._Block_version(ctx, field, obj) + case "send": + out.Values[i] = ec._MsgCall_send(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "chain_id": - out.Values[i] = ec._Block_chain_id(ctx, field, obj) + case "pkg_path": + out.Values[i] = ec._MsgCall_pkg_path(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "time": - out.Values[i] = ec._Block_time(ctx, field, obj) + case "func": + out.Values[i] = ec._MsgCall_func(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "proposer_address_raw": - out.Values[i] = ec._Block_proposer_address_raw(ctx, field, obj) + case "args": + out.Values[i] = ec._MsgCall_args(ctx, field, obj) + 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 msgRunImplementors = []string{"MsgRun", "MessageValue"} + +func (ec *executionContext) _MsgRun(ctx context.Context, sel ast.SelectionSet, obj *model.MsgRun) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, msgRunImplementors) + + 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("MsgRun") + case "caller": + out.Values[i] = ec._MsgRun_caller(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "send": + out.Values[i] = ec._MsgRun_send(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "package": + out.Values[i] = ec._MsgRun_package(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -3499,17 +6117,120 @@ func (ec *executionContext) _Transaction(ctx context.Context, sel ast.SelectionS out.Invalids++ } case "gas_wanted": - out.Values[i] = ec._Transaction_gas_wanted(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "gas_used": - out.Values[i] = ec._Transaction_gas_used(ctx, field, obj) + out.Values[i] = ec._Transaction_gas_wanted(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "gas_used": + out.Values[i] = ec._Transaction_gas_used(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "content_raw": + out.Values[i] = ec._Transaction_content_raw(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "messages": + out.Values[i] = ec._Transaction_messages(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "memo": + out.Values[i] = ec._Transaction_memo(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 transactionMessageImplementors = []string{"TransactionMessage"} + +func (ec *executionContext) _TransactionMessage(ctx context.Context, sel ast.SelectionSet, obj *model.TransactionMessage) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, transactionMessageImplementors) + + 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("TransactionMessage") + case "typeUrl": + out.Values[i] = ec._TransactionMessage_typeUrl(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "route": + out.Values[i] = ec._TransactionMessage_route(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "value": + out.Values[i] = ec._TransactionMessage_value(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 { + fields := graphql.CollectFields(ec.OperationContext, sel, txFeeImplementors) + + 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("TxFee") + case "gas_wanted": + out.Values[i] = ec._TxFee_gas_wanted(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "content_raw": - out.Values[i] = ec._Transaction_content_raw(ctx, field, obj) + case "gas_fee": + out.Values[i] = ec._TxFee_gas_fee(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -3926,6 +6647,56 @@ func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.Selec return res } +func (ec *executionContext) marshalNMemFile2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFile(ctx context.Context, sel ast.SelectionSet, v *model.MemFile) 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._MemFile(ctx, sel, v) +} + +func (ec *executionContext) marshalNMemPackage2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackage(ctx context.Context, sel ast.SelectionSet, v *model.MemPackage) 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._MemPackage(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNMessageRoute2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx context.Context, v interface{}) (model.MessageRoute, error) { + var res model.MessageRoute + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNMessageRoute2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx context.Context, sel ast.SelectionSet, v model.MessageRoute) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNMessageType2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx context.Context, v interface{}) (model.MessageType, error) { + var res model.MessageType + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNMessageType2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx context.Context, sel ast.SelectionSet, v model.MessageType) graphql.Marshaler { + return v +} + +func (ec *executionContext) marshalNMessageValue2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageValue(ctx context.Context, sel ast.SelectionSet, v model.MessageValue) 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._MessageValue(ctx, sel, v) +} + func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) @@ -3975,6 +6746,44 @@ func (ec *executionContext) unmarshalNTransactionFilter2githubᚗcomᚋgnolang return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNTransactionMessage2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessage(ctx context.Context, sel ast.SelectionSet, v []*model.TransactionMessage) 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.marshalOTransactionMessage2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessage(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + 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) } @@ -4228,6 +7037,14 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return res } +func (ec *executionContext) unmarshalOBankMsgSendInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBankMsgSendInput(ctx context.Context, v interface{}) (*model.BankMsgSendInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputBankMsgSendInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOBlock2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBlockᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Block) graphql.Marshaler { if v == nil { return graphql.Null @@ -4317,6 +7134,183 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return res } +func (ec *executionContext) marshalOMemFile2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.MemFile) 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.marshalNMemFile2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFile(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) unmarshalOMemFileInput2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileInput(ctx context.Context, v interface{}) ([]*model.MemFileInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*model.MemFileInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOMemFileInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOMemFileInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileInput(ctx context.Context, v interface{}) (*model.MemFileInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMemFileInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOMemPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemPackageInput(ctx context.Context, v interface{}) (*model.MemPackageInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMemPackageInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOMessageRoute2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx context.Context, v interface{}) (*model.MessageRoute, error) { + if v == nil { + return nil, nil + } + var res = new(model.MessageRoute) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOMessageRoute2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx context.Context, sel ast.SelectionSet, v *model.MessageRoute) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOMessageType2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx context.Context, v interface{}) (*model.MessageType, error) { + if v == nil { + return nil, nil + } + var res = new(model.MessageType) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOMessageType2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx context.Context, sel ast.SelectionSet, v *model.MessageType) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOMsgAddPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgAddPackageInput(ctx context.Context, v interface{}) (*model.MsgAddPackageInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMsgAddPackageInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOMsgCallInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgCallInput(ctx context.Context, v interface{}) (*model.MsgCallInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMsgCallInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOMsgRunInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgRunInput(ctx context.Context, v interface{}) (*model.MsgRunInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMsgRunInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + if v == nil { + return nil, nil + } + 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) marshalOString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + 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) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil @@ -4396,6 +7390,37 @@ func (ec *executionContext) marshalOTransaction2ᚕᚖgithubᚗcomᚋgnolangᚋt return ret } +func (ec *executionContext) unmarshalOTransactionBankMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionBankMessageInput(ctx context.Context, v interface{}) (*model.TransactionBankMessageInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputTransactionBankMessageInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOTransactionMessage2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessage(ctx context.Context, sel ast.SelectionSet, v *model.TransactionMessage) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._TransactionMessage(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOTransactionMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionMessageInput(ctx context.Context, v interface{}) (*model.TransactionMessageInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputTransactionMessageInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOTransactionVmMessageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐTransactionVMMessageInput(ctx context.Context, v interface{}) (*model.TransactionVMMessageInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputTransactionVmMessageInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/serve/graph/resolver.go b/serve/graph/resolver.go deleted file mode 100644 index 8241fc3b..00000000 --- a/serve/graph/resolver.go +++ /dev/null @@ -1,77 +0,0 @@ -//go:generate go run github.com/99designs/gqlgen generate - -package graph - -import ( - "context" - "fmt" - - "github.com/99designs/gqlgen/graphql" - - "github.com/gnolang/tx-indexer/events" - "github.com/gnolang/tx-indexer/storage" - "github.com/gnolang/tx-indexer/types" -) - -// This file will not be regenerated automatically. -// -// It serves as dependency injection for your app, add any dependencies you require here. - -const maxElementsPerQuery = 10000 - -func deref[T any](v *T) T { - if v == nil { - var zero T - - return zero - } - - return *v -} - -func handleChannel[T any]( - ctx context.Context, - m *events.Manager, - writeToChannel func(*types.NewBlock, chan<- T), -) <-chan T { - ch := make(chan T) - go func() { - defer close(ch) - - sub := m.Subscribe([]events.Type{types.NewBlockEvent}) - defer m.CancelSubscription(sub.ID) - - for { - select { - case <-ctx.Done(): - graphql.AddError(ctx, ctx.Err()) - - return - case rawE, ok := <-sub.SubCh: - if !ok { - return - } - - e, ok := rawE.GetData().(*types.NewBlock) - if !ok { - graphql.AddError(ctx, fmt.Errorf("error casting event data. Obtained event ID: %q", rawE.GetType())) - - return - } - - writeToChannel(e, ch) - } - } - }() - - return ch -} - -type Resolver struct { - store storage.Storage - manager *events.Manager -} - -func NewResolver(s storage.Storage, m *events.Manager) *Resolver { - return &Resolver{store: s, manager: m} -} diff --git a/serve/graph/schema.graphql b/serve/graph/schema.graphql deleted file mode 100644 index b166c06c..00000000 --- a/serve/graph/schema.graphql +++ /dev/null @@ -1,205 +0,0 @@ -""" -Represents a blockchain block with various attributes detailing its creation and content. -""" -type Block { - - """ - A unique identifier for the Block determined by its position in the blockchain. - This integer is strictly increasing with each new Block. - """ - height: Int! - - """ - The software version of the node that created this Block, indicating the specific - implementation and versioning of the blockchain protocol used. - """ - version: String! - - """ - An identifier for the specific blockchain network this Block belongs to. Helps in - distinguishing between different networks like mainnet, testnet, etc. - """ - chain_id: String! - - """ - The timestamp at which this Block was proposed and finalized in the blockchain. Represented in UTC. - """ - time: Time! - - """ - Encoded data representing the blockchain address of the proposer who submitted this Block. - It is raw and requires decoding to be human-readable. - """ - proposer_address_raw: String! -} - -""" -Defines a transaction within a block, detailing its execution specifics and content. -""" -type Transaction { - - """ - A sequential index representing the order of this Transaction within its Block. Unique within the context of its Block. - """ - index: Int! - - """ - Hash from Transaction content in base64 encoding. - """ - hash: String! - - """ - The height of the Block in which this Transaction is included. Links the Transaction to its containing Block. - """ - block_height: Int! - - """ - The declared amount of computational effort the sender is willing to pay for executing this Transaction. - """ - gas_wanted: Int! - - """ - The actual amount of computational effort consumed to execute this Transaction. It could be less or equal to `gas_wanted`. - """ - gas_used: Int! - - """ - The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. - """ - content_raw: String! -} - -""" -Filters for querying Blocks within specified criteria related to their attributes. -""" -input BlockFilter { - - """ - Minimum block height from which to start fetching Blocks, inclusive. If unspecified, there is no lower bound. - """ - from_height: Int - - """ - Maximum block height up to which Blocks should be fetched, exclusive. If unspecified, there is no upper bound. - """ - to_height: Int - - """ - Minimum timestamp from which to start fetching Blocks, inclusive. Blocks created at or after this time will be included. - """ - from_time: Time - - """ - Maximum timestamp up to which to fetch Blocks, exclusive. Only Blocks created before this time are included. - """ - to_time: Time -} - -""" -Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. -""" -input TransactionFilter { - - """ - Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. - """ - from_block_height: Int - - """ - Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. - """ - to_block_height: Int - - """ - Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. - """ - from_index: Int - - """ - Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. - """ - to_index: Int - - """ - Minimum `gas_wanted` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. - """ - from_gas_wanted: Int - - """ - Maximum `gas_wanted` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. - """ - to_gas_wanted: Int - - """ - Minimum `gas_used` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. - """ - from_gas_used: Int - - """ - Maximum `gas_used` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. - """ - to_gas_used: Int - - """ - Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. - """ - hash: String - -} - -""" -Root Query type to fetch data about Blocks and Transactions based on filters or retrieve the latest block height. -""" -type Query { - - """ - Retrieves a list of Transactions that match the given filter criteria. If the result is incomplete due to errors, both partial results and errors are returned. - """ - transactions(filter: TransactionFilter!): [Transaction!] - - """ - Fetches Blocks matching the specified filter criteria. Incomplete results due to errors return both the partial Blocks and the associated errors. - """ - blocks(filter: BlockFilter!): [Block!] - - """ - Returns the height of the most recently processed Block by the blockchain indexer, indicating the current length of the blockchain. - """ - latestBlockHeight: Int! -} - -""" -Subscriptions provide a way for clients to receive real-time updates about Transactions and Blocks based on specified filter criteria. -Subscribers will only receive updates for events occurring after the subscription is established. -""" -type Subscription { - - """ - Subscribes to real-time updates of Transactions that match the provided filter criteria. - This subscription starts immediately and only includes Transactions added to the blockchain after the subscription is active. - - This is useful for applications needing to track Transactions in real-time, such as wallets tracking incoming transactions - or analytics platforms monitoring blockchain activity. - - Returns: - - Transaction: Each received update is a Transaction object that matches the filter criteria. - """ - transactions: Transaction! - - """ - Subscribes to real-time updates of Blocks that match the provided filter criteria. Similar to the Transactions subscription, - this subscription is active immediately upon creation and only includes Blocks added after the subscription begins. - - This subscription is ideal for services that need to be notified of new Blocks for processing or analysis, such as block explorers, - data aggregators, or security monitoring tools. - - Returns: - - Block: Each update consists of a Block object that satisfies the filter criteria, allowing subscribers to process or analyze new Blocks in real time. - """ - blocks: Block! -} - -""" -Field representing a point on time. It is following the RFC3339Nano format ("2006-01-02T15:04:05.999999999Z07:00") -""" -scalar Time diff --git a/serve/graph/schema.resolvers.go b/serve/graph/schema.resolvers.go deleted file mode 100644 index 0e2180bd..00000000 --- a/serve/graph/schema.resolvers.go +++ /dev/null @@ -1,167 +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.43 - -import ( - "context" - "math" - - "github.com/99designs/gqlgen/graphql" - "github.com/gnolang/tx-indexer/serve/graph/model" - "github.com/gnolang/tx-indexer/types" - "github.com/vektah/gqlparser/v2/gqlerror" -) - -// Transactions is the resolver for the transactions field. -func (r *queryResolver) Transactions(ctx context.Context, filter model.TransactionFilter) ([]*model.Transaction, error) { - if filter.Hash != nil { - tx, err := r.store.GetTxByHash(*filter.Hash) - if err != nil { - return nil, gqlerror.Wrap(err) - } - - return []*model.Transaction{model.NewTransaction(tx)}, nil - } - - it, err := r. - store. - TxIterator( - uint64(deref(filter.FromBlockHeight)), - uint64(deref(filter.ToBlockHeight)), - uint32(deref(filter.FromIndex)), - uint32(deref(filter.ToIndex)), - ) - if err != nil { - return nil, gqlerror.Wrap(err) - } - defer it.Close() - - fgw := deref(filter.FromGasUsed) - tgw := deref(filter.ToGasWanted) - if tgw == 0 { - tgw = math.MaxInt - } - fgu := deref(filter.FromGasUsed) - tgu := deref(filter.ToGasUsed) - if tgu == 0 { - tgu = math.MaxInt - } - - var out []*model.Transaction - i := 0 - for { - if i == maxElementsPerQuery { - graphql.AddErrorf(ctx, "max elements per query reached (%d)", maxElementsPerQuery) - return out, nil - } - - if !it.Next() { - return out, it.Error() - } - - select { - case <-ctx.Done(): - graphql.AddError(ctx, ctx.Err()) - return out, nil - default: - t, err := it.Value() - if err != nil { - graphql.AddError(ctx, err) - return out, nil - } - - if !(t.Response.GasUsed >= int64(fgu) && (t.Response.GasUsed <= int64(tgu))) { - continue - } - if !(t.Response.GasWanted >= int64(fgw) && (t.Response.GasWanted <= int64(tgw))) { - continue - } - - out = append(out, model.NewTransaction(t)) - i++ - } - } -} - -// Blocks is the resolver for the blocks field. -func (r *queryResolver) Blocks(ctx context.Context, filter model.BlockFilter) ([]*model.Block, error) { - it, err := r. - store. - BlockIterator( - uint64(deref(filter.FromHeight)), - uint64(deref(filter.ToHeight)), - ) - if err != nil { - return nil, gqlerror.Wrap(err) - } - defer it.Close() - - var out []*model.Block - - i := 0 - for { - if i == maxElementsPerQuery { - graphql.AddErrorf(ctx, "max elements per query reached (%d)", maxElementsPerQuery) - return out, nil - } - - if !it.Next() { - return out, it.Error() - } - - select { - case <-ctx.Done(): - graphql.AddError(ctx, ctx.Err()) - return out, nil - default: - b, err := it.Value() - if err != nil { - graphql.AddError(ctx, err) - return out, nil - } - - dft := deref(filter.FromTime) - dtt := deref(filter.ToTime) - - if !((b.Time.After(dft) || b.Time.Equal(dft)) && (dtt.IsZero() || b.Time.Before(dtt))) { - continue - } - - out = append(out, model.NewBlock(b)) - i++ - } - } -} - -// LatestBlockHeight is the resolver for the latestBlockHeight field. -func (r *queryResolver) LatestBlockHeight(ctx context.Context) (int, error) { - h, err := r.store.GetLatestHeight() - return int(h), err -} - -// Transactions is the resolver for the transactions field. -func (r *subscriptionResolver) Transactions(ctx context.Context) (<-chan *model.Transaction, error) { - return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Transaction) { - for _, tx := range nb.Results { - c <- model.NewTransaction(tx) - } - }), nil -} - -// Blocks is the resolver for the blocks field. -func (r *subscriptionResolver) Blocks(ctx context.Context) (<-chan *model.Block, error) { - return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Block) { - c <- model.NewBlock(nb.Block) - }), nil -} - -// Query returns QueryResolver implementation. -func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } - -// Subscription returns SubscriptionResolver implementation. -func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } - -type queryResolver struct{ *Resolver } -type subscriptionResolver struct{ *Resolver } diff --git a/serve/graph/schema/filter/block_filter.graphql b/serve/graph/schema/filter/block_filter.graphql new file mode 100644 index 00000000..b1eac178 --- /dev/null +++ b/serve/graph/schema/filter/block_filter.graphql @@ -0,0 +1,24 @@ +""" +Filters for querying Blocks within specified criteria related to their attributes. +""" +input BlockFilter { + """ + Minimum block height from which to start fetching Blocks, inclusive. If unspecified, there is no lower bound. + """ + from_height: Int + + """ + Maximum block height up to which Blocks should be fetched, exclusive. If unspecified, there is no upper bound. + """ + to_height: Int + + """ + Minimum timestamp from which to start fetching Blocks, inclusive. Blocks created at or after this time will be included. + """ + from_time: Time + + """ + Maximum timestamp up to which to fetch Blocks, exclusive. Only Blocks created before this time are included. + """ + to_time: Time +} diff --git a/serve/graph/schema/filter/transaction_filter.graphql b/serve/graph/schema/filter/transaction_filter.graphql new file mode 100644 index 00000000..1711ca51 --- /dev/null +++ b/serve/graph/schema/filter/transaction_filter.graphql @@ -0,0 +1,215 @@ +""" +Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. +""" +input TransactionFilter { + """ + Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. + """ + from_block_height: Int + + """ + Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. + """ + to_block_height: Int + + """ + Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. + """ + from_index: Int + + """ + Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. + """ + to_index: Int + + """ + Minimum `gas_wanted` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. + """ + from_gas_wanted: Int + + """ + Maximum `gas_wanted` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. + """ + to_gas_wanted: Int + + """ + Minimum `gas_used` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. + """ + from_gas_used: Int + + """ + Maximum `gas_used` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. + """ + to_gas_used: Int + + """ + Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. + """ + hash: String + + """ + Transaction's message to filter Transactions. + """ + message: TransactionMessageInput + + """ + `memo` value to filter Transaction's memo. + """ + memo: String +} + +""" +Input for filters by transaction message. +""" +input TransactionMessageInput { + """ + The type of transaction message. + """ + type_url: MessageType + + """ + The route of transaction message. + """ + route: MessageRoute + + """ + Input parameters required when the message router type is `bank`. + """ + bank_param: TransactionBankMessageInput + + """ + Input parameters required when the message router type is `vm`. + """ + vm_param: TransactionVmMessageInput +} + +""" +Input parameters required when the message router is `bank`. +""" +input TransactionBankMessageInput { + """ + Input parameters required when the message type is `send`. + """ + send: BankMsgSendInput +} + +""" +Input parameters required when the message type is `send`. +""" +input BankMsgSendInput { + """ + Filter by `from_address`. + """ + from_address: String + + """ + Filter by `to_address`. + """ + to_address: String + + """ + Filter by `amount`. + """ + amount: String +} + +""" +Input parameters required when the message router is `vm`. +""" +input TransactionVmMessageInput { + """ + Input parameters required when the message type is `exec`. + """ + m_call: MsgCallInput + + """ + Input parameters required when the message type is `add_package`. + """ + m_addpkg: MsgAddPackageInput + + """ + Input parameters required when the message type is `run`. + """ + m_run: MsgRunInput +} + +""" +Input parameters required when the message type is `exec`. +""" +input MsgCallInput { + """ + Filter by `caller`. + """ + caller: String + + """ + Filter by `send`. + """ + send: String + + """ + Filter by `pkg_path`. + """ + pkg_path: String + + """ + Filter by `func`. + """ + func: String + + """ + Filter by `args`, Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + """ + args: [String!] +} + +""" +Input parameters required when the message type is `add_package`. +""" +input MsgAddPackageInput { + """ + Filter by `creator`. + """ + creator: String + + """ + Filter by `package`. + """ + package: MemPackageInput + + """ + Filter by `deposit`. + """ + deposit: String +} + +""" +Input parameters required when the message type is `run`. +""" +input MsgRunInput { + """ + Filter by `caller`. + """ + caller: String + + """ + Filter by `send`. + """ + send: String + + """ + Filter by `package`. + """ + package: MemPackageInput +} + +input MemPackageInput { + Name: String + Path: String + Files: [MemFileInput] +} + +input MemFileInput { + Name: String + Body: String +} diff --git a/serve/graph/schema/query.graphql b/serve/graph/schema/query.graphql new file mode 100644 index 00000000..5ab9c837 --- /dev/null +++ b/serve/graph/schema/query.graphql @@ -0,0 +1,19 @@ +""" +Root Query type to fetch data about Blocks and Transactions based on filters or retrieve the latest block height. +""" +type Query { + """ + Retrieves a list of Transactions that match the given filter criteria. If the result is incomplete due to errors, both partial results and errors are returned. + """ + transactions(filter: TransactionFilter!): [Transaction!] + + """ + Fetches Blocks matching the specified filter criteria. Incomplete results due to errors return both the partial Blocks and the associated errors. + """ + blocks(filter: BlockFilter!): [Block!] + + """ + Returns the height of the most recently processed Block by the blockchain indexer, indicating the current length of the blockchain. + """ + latestBlockHeight: Int! +} diff --git a/serve/graph/schema/schema.graphql b/serve/graph/schema/schema.graphql new file mode 100644 index 00000000..2b8bc3ff --- /dev/null +++ b/serve/graph/schema/schema.graphql @@ -0,0 +1,9 @@ +schema { + query: Query + subscription: Subscription +} + +""" +Field representing a point on time. It is following the RFC3339Nano format ("2006-01-02T15:04:05.999999999Z07:00") +""" +scalar Time diff --git a/serve/graph/schema/subscription.graphql b/serve/graph/schema/subscription.graphql new file mode 100644 index 00000000..f363c8d1 --- /dev/null +++ b/serve/graph/schema/subscription.graphql @@ -0,0 +1,29 @@ +""" +Subscriptions provide a way for clients to receive real-time updates about Transactions and Blocks based on specified filter criteria. +Subscribers will only receive updates for events occurring after the subscription is established. +""" +type Subscription { + """ + Subscribes to real-time updates of Transactions that match the provided filter criteria. + This subscription starts immediately and only includes Transactions added to the blockchain after the subscription is active. + + This is useful for applications needing to track Transactions in real-time, such as wallets tracking incoming transactions + or analytics platforms monitoring blockchain activity. + + Returns: + - Transaction: Each received update is a Transaction object that matches the filter criteria. + """ + transactions(filter: TransactionFilter!): Transaction! + + """ + Subscribes to real-time updates of Blocks that match the provided filter criteria. Similar to the Transactions subscription, + this subscription is active immediately upon creation and only includes Blocks added after the subscription begins. + + This subscription is ideal for services that need to be notified of new Blocks for processing or analysis, such as block explorers, + data aggregators, or security monitoring tools. + + Returns: + - Block: Each update consists of a Block object that satisfies the filter criteria, allowing subscribers to process or analyze new Blocks in real time. + """ + blocks(filter: BlockFilter!): Block! +} diff --git a/serve/graph/schema/types/block.graphql b/serve/graph/schema/types/block.graphql new file mode 100644 index 00000000..3747ff5e --- /dev/null +++ b/serve/graph/schema/types/block.graphql @@ -0,0 +1,33 @@ +""" +Represents a blockchain block with various attributes detailing its creation and content. +""" +type Block { + """ + A unique identifier for the Block determined by its position in the blockchain. + This integer is strictly increasing with each new Block. + """ + height: Int! + + """ + The software version of the node that created this Block, indicating the specific + implementation and versioning of the blockchain protocol used. + """ + version: String! + + """ + An identifier for the specific blockchain network this Block belongs to. Helps in + distinguishing between different networks like mainnet, testnet, etc. + """ + chain_id: String! + + """ + The timestamp at which this Block was proposed and finalized in the blockchain. Represented in UTC. + """ + time: Time! + + """ + Encoded data representing the blockchain address of the proposer who submitted this Block. + It is raw and requires decoding to be human-readable. + """ + proposer_address_raw: String! +} diff --git a/serve/graph/schema/types/transaction.graphql b/serve/graph/schema/types/transaction.graphql new file mode 100644 index 00000000..4e10c095 --- /dev/null +++ b/serve/graph/schema/types/transaction.graphql @@ -0,0 +1,106 @@ +""" +Defines a transaction within a block, detailing its execution specifics and content. +""" +type Transaction { + """ + A sequential index representing the order of this Transaction within its Block. Unique within the context of its Block. + """ + index: Int! + + """ + Hash from Transaction content in base64 encoding. + """ + hash: String! + + """ + The height of the Block in which this Transaction is included. Links the Transaction to its containing Block. + """ + block_height: Int! + + """ + The declared amount of computational effort the sender is willing to pay for executing this Transaction. + """ + gas_wanted: Int! + + """ + The actual amount of computational effort consumed to execute this Transaction. It could be less or equal to `gas_wanted`. + """ + gas_used: Int! + + """ + The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. + """ + content_raw: String! + + """ + The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. + """ + messages: [TransactionMessage]! + + """ + The memo of the Transaction. + """ + memo: String! +} + +enum MessageRoute { + vm + bank +} + +enum MessageType { + send + exec + add_package + run +} + +type TransactionMessage { + typeUrl: MessageType! + route: MessageRoute! + value: MessageValue! +} + +union MessageValue = BankMsgSend | MsgCall | MsgAddPackage | MsgRun + +type BankMsgSend { + from_address: String! + to_address: String! + amount: String! +} + +type MsgCall { + caller: String! + send: String! + pkg_path: String! + func: String! + args: [String!] +} + +type MsgAddPackage { + creator: String! + package: MemPackage! + deposit: String! +} + +type MsgRun { + caller: String! + send: String! + package: MemPackage! +} + +type MemPackage { + Name: String! + Path: String! + Files: [MemFile!] +} + +type MemFile { + Name: String! + Body: String! +} + +type TxFee { + gas_wanted: Int! + gas_fee: Int! +} diff --git a/serve/graph/setup.go b/serve/graph/setup.go index 787fbefc..6bc0eb76 100644 --- a/serve/graph/setup.go +++ b/serve/graph/setup.go @@ -4,14 +4,15 @@ import ( "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" - "github.com/go-chi/chi/v5" - "github.com/gnolang/tx-indexer/events" + "github.com/gnolang/tx-indexer/serve/graph/generated" + "github.com/gnolang/tx-indexer/serve/graph/resolvers" "github.com/gnolang/tx-indexer/storage" + "github.com/go-chi/chi/v5" ) func Setup(s storage.Storage, manager *events.Manager, m *chi.Mux) *chi.Mux { - srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: NewResolver(s, manager)})) + srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: resolvers.NewResolver(s, manager)})) srv.AddTransport(&transport.Websocket{}) From 469327fdad66c7358c45b59329c4340185d85902 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Mon, 1 Apr 2024 12:30:27 +0900 Subject: [PATCH 05/25] feat: Implements transaction message encoding and message filter --- serve/graph/generated/generated.go | 3 + serve/graph/model/block_filter.go | 44 +++ serve/graph/model/models_gen.go | 253 ++++++++++++++-- serve/graph/model/transaction.go | 109 ++++++- serve/graph/model/transaction_filter.go | 278 ++++++++++++++++++ serve/graph/model/utils.go | 113 +++++++ serve/graph/resolvers/query.resolvers.go | 128 ++++++++ serve/graph/resolvers/resolver.go | 76 +++++ .../graph/resolvers/subscription.resolvers.go | 39 +++ 9 files changed, 1002 insertions(+), 41 deletions(-) create mode 100644 serve/graph/model/block_filter.go create mode 100644 serve/graph/model/transaction_filter.go create mode 100644 serve/graph/model/utils.go create mode 100644 serve/graph/resolvers/query.resolvers.go create mode 100644 serve/graph/resolvers/resolver.go create mode 100644 serve/graph/resolvers/subscription.resolvers.go diff --git a/serve/graph/generated/generated.go b/serve/graph/generated/generated.go index 281ff65d..f1573b1d 100644 --- a/serve/graph/generated/generated.go +++ b/serve/graph/generated/generated.go @@ -962,6 +962,9 @@ type Transaction { """ messages: [TransactionMessage]! + """ + The memo of the Transaction. + """ memo: String! } diff --git a/serve/graph/model/block_filter.go b/serve/graph/model/block_filter.go new file mode 100644 index 00000000..5577650e --- /dev/null +++ b/serve/graph/model/block_filter.go @@ -0,0 +1,44 @@ +package model + +import ( + "time" + + "github.com/gnolang/gno/tm2/pkg/bft/types" +) + +type BlockFilter struct { + // Minimum block height from which to start fetching Blocks, inclusive. Aids in scoping the search to recent Blocks. + FromHeight *int `json:"from_height,omitempty"` + // Maximum block height up to which Blocks should be fetched, exclusive. Helps in limiting the search to older Blocks. + ToHeight *int `json:"to_height,omitempty"` + // Minimum block create time from which to start fetching Blocks, inclusive. Aids in scoping the search to recent Blocks. + FromTime *time.Time `json:"from_time,omitempty"` + // Maximum block create time up to which Blocks should be fetched, exclusive. Helps in limiting the search to older Blocks. + ToTime *time.Time `json:"to_time,omitempty"` +} + +func (filter *BlockFilter) GetFromHeight() uint64 { + return uint64(Deref(filter.FromHeight)) +} + +func (filter *BlockFilter) GetToHeight() uint64 { + return uint64(Deref(filter.ToHeight)) +} + +func (filter *BlockFilter) GetFromTime() time.Time { + return Deref(filter.FromTime) +} + +func (filter *BlockFilter) GetToTime() time.Time { + return Deref(filter.ToTime) +} + +func (filter *BlockFilter) FilterBy(block *types.Block) bool { + return filter.filterByBlockTime(block.Time) +} + +func (filter *BlockFilter) filterByBlockTime(blockTime time.Time) bool { + fromTime := filter.GetFromTime() + toTIme := filter.GetToTime() + return (blockTime.After(fromTime) || blockTime.Equal(fromTime)) && (toTIme.IsZero() || blockTime.Before(toTIme)) +} diff --git a/serve/graph/model/models_gen.go b/serve/graph/model/models_gen.go index cd99b076..100e1de5 100644 --- a/serve/graph/model/models_gen.go +++ b/serve/graph/model/models_gen.go @@ -3,19 +3,113 @@ package model import ( - "time" + "fmt" + "io" + "strconv" ) -// Filters for querying Blocks within specified criteria related to their attributes. -type BlockFilter struct { - // Minimum block height from which to start fetching Blocks, inclusive. If unspecified, there is no lower bound. - FromHeight *int `json:"from_height,omitempty"` - // Maximum block height up to which Blocks should be fetched, exclusive. If unspecified, there is no upper bound. - ToHeight *int `json:"to_height,omitempty"` - // Minimum timestamp from which to start fetching Blocks, inclusive. Blocks created at or after this time will be included. - FromTime *time.Time `json:"from_time,omitempty"` - // Maximum timestamp up to which to fetch Blocks, exclusive. Only Blocks created before this time are included. - ToTime *time.Time `json:"to_time,omitempty"` +type MessageValue interface { + IsMessageValue() +} + +type BankMsgSend struct { + FromAddress string `json:"from_address"` + ToAddress string `json:"to_address"` + Amount string `json:"amount"` +} + +func (BankMsgSend) IsMessageValue() {} + +// Input parameters required when the message type is `send`. +type BankMsgSendInput struct { + // Filter by `from_address`. + FromAddress *string `json:"from_address,omitempty"` + // Filter by `to_address`. + ToAddress *string `json:"to_address,omitempty"` + // Filter by `amount`. + Amount *string `json:"amount,omitempty"` +} + +type MemFile struct { + Name string `json:"Name"` + Body string `json:"Body"` +} + +type MemFileInput struct { + Name *string `json:"Name,omitempty"` + Body *string `json:"Body,omitempty"` +} + +type MemPackage struct { + Name string `json:"Name"` + Path string `json:"Path"` + Files []*MemFile `json:"Files,omitempty"` +} + +type MemPackageInput struct { + Name *string `json:"Name,omitempty"` + Path *string `json:"Path,omitempty"` + Files []*MemFileInput `json:"Files,omitempty"` +} + +type MsgAddPackage struct { + Creator string `json:"creator"` + Package *MemPackage `json:"package"` + Deposit string `json:"deposit"` +} + +func (MsgAddPackage) IsMessageValue() {} + +// Input parameters required when the message type is `add_package`. +type MsgAddPackageInput struct { + // Filter by `creator`. + Creator *string `json:"creator,omitempty"` + // Filter by `package`. + Package *MemPackageInput `json:"package,omitempty"` + // Filter by `deposit`. + Deposit *string `json:"deposit,omitempty"` +} + +type MsgCall struct { + Caller string `json:"caller"` + Send string `json:"send"` + PkgPath string `json:"pkg_path"` + Func string `json:"func"` + Args []string `json:"args,omitempty"` +} + +func (MsgCall) IsMessageValue() {} + +// Input parameters required when the message type is `exec`. +type MsgCallInput struct { + // Filter by `caller`. + Caller *string `json:"caller,omitempty"` + // Filter by `send`. + Send *string `json:"send,omitempty"` + // Filter by `pkg_path`. + PkgPath *string `json:"pkg_path,omitempty"` + // Filter by `func`. + Func *string `json:"func,omitempty"` + // Filter by `args`, Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + Args []string `json:"args,omitempty"` +} + +type MsgRun struct { + Caller string `json:"caller"` + Send string `json:"send"` + Package *MemPackage `json:"package"` +} + +func (MsgRun) IsMessageValue() {} + +// Input parameters required when the message type is `run`. +type MsgRunInput struct { + // Filter by `caller`. + Caller *string `json:"caller,omitempty"` + // Filter by `send`. + Send *string `json:"send,omitempty"` + // Filter by `package`. + Package *MemPackageInput `json:"package,omitempty"` } // Root Query type to fetch data about Blocks and Transactions based on filters or retrieve the latest block height. @@ -27,24 +121,121 @@ type Query struct { type Subscription struct { } -// Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. -type TransactionFilter struct { - // Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. - FromBlockHeight *int `json:"from_block_height,omitempty"` - // Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. - ToBlockHeight *int `json:"to_block_height,omitempty"` - // Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. - FromIndex *int `json:"from_index,omitempty"` - // Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. - ToIndex *int `json:"to_index,omitempty"` - // Minimum `gas_wanted` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. - FromGasWanted *int `json:"from_gas_wanted,omitempty"` - // Maximum `gas_wanted` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. - ToGasWanted *int `json:"to_gas_wanted,omitempty"` - // Minimum `gas_used` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. - FromGasUsed *int `json:"from_gas_used,omitempty"` - // Maximum `gas_used` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. - ToGasUsed *int `json:"to_gas_used,omitempty"` - // Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. - Hash *string `json:"hash,omitempty"` +// Input parameters required when the message router is `bank`. +type TransactionBankMessageInput struct { + // Input parameters required when the message type is `send`. + Send *BankMsgSendInput `json:"send,omitempty"` +} + +// Input for filters by transaction message. +type TransactionMessageInput struct { + // The type of transaction message. + TypeURL *MessageType `json:"type_url,omitempty"` + // The route of transaction message. + Route *MessageRoute `json:"route,omitempty"` + // Input parameters required when the message router type is `bank`. + BankParam *TransactionBankMessageInput `json:"bank_param,omitempty"` + // Input parameters required when the message router type is `vm`. + VMParam *TransactionVMMessageInput `json:"vm_param,omitempty"` +} + +// Input parameters required when the message router is `vm`. +type TransactionVMMessageInput struct { + // Input parameters required when the message type is `exec`. + MCall *MsgCallInput `json:"m_call,omitempty"` + // Input parameters required when the message type is `add_package`. + MAddpkg *MsgAddPackageInput `json:"m_addpkg,omitempty"` + // Input parameters required when the message type is `run`. + MRun *MsgRunInput `json:"m_run,omitempty"` +} + +type TxFee struct { + GasWanted int `json:"gas_wanted"` + GasFee int `json:"gas_fee"` +} + +type MessageRoute string + +const ( + MessageRouteVM MessageRoute = "vm" + MessageRouteBank MessageRoute = "bank" +) + +var AllMessageRoute = []MessageRoute{ + MessageRouteVM, + MessageRouteBank, +} + +func (e MessageRoute) IsValid() bool { + switch e { + case MessageRouteVM, MessageRouteBank: + return true + } + return false +} + +func (e MessageRoute) String() string { + return string(e) +} + +func (e *MessageRoute) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MessageRoute(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MessageRoute", str) + } + return nil +} + +func (e MessageRoute) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type MessageType string + +const ( + MessageTypeSend MessageType = "send" + MessageTypeExec MessageType = "exec" + MessageTypeAddPackage MessageType = "add_package" + MessageTypeRun MessageType = "run" +) + +var AllMessageType = []MessageType{ + MessageTypeSend, + MessageTypeExec, + MessageTypeAddPackage, + MessageTypeRun, +} + +func (e MessageType) IsValid() bool { + switch e { + case MessageTypeSend, MessageTypeExec, MessageTypeAddPackage, MessageTypeRun: + return true + } + return false +} + +func (e MessageType) String() string { + return string(e) +} + +func (e *MessageType) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MessageType(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MessageType", str) + } + return nil +} + +func (e MessageType) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) } diff --git a/serve/graph/model/transaction.go b/serve/graph/model/transaction.go index ab4b9173..3eb9af21 100644 --- a/serve/graph/model/transaction.go +++ b/serve/graph/model/transaction.go @@ -4,41 +4,130 @@ import ( "encoding/base64" "fmt" + "github.com/gnolang/gno/gno.land/pkg/sdk/vm" + "github.com/gnolang/gno/tm2/pkg/amino" "github.com/gnolang/gno/tm2/pkg/bft/types" + "github.com/gnolang/gno/tm2/pkg/sdk/bank" + "github.com/gnolang/gno/tm2/pkg/std" ) type Transaction struct { - t *types.TxResult + txResult *types.TxResult + messages []*TransactionMessage + memo string } -func NewTransaction(t *types.TxResult) *Transaction { - return &Transaction{t: t} +func NewTransaction(txResult *types.TxResult) *Transaction { + var stdTx std.Tx + amino.Unmarshal(txResult.Tx, &stdTx) + + messages := make([]*TransactionMessage, 0) + for _, message := range stdTx.GetMsgs() { + messages = append(messages, NewTransactionMessage(message)) + } + return &Transaction{txResult: txResult, messages: messages, memo: stdTx.GetMemo()} } func (t *Transaction) ID() string { - return fmt.Sprintf("%d_%d", t.t.Height, t.t.Index) + return fmt.Sprintf("%d_%d", t.txResult.Height, t.txResult.Index) } func (t *Transaction) Index() int { - return int(t.t.Index) + return int(t.txResult.Index) } func (t *Transaction) Hash() string { - return base64.StdEncoding.EncodeToString(t.t.Tx.Hash()) + return base64.StdEncoding.EncodeToString(t.txResult.Tx.Hash()) } func (t *Transaction) BlockHeight() int { - return int(t.t.Height) + return int(t.txResult.Height) } func (t *Transaction) GasWanted() int { - return int(t.t.Response.GasWanted) + return int(t.txResult.Response.GasWanted) } func (t *Transaction) GasUsed() int { - return int(t.t.Response.GasUsed) + return int(t.txResult.Response.GasUsed) } func (t *Transaction) ContentRaw() string { - return t.t.Tx.String() + return t.txResult.Tx.String() +} + +func (t *Transaction) Memo() string { + return t.memo +} + +func (t *Transaction) Messages() []*TransactionMessage { + return t.messages +} + +func (t *Transaction) Fee() *TxFee { + return &TxFee{ + GasWanted: t.GasWanted(), + GasFee: t.GasUsed(), + } +} + +type TransactionMessage struct { + TypeUrl MessageType + Route MessageRoute + Value MessageValue +} + +func NewTransactionMessage(message std.Msg) *TransactionMessage { + var contentMessage *TransactionMessage + + switch message.Route() { + case bank.RouterKey: + switch message.Type() { + case MessageTypeSend.String(): + contentMessage = &TransactionMessage{ + Route: MessageRouteBank, + TypeUrl: MessageTypeSend, + Value: ParseBankMsgSend(message), + } + } + case vm.RouterKey: + switch message.Type() { + case MessageTypeExec.String(): + contentMessage = &TransactionMessage{ + Route: MessageRouteVM, + TypeUrl: MessageTypeExec, + Value: ParseVmMsgCall(message), + } + case MessageTypeAddPackage.String(): + contentMessage = &TransactionMessage{ + Route: MessageRouteVM, + TypeUrl: MessageTypeAddPackage, + Value: ParseVmAddPackage(message), + } + case MessageTypeRun.String(): + contentMessage = &TransactionMessage{ + Route: MessageRouteVM, + TypeUrl: MessageTypeRun, + Value: ParseVmMsgRun(message), + } + } + } + + return contentMessage +} + +func (tm *TransactionMessage) BankMsgSend() BankMsgSend { + return tm.Value.(BankMsgSend) +} + +func (tm *TransactionMessage) VmMsgCall() MsgCall { + return tm.Value.(MsgCall) +} + +func (tm *TransactionMessage) VmAddPackage() MsgAddPackage { + return tm.Value.(MsgAddPackage) +} + +func (tm *TransactionMessage) VmMsgRun() MsgRun { + return tm.Value.(MsgRun) } diff --git a/serve/graph/model/transaction_filter.go b/serve/graph/model/transaction_filter.go new file mode 100644 index 00000000..22962a65 --- /dev/null +++ b/serve/graph/model/transaction_filter.go @@ -0,0 +1,278 @@ +package model + +import "math" + +// Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. +type TransactionFilter struct { + // Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. + FromBlockHeight *int `json:"from_block_height,omitempty"` + // Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. + ToBlockHeight *int `json:"to_block_height,omitempty"` + // Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. + FromIndex *int `json:"from_index,omitempty"` + // Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. + ToIndex *int `json:"to_index,omitempty"` + // Minimum `gas_wanted` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. + FromGasWanted *int `json:"from_gas_wanted,omitempty"` + // Maximum `gas_wanted` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. + ToGasWanted *int `json:"to_gas_wanted,omitempty"` + // Minimum `gas_used` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. + FromGasUsed *int `json:"from_gas_used,omitempty"` + // Maximum `gas_used` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. + ToGasUsed *int `json:"to_gas_used,omitempty"` + // Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. + Hash *string `json:"hash,omitempty"` + // Transaction's message to filter Transactions. + Message *TransactionMessageInput `json:"message,omitempty"` + // `memo` value to filter Transaction's memo. + Memo *string `json:"memo,omitempty"` +} + +func (filter *TransactionFilter) GetFromBlockHeight() uint64 { + return uint64(Deref(filter.FromBlockHeight)) +} + +func (filter *TransactionFilter) GetToBlockHeight() uint64 { + return uint64(Deref(filter.ToBlockHeight)) +} + +func (filter *TransactionFilter) GetFromIndex() uint32 { + return uint32(Deref(filter.FromIndex)) +} + +func (filter *TransactionFilter) GetToIndex() uint32 { + return uint32(Deref(filter.ToIndex)) +} + +// Transaction +// for all filter types +func (filter *TransactionFilter) FilterBy(tx *Transaction) bool { + if filter == nil { + return true + } + if !filter.filterByGasUsed(tx) { + return false + } + if !filter.filterByGasWanted(tx) { + return false + } + if !filter.filterByMemo(tx) { + return false + } + if !filter.filterByMessages(tx) { + return false + } + return true +} + +func (filter *TransactionFilter) filterByGasUsed(tx *Transaction) bool { + fromGasUsed := Deref(filter.FromGasUsed) + toGasUsed := Deref(filter.ToGasUsed) + if toGasUsed == 0 { + toGasUsed = math.MaxInt + } + return tx.GasUsed() >= fromGasUsed && tx.GasUsed() <= toGasUsed +} + +func (filter *TransactionFilter) filterByGasWanted(tx *Transaction) bool { + fromGasWanted := Deref(filter.FromGasWanted) + toGasWanted := Deref(filter.ToGasWanted) + if toGasWanted == 0 { + toGasWanted = math.MaxInt + } + return tx.GasWanted() >= fromGasWanted && tx.GasWanted() <= toGasWanted +} + +func (filter *TransactionFilter) filterByMessages(tx *Transaction) bool { + if filter.Message == nil { + return true + } + if !filter.filterByMessageRoutes(tx) { + return false + } + if !filter.filterByMessageTypes(tx) { + return false + } + for _, message := range tx.messages { + if !filter.filterByMessageContent(message) { + return false + } + } + return true +} + +func (filter *TransactionFilter) filterByMessageRoutes(tx *Transaction) bool { + if filter.Message.Route == nil { + return true + } + for _, message := range tx.messages { + if message.Route.String() == filter.Message.Route.String() { + return true + } + } + return false +} + +func (filter *TransactionFilter) filterByMessageTypes(tx *Transaction) bool { + if filter.Message.TypeURL == nil { + return true + } + for _, message := range tx.messages { + if message.TypeUrl.String() == filter.Message.TypeURL.String() { + return true + } + } + return false +} + +func (filter *TransactionFilter) filterByMessageContent(tm *TransactionMessage) bool { + if filter.Message.TypeURL != nil && filter.Message.TypeURL.String() != tm.TypeUrl.String() { + return false + } + + if filter.Message.BankParam == nil && filter.Message.VMParam == nil { + return true + } + + switch tm.Route { + case MessageRouteBank: + if filter.Message.BankParam == nil { + return false + } + case MessageRouteVM: + if filter.Message.VMParam == nil { + return false + } + } + + switch tm.TypeUrl { + case MessageTypeSend: + if !filter.filterByMessageOfBankMsgSend(tm.BankMsgSend()) { + return false + } + case MessageTypeExec: + if !filter.filterByMessageOfMsgCall(tm.VmMsgCall()) { + return false + } + case MessageTypeAddPackage: + if !filter.filterByMessageOfMsgAddPackage(tm.VmAddPackage()) { + return false + } + case MessageTypeRun: + if !filter.filterByMessageOfMsgRun(tm.VmMsgRun()) { + return false + } + } + return true +} + +func (filter *TransactionFilter) filterByMemo(tx *Transaction) bool { + if filter.Memo == nil { + return true + } + return *filter.Memo == tx.Memo() +} + +func (filter *TransactionFilter) filterByMessageOfBankMsgSend(messageValue BankMsgSend) bool { + params := filter.Message.BankParam + if params == nil || params.Send == nil { + return true + } + if params.Send.Amount != nil && Deref(params.Send.Amount) != messageValue.Amount { + return false + } + if params.Send.FromAddress != nil && Deref(params.Send.FromAddress) != messageValue.FromAddress { + return false + } + if params.Send.ToAddress != nil && Deref(params.Send.ToAddress) != messageValue.ToAddress { + return false + } + return true +} + +func (filter *TransactionFilter) filterByMessageOfMsgCall(messageValue MsgCall) bool { + params := filter.Message.VMParam + if params == nil { + return true + } + if params.MCall == nil { + return false + } + if params.MCall.Caller != nil && Deref(params.MCall.Caller) != messageValue.Caller { + return false + } + if params.MCall.Func != nil && Deref(params.MCall.Func) != messageValue.Func { + return false + } + if params.MCall.PkgPath != nil && Deref(params.MCall.PkgPath) != messageValue.PkgPath { + return false + } + if params.MCall.Send != nil && Deref(params.MCall.Send) != messageValue.Send { + return false + } + if params.MCall.Args != nil { + messageArgs := messageValue.Args + if messageArgs == nil { + return false + } + messageFilterArgs := params.MCall.Args + for index, arg := range messageArgs { + if index < len(messageFilterArgs) { + if arg != "" && messageFilterArgs[index] != arg { + return false + } + } + } + } + return true +} + +func (filter *TransactionFilter) filterByMessageOfMsgAddPackage(messageValue MsgAddPackage) bool { + params := filter.Message.VMParam + if params == nil { + return true + } + if params.MAddpkg == nil { + return false + } + if params.MAddpkg.Creator != nil && Deref(params.MAddpkg.Creator) != messageValue.Creator { + return false + } + if params.MAddpkg.Deposit != nil && Deref(params.MAddpkg.Deposit) != messageValue.Deposit { + return false + } + if params.MAddpkg.Package != nil { + if params.MAddpkg.Package.Name != nil && Deref(params.MAddpkg.Package.Name) != messageValue.Package.Name { + return false + } + if params.MAddpkg.Package.Path != nil && Deref(params.MAddpkg.Package.Path) != messageValue.Package.Path { + return false + } + } + return true +} + +func (filter *TransactionFilter) filterByMessageOfMsgRun(messageValue MsgRun) bool { + params := filter.Message.VMParam + if params == nil { + return true + } + if params.MRun == nil { + return false + } + if params.MRun.Caller != nil && Deref(params.MRun.Caller) != messageValue.Caller { + return false + } + if params.MRun.Send != nil && Deref(params.MRun.Send) != messageValue.Send { + return false + } + if params.MRun.Package != nil { + if params.MRun.Package.Name != nil && Deref(params.MRun.Package.Name) != messageValue.Package.Name { + return false + } + if params.MRun.Package.Path != nil && Deref(params.MRun.Package.Path) != messageValue.Package.Path { + return false + } + } + return true +} diff --git a/serve/graph/model/utils.go b/serve/graph/model/utils.go new file mode 100644 index 00000000..ad4f91ed --- /dev/null +++ b/serve/graph/model/utils.go @@ -0,0 +1,113 @@ +package model + +import ( + "encoding/json" + + "github.com/gnolang/gno/gno.land/pkg/sdk/vm" + "github.com/gnolang/gno/tm2/pkg/sdk/bank" + "github.com/gnolang/gno/tm2/pkg/std" +) + +// Deref dereferences a pointer variable. +func Deref[T any](v *T) T { + if v == nil { + var zero T + + return zero + } + return *v + +} + +// Cast casts a type. +func Cast[T any](input any) (*T, error) { + encoded, err := json.Marshal(input) + if err != nil { + return nil, err + } + + var data T + if err = json.Unmarshal(encoded, &data); err != nil { + return nil, err + } + + return &data, nil +} + +func ParseBankMsgSend(value std.Msg) BankMsgSend { + decodedMessage, err := Cast[bank.MsgSend](value) + if err != nil { + return BankMsgSend{} + } + + return BankMsgSend{ + FromAddress: decodedMessage.FromAddress.String(), + ToAddress: decodedMessage.ToAddress.String(), + Amount: decodedMessage.Amount.String(), + } +} + +func ParseVmMsgCall(value std.Msg) MsgCall { + decodedMessage, err := Cast[vm.MsgCall](value) + if err != nil { + return MsgCall{} + } + + return MsgCall{ + Caller: decodedMessage.Caller.String(), + Send: decodedMessage.Send.String(), + PkgPath: decodedMessage.PkgPath, + Func: decodedMessage.Func, + Args: decodedMessage.Args, + } +} + +func ParseVmAddPackage(value std.Msg) MsgAddPackage { + decodedMessage, err := Cast[vm.MsgAddPackage](value) + if err != nil { + return MsgAddPackage{} + } + + memFiles := make([]*MemFile, 0) + for _, file := range decodedMessage.Package.Files { + memFiles = append(memFiles, &MemFile{ + Name: file.Name, + Body: file.Body, + }) + } + + return MsgAddPackage{ + Creator: decodedMessage.Creator.String(), + Package: &MemPackage{ + Name: decodedMessage.Package.Name, + Path: decodedMessage.Package.Path, + Files: memFiles, + }, + Deposit: decodedMessage.Deposit.String(), + } +} + +func ParseVmMsgRun(value std.Msg) MsgRun { + decodedMessage, err := Cast[vm.MsgRun](value) + if err != nil { + return MsgRun{} + } + + memFiles := make([]*MemFile, 0) + for _, file := range decodedMessage.Package.Files { + memFiles = append(memFiles, &MemFile{ + Name: file.Name, + Body: file.Body, + }) + } + + return MsgRun{ + Caller: decodedMessage.Caller.String(), + Send: decodedMessage.Send.String(), + Package: &MemPackage{ + Name: decodedMessage.Package.Name, + Path: decodedMessage.Package.Path, + Files: memFiles, + }, + } +} diff --git a/serve/graph/resolvers/query.resolvers.go b/serve/graph/resolvers/query.resolvers.go new file mode 100644 index 00000000..c534e058 --- /dev/null +++ b/serve/graph/resolvers/query.resolvers.go @@ -0,0 +1,128 @@ +package resolvers + +// 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/99designs/gqlgen/graphql" + "github.com/gnolang/tx-indexer/serve/graph/generated" + "github.com/gnolang/tx-indexer/serve/graph/model" + "github.com/vektah/gqlparser/v2/gqlerror" +) + +// Transactions is the resolver for the transactions field. +func (r *queryResolver) Transactions(ctx context.Context, filter model.TransactionFilter) ([]*model.Transaction, error) { + if filter.Hash != nil { + tx, err := r.store.GetTxByHash(*filter.Hash) + if err != nil { + return nil, gqlerror.Wrap(err) + } + return []*model.Transaction{model.NewTransaction(tx)}, nil + } + + it, err := r. + store. + TxIterator( + filter.GetFromBlockHeight(), + filter.GetToBlockHeight(), + filter.GetFromIndex(), + filter.GetToIndex(), + ) + if err != nil { + return nil, gqlerror.Wrap(err) + } + defer it.Close() + + var out []*model.Transaction + i := 0 + for { + if i == maxElementsPerQuery { + graphql.AddErrorf(ctx, "max elements per query reached (%d)", maxElementsPerQuery) + return out, nil + } + + if !it.Next() { + return out, it.Error() + } + + select { + case <-ctx.Done(): + graphql.AddError(ctx, ctx.Err()) + return out, nil + default: + t, err := it.Value() + if err != nil { + graphql.AddError(ctx, err) + return out, nil + } + + transaction := model.NewTransaction(t) + if !filter.FilterBy(transaction) { + continue + } + out = append(out, transaction) + i++ + } + } +} + +// Blocks is the resolver for the blocks field. +func (r *queryResolver) Blocks(ctx context.Context, filter model.BlockFilter) ([]*model.Block, error) { + it, err := r. + store. + BlockIterator( + filter.GetFromHeight(), + filter.GetToHeight(), + ) + if err != nil { + return nil, gqlerror.Wrap(err) + } + defer it.Close() + + var out []*model.Block + + i := 0 + for { + if i == maxElementsPerQuery { + graphql.AddErrorf(ctx, "max elements per query reached (%d)", maxElementsPerQuery) + return out, nil + } + + if !it.Next() { + return out, it.Error() + } + + select { + case <-ctx.Done(): + graphql.AddError(ctx, ctx.Err()) + return out, nil + default: + b, err := it.Value() + if err != nil { + graphql.AddError(ctx, err) + return out, nil + } + + if !filter.FilterBy(b) { + continue + } + + out = append(out, model.NewBlock(b)) + i++ + } + } +} + +// LatestBlockHeight is the resolver for the latestBlockHeight field. +func (r *queryResolver) LatestBlockHeight(ctx context.Context) (int, error) { + h, err := r.store.GetLatestHeight() + return int(h), err +} + +// Query returns generated.QueryResolver implementation. +func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } + +type queryResolver struct{ *Resolver } diff --git a/serve/graph/resolvers/resolver.go b/serve/graph/resolvers/resolver.go new file mode 100644 index 00000000..65c5f972 --- /dev/null +++ b/serve/graph/resolvers/resolver.go @@ -0,0 +1,76 @@ +//go:generate go run github.com/99designs/gqlgen generate + +package resolvers + +import ( + "context" + "fmt" + + "github.com/99designs/gqlgen/graphql" + "github.com/gnolang/tx-indexer/events" + "github.com/gnolang/tx-indexer/storage" + "github.com/gnolang/tx-indexer/types" +) + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +const maxElementsPerQuery = 10000 + +func deref[T any](v *T) T { + if v == nil { + var zero T + + return zero + } + + return *v +} + +type Resolver struct { + store storage.Storage + manager *events.Manager +} + +func handleChannel[T any]( + ctx context.Context, + m *events.Manager, + writeToChannel func(*types.NewBlock, chan<- T), +) <-chan T { + ch := make(chan T) + go func() { + defer close(ch) + + sub := m.Subscribe([]events.Type{types.NewBlockEvent}) + defer m.CancelSubscription(sub.ID) + + for { + select { + case <-ctx.Done(): + graphql.AddError(ctx, ctx.Err()) + + return + case rawE, ok := <-sub.SubCh: + if !ok { + return + } + + e, ok := rawE.GetData().(*types.NewBlock) + if !ok { + graphql.AddError(ctx, fmt.Errorf("error casting event data. Obtained event ID: %q", rawE.GetType())) + + return + } + + writeToChannel(e, ch) + } + } + }() + + return ch +} + +func NewResolver(s storage.Storage, m *events.Manager) *Resolver { + return &Resolver{store: s, manager: m} +} diff --git a/serve/graph/resolvers/subscription.resolvers.go b/serve/graph/resolvers/subscription.resolvers.go new file mode 100644 index 00000000..ef5c9801 --- /dev/null +++ b/serve/graph/resolvers/subscription.resolvers.go @@ -0,0 +1,39 @@ +package resolvers + +// 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/generated" + "github.com/gnolang/tx-indexer/serve/graph/model" + "github.com/gnolang/tx-indexer/types" +) + +// Transactions is the resolver for the transactions field. +func (r *subscriptionResolver) Transactions(ctx context.Context, filter model.TransactionFilter) (<-chan *model.Transaction, error) { + return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Transaction) { + for _, tx := range nb.Results { + transaction := model.NewTransaction(tx) + if filter.FilterBy(transaction) { + c <- transaction + } + } + }), nil +} + +// Blocks is the resolver for the blocks field. +func (r *subscriptionResolver) Blocks(ctx context.Context, filter model.BlockFilter) (<-chan *model.Block, error) { + return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Block) { + if filter.FilterBy(nb.Block) { + c <- model.NewBlock(nb.Block) + } + }), nil +} + +// Subscription returns generated.SubscriptionResolver implementation. +func (r *Resolver) Subscription() generated.SubscriptionResolver { return &subscriptionResolver{r} } + +type subscriptionResolver struct{ *Resolver } From fa5912b2344c5e2229042ece83e64c72693b93f2 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Mon, 1 Apr 2024 15:10:09 +0900 Subject: [PATCH 06/25] fix: Fix lints --- serve/graph/generated/generated.go | 8 +- serve/graph/model/block_filter.go | 21 +++-- serve/graph/model/transaction.go | 35 ++++---- serve/graph/model/transaction_filter.go | 102 ++++++++++++++++++------ serve/graph/model/utils.go | 10 +-- serve/graph/resolvers/resolver.go | 10 --- serve/graph/setup.go | 4 +- 7 files changed, 121 insertions(+), 69 deletions(-) diff --git a/serve/graph/generated/generated.go b/serve/graph/generated/generated.go index f1573b1d..b053d85d 100644 --- a/serve/graph/generated/generated.go +++ b/serve/graph/generated/generated.go @@ -117,7 +117,7 @@ type ComplexityRoot struct { TransactionMessage struct { Route func(childComplexity int) int - TypeUrl func(childComplexity int) int + TypeURL func(childComplexity int) int Value func(childComplexity int) int } @@ -443,11 +443,11 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.TransactionMessage.Route(childComplexity), true case "TransactionMessage.typeUrl": - if e.complexity.TransactionMessage.TypeUrl == nil { + if e.complexity.TransactionMessage.TypeURL == nil { break } - return e.complexity.TransactionMessage.TypeUrl(childComplexity), true + return e.complexity.TransactionMessage.TypeURL(childComplexity), true case "TransactionMessage.value": if e.complexity.TransactionMessage.Value == nil { @@ -3071,7 +3071,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.TypeURL, nil }) if err != nil { ec.Error(ctx, err) diff --git a/serve/graph/model/block_filter.go b/serve/graph/model/block_filter.go index 5577650e..41cadbb6 100644 --- a/serve/graph/model/block_filter.go +++ b/serve/graph/model/block_filter.go @@ -7,14 +7,18 @@ import ( ) type BlockFilter struct { - // Minimum block height from which to start fetching Blocks, inclusive. Aids in scoping the search to recent Blocks. - FromHeight *int `json:"from_height,omitempty"` - // Maximum block height up to which Blocks should be fetched, exclusive. Helps in limiting the search to older Blocks. - ToHeight *int `json:"to_height,omitempty"` - // Minimum block create time from which to start fetching Blocks, inclusive. Aids in scoping the search to recent Blocks. - FromTime *time.Time `json:"from_time,omitempty"` - // Maximum block create time up to which Blocks should be fetched, exclusive. Helps in limiting the search to older Blocks. - ToTime *time.Time `json:"to_time,omitempty"` + // Minimum block height from which to start fetching Blocks, inclusive. + // Aids in scoping the search to recent Blocks. + FromHeight *int `json:"fromHeight,omitempty"` + // Maximum block height up to which Blocks should be fetched, exclusive. + // Helps in limiting the search to older Blocks. + ToHeight *int `json:"toHeight,omitempty"` + // Minimum block create time from which to start fetching Blocks, inclusive. + // Aids in scoping the search to recent Blocks. + FromTime *time.Time `json:"fromTime,omitempty"` + // Maximum block create time up to which Blocks should be fetched, exclusive. + // Helps in limiting the search to older Blocks. + ToTime *time.Time `json:"toTime,omitempty"` } func (filter *BlockFilter) GetFromHeight() uint64 { @@ -40,5 +44,6 @@ func (filter *BlockFilter) FilterBy(block *types.Block) bool { func (filter *BlockFilter) filterByBlockTime(blockTime time.Time) bool { fromTime := filter.GetFromTime() toTIme := filter.GetToTime() + return (blockTime.After(fromTime) || blockTime.Equal(fromTime)) && (toTIme.IsZero() || blockTime.Before(toTIme)) } diff --git a/serve/graph/model/transaction.go b/serve/graph/model/transaction.go index 3eb9af21..bfca13ef 100644 --- a/serve/graph/model/transaction.go +++ b/serve/graph/model/transaction.go @@ -12,19 +12,23 @@ import ( ) type Transaction struct { + memo string txResult *types.TxResult messages []*TransactionMessage - memo string } func NewTransaction(txResult *types.TxResult) *Transaction { var stdTx std.Tx - amino.Unmarshal(txResult.Tx, &stdTx) + + if err := amino.Unmarshal(txResult.Tx, &stdTx); err != nil { + return nil + } messages := make([]*TransactionMessage, 0) for _, message := range stdTx.GetMsgs() { messages = append(messages, NewTransactionMessage(message)) } + return &Transaction{txResult: txResult, messages: messages, memo: stdTx.GetMemo()} } @@ -72,9 +76,9 @@ func (t *Transaction) Fee() *TxFee { } type TransactionMessage struct { - TypeUrl MessageType - Route MessageRoute Value MessageValue + TypeURL MessageType + Route MessageRoute } func NewTransactionMessage(message std.Msg) *TransactionMessage { @@ -82,11 +86,10 @@ func NewTransactionMessage(message std.Msg) *TransactionMessage { switch message.Route() { case bank.RouterKey: - switch message.Type() { - case MessageTypeSend.String(): + if message.Type() == MessageTypeSend.String() { contentMessage = &TransactionMessage{ Route: MessageRouteBank, - TypeUrl: MessageTypeSend, + TypeURL: MessageTypeSend, Value: ParseBankMsgSend(message), } } @@ -95,20 +98,20 @@ func NewTransactionMessage(message std.Msg) *TransactionMessage { case MessageTypeExec.String(): contentMessage = &TransactionMessage{ Route: MessageRouteVM, - TypeUrl: MessageTypeExec, - Value: ParseVmMsgCall(message), + TypeURL: MessageTypeExec, + Value: ParseVMMsgCall(message), } case MessageTypeAddPackage.String(): contentMessage = &TransactionMessage{ Route: MessageRouteVM, - TypeUrl: MessageTypeAddPackage, - Value: ParseVmAddPackage(message), + TypeURL: MessageTypeAddPackage, + Value: ParseVMAddPackage(message), } case MessageTypeRun.String(): contentMessage = &TransactionMessage{ Route: MessageRouteVM, - TypeUrl: MessageTypeRun, - Value: ParseVmMsgRun(message), + TypeURL: MessageTypeRun, + Value: ParseVMMsgRun(message), } } } @@ -120,14 +123,14 @@ func (tm *TransactionMessage) BankMsgSend() BankMsgSend { return tm.Value.(BankMsgSend) } -func (tm *TransactionMessage) VmMsgCall() MsgCall { +func (tm *TransactionMessage) VMMsgCall() MsgCall { return tm.Value.(MsgCall) } -func (tm *TransactionMessage) VmAddPackage() MsgAddPackage { +func (tm *TransactionMessage) VMAddPackage() MsgAddPackage { return tm.Value.(MsgAddPackage) } -func (tm *TransactionMessage) VmMsgRun() MsgRun { +func (tm *TransactionMessage) VMMsgRun() MsgRun { return tm.Value.(MsgRun) } diff --git a/serve/graph/model/transaction_filter.go b/serve/graph/model/transaction_filter.go index 22962a65..3564fd2f 100644 --- a/serve/graph/model/transaction_filter.go +++ b/serve/graph/model/transaction_filter.go @@ -4,23 +4,32 @@ import "math" // Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. type TransactionFilter struct { - // Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. - FromBlockHeight *int `json:"from_block_height,omitempty"` - // Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. - ToBlockHeight *int `json:"to_block_height,omitempty"` - // Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. - FromIndex *int `json:"from_index,omitempty"` - // Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. - ToIndex *int `json:"to_index,omitempty"` - // Minimum `gas_wanted` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. - FromGasWanted *int `json:"from_gas_wanted,omitempty"` - // Maximum `gas_wanted` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. - ToGasWanted *int `json:"to_gas_wanted,omitempty"` - // Minimum `gas_used` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. - FromGasUsed *int `json:"from_gas_used,omitempty"` - // Maximum `gas_used` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. - ToGasUsed *int `json:"to_gas_used,omitempty"` - // Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. + // Minimum block height from which to start fetching Transactions, inclusive. + // Aids in scoping the search to recent Transactions. + FromBlockHeight *int `json:"fromBlockHeight,omitempty"` + // Maximum block height up to which Transactions should be fetched, exclusive. + // Helps in limiting the search to older Transactions. + ToBlockHeight *int `json:"toBlockHeight,omitempty"` + // Minimum Transaction index from which to start fetching, inclusive. + // Facilitates ordering in Transaction queries. + FromIndex *int `json:"fromIndex,omitempty"` + // Maximum Transaction index up to which to fetch, exclusive. + // Ensures a limit on the ordering range for Transaction queries. + ToIndex *int `json:"toIndex,omitempty"` + // Minimum `gas_wanted` value to filter Transactions by, inclusive. + // Filters Transactions based on the minimum computational effort declared. + FromGasWanted *int `json:"fromGasWanted,omitempty"` + // Maximum `gas_wanted` value for filtering Transactions, exclusive. + // Limits Transactions based on the declared computational effort. + ToGasWanted *int `json:"toGasWanted,omitempty"` + // Minimum `gas_used` value to filter Transactions by, inclusive. + // Selects Transactions based on the minimum computational effort actually used. + FromGasUsed *int `json:"fromGasUsed,omitempty"` + // Maximum `gas_used` value for filtering Transactions, exclusive. + // Refines selection based on the computational effort actually consumed. + ToGasUsed *int `json:"toGasUsed,omitempty"` + // Hash from Transaction content in base64 encoding. + // If this filter is used, any other filter will be ignored. Hash *string `json:"hash,omitempty"` // Transaction's message to filter Transactions. Message *TransactionMessageInput `json:"message,omitempty"` @@ -50,36 +59,45 @@ func (filter *TransactionFilter) FilterBy(tx *Transaction) bool { if filter == nil { return true } + if !filter.filterByGasUsed(tx) { return false } + if !filter.filterByGasWanted(tx) { return false } + if !filter.filterByMemo(tx) { return false } + if !filter.filterByMessages(tx) { return false } + return true } func (filter *TransactionFilter) filterByGasUsed(tx *Transaction) bool { fromGasUsed := Deref(filter.FromGasUsed) toGasUsed := Deref(filter.ToGasUsed) + if toGasUsed == 0 { toGasUsed = math.MaxInt } + return tx.GasUsed() >= fromGasUsed && tx.GasUsed() <= toGasUsed } func (filter *TransactionFilter) filterByGasWanted(tx *Transaction) bool { fromGasWanted := Deref(filter.FromGasWanted) toGasWanted := Deref(filter.ToGasWanted) + if toGasWanted == 0 { toGasWanted = math.MaxInt } + return tx.GasWanted() >= fromGasWanted && tx.GasWanted() <= toGasWanted } @@ -87,17 +105,21 @@ func (filter *TransactionFilter) filterByMessages(tx *Transaction) bool { if filter.Message == nil { return true } + if !filter.filterByMessageRoutes(tx) { return false } + if !filter.filterByMessageTypes(tx) { return false } + for _, message := range tx.messages { if !filter.filterByMessageContent(message) { return false } } + return true } @@ -105,11 +127,13 @@ func (filter *TransactionFilter) filterByMessageRoutes(tx *Transaction) bool { if filter.Message.Route == nil { return true } + for _, message := range tx.messages { if message.Route.String() == filter.Message.Route.String() { return true } } + return false } @@ -117,16 +141,18 @@ func (filter *TransactionFilter) filterByMessageTypes(tx *Transaction) bool { if filter.Message.TypeURL == nil { return true } + for _, message := range tx.messages { - if message.TypeUrl.String() == filter.Message.TypeURL.String() { + if message.TypeURL.String() == filter.Message.TypeURL.String() { return true } } + return false } func (filter *TransactionFilter) filterByMessageContent(tm *TransactionMessage) bool { - if filter.Message.TypeURL != nil && filter.Message.TypeURL.String() != tm.TypeUrl.String() { + if filter.Message.TypeURL != nil && filter.Message.TypeURL.String() != tm.TypeURL.String() { return false } @@ -145,24 +171,25 @@ func (filter *TransactionFilter) filterByMessageContent(tm *TransactionMessage) } } - switch tm.TypeUrl { + switch tm.TypeURL { case MessageTypeSend: if !filter.filterByMessageOfBankMsgSend(tm.BankMsgSend()) { return false } case MessageTypeExec: - if !filter.filterByMessageOfMsgCall(tm.VmMsgCall()) { + if !filter.filterByMessageOfMsgCall(tm.VMMsgCall()) { return false } case MessageTypeAddPackage: - if !filter.filterByMessageOfMsgAddPackage(tm.VmAddPackage()) { + if !filter.filterByMessageOfMsgAddPackage(tm.VMAddPackage()) { return false } case MessageTypeRun: - if !filter.filterByMessageOfMsgRun(tm.VmMsgRun()) { + if !filter.filterByMessageOfMsgRun(tm.VMMsgRun()) { return false } } + return true } @@ -170,6 +197,7 @@ func (filter *TransactionFilter) filterByMemo(tx *Transaction) bool { if filter.Memo == nil { return true } + return *filter.Memo == tx.Memo() } @@ -178,15 +206,19 @@ func (filter *TransactionFilter) filterByMessageOfBankMsgSend(messageValue BankM if params == nil || params.Send == nil { return true } + if params.Send.Amount != nil && Deref(params.Send.Amount) != messageValue.Amount { return false } + if params.Send.FromAddress != nil && Deref(params.Send.FromAddress) != messageValue.FromAddress { return false } + if params.Send.ToAddress != nil && Deref(params.Send.ToAddress) != messageValue.ToAddress { return false } + return true } @@ -195,26 +227,33 @@ func (filter *TransactionFilter) filterByMessageOfMsgCall(messageValue MsgCall) if params == nil { return true } + if params.MCall == nil { return false } + if params.MCall.Caller != nil && Deref(params.MCall.Caller) != messageValue.Caller { return false } + if params.MCall.Func != nil && Deref(params.MCall.Func) != messageValue.Func { return false } + if params.MCall.PkgPath != nil && Deref(params.MCall.PkgPath) != messageValue.PkgPath { return false } + if params.MCall.Send != nil && Deref(params.MCall.Send) != messageValue.Send { return false } + if params.MCall.Args != nil { messageArgs := messageValue.Args if messageArgs == nil { return false } + messageFilterArgs := params.MCall.Args for index, arg := range messageArgs { if index < len(messageFilterArgs) { @@ -224,6 +263,7 @@ func (filter *TransactionFilter) filterByMessageOfMsgCall(messageValue MsgCall) } } } + return true } @@ -232,23 +272,29 @@ func (filter *TransactionFilter) filterByMessageOfMsgAddPackage(messageValue Msg if params == nil { return true } + if params.MAddpkg == nil { return false } + if params.MAddpkg.Creator != nil && Deref(params.MAddpkg.Creator) != messageValue.Creator { return false } + if params.MAddpkg.Deposit != nil && Deref(params.MAddpkg.Deposit) != messageValue.Deposit { return false } + if params.MAddpkg.Package != nil { if params.MAddpkg.Package.Name != nil && Deref(params.MAddpkg.Package.Name) != messageValue.Package.Name { return false } + if params.MAddpkg.Package.Path != nil && Deref(params.MAddpkg.Package.Path) != messageValue.Package.Path { return false } } + return true } @@ -257,22 +303,28 @@ func (filter *TransactionFilter) filterByMessageOfMsgRun(messageValue MsgRun) bo if params == nil { return true } + if params.MRun == nil { return false } + if params.MRun.Caller != nil && Deref(params.MRun.Caller) != messageValue.Caller { return false } + if params.MRun.Send != nil && Deref(params.MRun.Send) != messageValue.Send { return false } + if params.MRun.Package != nil { - if params.MRun.Package.Name != nil && Deref(params.MRun.Package.Name) != messageValue.Package.Name { + if Deref(params.MRun.Package.Name) != messageValue.Package.Name { return false } - if params.MRun.Package.Path != nil && Deref(params.MRun.Package.Path) != messageValue.Package.Path { + + if Deref(params.MRun.Package.Path) != messageValue.Package.Path { return false } } + return true } diff --git a/serve/graph/model/utils.go b/serve/graph/model/utils.go index ad4f91ed..e8325d75 100644 --- a/serve/graph/model/utils.go +++ b/serve/graph/model/utils.go @@ -15,8 +15,8 @@ func Deref[T any](v *T) T { return zero } - return *v + return *v } // Cast casts a type. @@ -27,7 +27,7 @@ func Cast[T any](input any) (*T, error) { } var data T - if err = json.Unmarshal(encoded, &data); err != nil { + if err := json.Unmarshal(encoded, &data); err != nil { return nil, err } @@ -47,7 +47,7 @@ func ParseBankMsgSend(value std.Msg) BankMsgSend { } } -func ParseVmMsgCall(value std.Msg) MsgCall { +func ParseVMMsgCall(value std.Msg) MsgCall { decodedMessage, err := Cast[vm.MsgCall](value) if err != nil { return MsgCall{} @@ -62,7 +62,7 @@ func ParseVmMsgCall(value std.Msg) MsgCall { } } -func ParseVmAddPackage(value std.Msg) MsgAddPackage { +func ParseVMAddPackage(value std.Msg) MsgAddPackage { decodedMessage, err := Cast[vm.MsgAddPackage](value) if err != nil { return MsgAddPackage{} @@ -87,7 +87,7 @@ func ParseVmAddPackage(value std.Msg) MsgAddPackage { } } -func ParseVmMsgRun(value std.Msg) MsgRun { +func ParseVMMsgRun(value std.Msg) MsgRun { decodedMessage, err := Cast[vm.MsgRun](value) if err != nil { return MsgRun{} diff --git a/serve/graph/resolvers/resolver.go b/serve/graph/resolvers/resolver.go index 65c5f972..2e739032 100644 --- a/serve/graph/resolvers/resolver.go +++ b/serve/graph/resolvers/resolver.go @@ -18,16 +18,6 @@ import ( const maxElementsPerQuery = 10000 -func deref[T any](v *T) T { - if v == nil { - var zero T - - return zero - } - - return *v -} - type Resolver struct { store storage.Storage manager *events.Manager diff --git a/serve/graph/setup.go b/serve/graph/setup.go index 6bc0eb76..79307442 100644 --- a/serve/graph/setup.go +++ b/serve/graph/setup.go @@ -12,7 +12,9 @@ import ( ) func Setup(s storage.Storage, manager *events.Manager, m *chi.Mux) *chi.Mux { - srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: resolvers.NewResolver(s, manager)})) + srv := handler.NewDefaultServer(generated.NewExecutableSchema( + generated.Config{Resolvers: resolvers.NewResolver(s, manager)}, + )) srv.AddTransport(&transport.Websocket{}) From 0c0024247f21266aed2d6f5b28a9d5e990c9a8be Mon Sep 17 00:00:00 2001 From: jinoosss Date: Tue, 2 Apr 2024 15:37:02 +0900 Subject: [PATCH 07/25] fix: Remove filter data model --- gqlgen.yml | 6 - serve/graph/model/block_filter.go | 49 ---- serve/graph/model/models_gen.go | 39 +++ serve/graph/model/transaction_filter.go | 330 ------------------------ 4 files changed, 39 insertions(+), 385 deletions(-) delete mode 100644 serve/graph/model/block_filter.go delete mode 100644 serve/graph/model/transaction_filter.go diff --git a/gqlgen.yml b/gqlgen.yml index aec6660b..1bf62a60 100644 --- a/gqlgen.yml +++ b/gqlgen.yml @@ -90,9 +90,3 @@ models: TransactionMessage: model: - github.com/gnolang/tx-indexer/serve/graph/model.TransactionMessage - BlockFilter: - model: - - github.com/gnolang/tx-indexer/serve/graph/model.BlockFilter - TransactionFilter: - model: - - github.com/gnolang/tx-indexer/serve/graph/model.TransactionFilter diff --git a/serve/graph/model/block_filter.go b/serve/graph/model/block_filter.go deleted file mode 100644 index 41cadbb6..00000000 --- a/serve/graph/model/block_filter.go +++ /dev/null @@ -1,49 +0,0 @@ -package model - -import ( - "time" - - "github.com/gnolang/gno/tm2/pkg/bft/types" -) - -type BlockFilter struct { - // Minimum block height from which to start fetching Blocks, inclusive. - // Aids in scoping the search to recent Blocks. - FromHeight *int `json:"fromHeight,omitempty"` - // Maximum block height up to which Blocks should be fetched, exclusive. - // Helps in limiting the search to older Blocks. - ToHeight *int `json:"toHeight,omitempty"` - // Minimum block create time from which to start fetching Blocks, inclusive. - // Aids in scoping the search to recent Blocks. - FromTime *time.Time `json:"fromTime,omitempty"` - // Maximum block create time up to which Blocks should be fetched, exclusive. - // Helps in limiting the search to older Blocks. - ToTime *time.Time `json:"toTime,omitempty"` -} - -func (filter *BlockFilter) GetFromHeight() uint64 { - return uint64(Deref(filter.FromHeight)) -} - -func (filter *BlockFilter) GetToHeight() uint64 { - return uint64(Deref(filter.ToHeight)) -} - -func (filter *BlockFilter) GetFromTime() time.Time { - return Deref(filter.FromTime) -} - -func (filter *BlockFilter) GetToTime() time.Time { - return Deref(filter.ToTime) -} - -func (filter *BlockFilter) FilterBy(block *types.Block) bool { - return filter.filterByBlockTime(block.Time) -} - -func (filter *BlockFilter) filterByBlockTime(blockTime time.Time) bool { - fromTime := filter.GetFromTime() - toTIme := filter.GetToTime() - - return (blockTime.After(fromTime) || blockTime.Equal(fromTime)) && (toTIme.IsZero() || blockTime.Before(toTIme)) -} diff --git a/serve/graph/model/models_gen.go b/serve/graph/model/models_gen.go index 100e1de5..e753ef18 100644 --- a/serve/graph/model/models_gen.go +++ b/serve/graph/model/models_gen.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "strconv" + "time" ) type MessageValue interface { @@ -30,6 +31,18 @@ type BankMsgSendInput struct { Amount *string `json:"amount,omitempty"` } +// Filters for querying Blocks within specified criteria related to their attributes. +type BlockFilter struct { + // Minimum block height from which to start fetching Blocks, inclusive. If unspecified, there is no lower bound. + FromHeight *int `json:"from_height,omitempty"` + // Maximum block height up to which Blocks should be fetched, exclusive. If unspecified, there is no upper bound. + ToHeight *int `json:"to_height,omitempty"` + // Minimum timestamp from which to start fetching Blocks, inclusive. Blocks created at or after this time will be included. + FromTime *time.Time `json:"from_time,omitempty"` + // Maximum timestamp up to which to fetch Blocks, exclusive. Only Blocks created before this time are included. + ToTime *time.Time `json:"to_time,omitempty"` +} + type MemFile struct { Name string `json:"Name"` Body string `json:"Body"` @@ -127,6 +140,32 @@ type TransactionBankMessageInput struct { Send *BankMsgSendInput `json:"send,omitempty"` } +// Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. +type TransactionFilter struct { + // Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. + FromBlockHeight *int `json:"from_block_height,omitempty"` + // Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. + ToBlockHeight *int `json:"to_block_height,omitempty"` + // Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. + FromIndex *int `json:"from_index,omitempty"` + // Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. + ToIndex *int `json:"to_index,omitempty"` + // Minimum `gas_wanted` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. + FromGasWanted *int `json:"from_gas_wanted,omitempty"` + // Maximum `gas_wanted` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. + ToGasWanted *int `json:"to_gas_wanted,omitempty"` + // Minimum `gas_used` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. + FromGasUsed *int `json:"from_gas_used,omitempty"` + // Maximum `gas_used` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. + ToGasUsed *int `json:"to_gas_used,omitempty"` + // Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. + Hash *string `json:"hash,omitempty"` + // Transaction's message to filter Transactions. + Message *TransactionMessageInput `json:"message,omitempty"` + // `memo` value to filter Transaction's memo. + Memo *string `json:"memo,omitempty"` +} + // Input for filters by transaction message. type TransactionMessageInput struct { // The type of transaction message. diff --git a/serve/graph/model/transaction_filter.go b/serve/graph/model/transaction_filter.go deleted file mode 100644 index 3564fd2f..00000000 --- a/serve/graph/model/transaction_filter.go +++ /dev/null @@ -1,330 +0,0 @@ -package model - -import "math" - -// Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. -type TransactionFilter struct { - // Minimum block height from which to start fetching Transactions, inclusive. - // Aids in scoping the search to recent Transactions. - FromBlockHeight *int `json:"fromBlockHeight,omitempty"` - // Maximum block height up to which Transactions should be fetched, exclusive. - // Helps in limiting the search to older Transactions. - ToBlockHeight *int `json:"toBlockHeight,omitempty"` - // Minimum Transaction index from which to start fetching, inclusive. - // Facilitates ordering in Transaction queries. - FromIndex *int `json:"fromIndex,omitempty"` - // Maximum Transaction index up to which to fetch, exclusive. - // Ensures a limit on the ordering range for Transaction queries. - ToIndex *int `json:"toIndex,omitempty"` - // Minimum `gas_wanted` value to filter Transactions by, inclusive. - // Filters Transactions based on the minimum computational effort declared. - FromGasWanted *int `json:"fromGasWanted,omitempty"` - // Maximum `gas_wanted` value for filtering Transactions, exclusive. - // Limits Transactions based on the declared computational effort. - ToGasWanted *int `json:"toGasWanted,omitempty"` - // Minimum `gas_used` value to filter Transactions by, inclusive. - // Selects Transactions based on the minimum computational effort actually used. - FromGasUsed *int `json:"fromGasUsed,omitempty"` - // Maximum `gas_used` value for filtering Transactions, exclusive. - // Refines selection based on the computational effort actually consumed. - ToGasUsed *int `json:"toGasUsed,omitempty"` - // Hash from Transaction content in base64 encoding. - // If this filter is used, any other filter will be ignored. - Hash *string `json:"hash,omitempty"` - // Transaction's message to filter Transactions. - Message *TransactionMessageInput `json:"message,omitempty"` - // `memo` value to filter Transaction's memo. - Memo *string `json:"memo,omitempty"` -} - -func (filter *TransactionFilter) GetFromBlockHeight() uint64 { - return uint64(Deref(filter.FromBlockHeight)) -} - -func (filter *TransactionFilter) GetToBlockHeight() uint64 { - return uint64(Deref(filter.ToBlockHeight)) -} - -func (filter *TransactionFilter) GetFromIndex() uint32 { - return uint32(Deref(filter.FromIndex)) -} - -func (filter *TransactionFilter) GetToIndex() uint32 { - return uint32(Deref(filter.ToIndex)) -} - -// Transaction -// for all filter types -func (filter *TransactionFilter) FilterBy(tx *Transaction) bool { - if filter == nil { - return true - } - - if !filter.filterByGasUsed(tx) { - return false - } - - if !filter.filterByGasWanted(tx) { - return false - } - - if !filter.filterByMemo(tx) { - return false - } - - if !filter.filterByMessages(tx) { - return false - } - - return true -} - -func (filter *TransactionFilter) filterByGasUsed(tx *Transaction) bool { - fromGasUsed := Deref(filter.FromGasUsed) - toGasUsed := Deref(filter.ToGasUsed) - - if toGasUsed == 0 { - toGasUsed = math.MaxInt - } - - return tx.GasUsed() >= fromGasUsed && tx.GasUsed() <= toGasUsed -} - -func (filter *TransactionFilter) filterByGasWanted(tx *Transaction) bool { - fromGasWanted := Deref(filter.FromGasWanted) - toGasWanted := Deref(filter.ToGasWanted) - - if toGasWanted == 0 { - toGasWanted = math.MaxInt - } - - return tx.GasWanted() >= fromGasWanted && tx.GasWanted() <= toGasWanted -} - -func (filter *TransactionFilter) filterByMessages(tx *Transaction) bool { - if filter.Message == nil { - return true - } - - if !filter.filterByMessageRoutes(tx) { - return false - } - - if !filter.filterByMessageTypes(tx) { - return false - } - - for _, message := range tx.messages { - if !filter.filterByMessageContent(message) { - return false - } - } - - return true -} - -func (filter *TransactionFilter) filterByMessageRoutes(tx *Transaction) bool { - if filter.Message.Route == nil { - return true - } - - for _, message := range tx.messages { - if message.Route.String() == filter.Message.Route.String() { - return true - } - } - - return false -} - -func (filter *TransactionFilter) filterByMessageTypes(tx *Transaction) bool { - if filter.Message.TypeURL == nil { - return true - } - - for _, message := range tx.messages { - if message.TypeURL.String() == filter.Message.TypeURL.String() { - return true - } - } - - return false -} - -func (filter *TransactionFilter) filterByMessageContent(tm *TransactionMessage) bool { - if filter.Message.TypeURL != nil && filter.Message.TypeURL.String() != tm.TypeURL.String() { - return false - } - - if filter.Message.BankParam == nil && filter.Message.VMParam == nil { - return true - } - - switch tm.Route { - case MessageRouteBank: - if filter.Message.BankParam == nil { - return false - } - case MessageRouteVM: - if filter.Message.VMParam == nil { - return false - } - } - - switch tm.TypeURL { - case MessageTypeSend: - if !filter.filterByMessageOfBankMsgSend(tm.BankMsgSend()) { - return false - } - case MessageTypeExec: - if !filter.filterByMessageOfMsgCall(tm.VMMsgCall()) { - return false - } - case MessageTypeAddPackage: - if !filter.filterByMessageOfMsgAddPackage(tm.VMAddPackage()) { - return false - } - case MessageTypeRun: - if !filter.filterByMessageOfMsgRun(tm.VMMsgRun()) { - return false - } - } - - return true -} - -func (filter *TransactionFilter) filterByMemo(tx *Transaction) bool { - if filter.Memo == nil { - return true - } - - return *filter.Memo == tx.Memo() -} - -func (filter *TransactionFilter) filterByMessageOfBankMsgSend(messageValue BankMsgSend) bool { - params := filter.Message.BankParam - if params == nil || params.Send == nil { - return true - } - - if params.Send.Amount != nil && Deref(params.Send.Amount) != messageValue.Amount { - return false - } - - if params.Send.FromAddress != nil && Deref(params.Send.FromAddress) != messageValue.FromAddress { - return false - } - - if params.Send.ToAddress != nil && Deref(params.Send.ToAddress) != messageValue.ToAddress { - return false - } - - return true -} - -func (filter *TransactionFilter) filterByMessageOfMsgCall(messageValue MsgCall) bool { - params := filter.Message.VMParam - if params == nil { - return true - } - - if params.MCall == nil { - return false - } - - if params.MCall.Caller != nil && Deref(params.MCall.Caller) != messageValue.Caller { - return false - } - - if params.MCall.Func != nil && Deref(params.MCall.Func) != messageValue.Func { - return false - } - - if params.MCall.PkgPath != nil && Deref(params.MCall.PkgPath) != messageValue.PkgPath { - return false - } - - if params.MCall.Send != nil && Deref(params.MCall.Send) != messageValue.Send { - return false - } - - if params.MCall.Args != nil { - messageArgs := messageValue.Args - if messageArgs == nil { - return false - } - - messageFilterArgs := params.MCall.Args - for index, arg := range messageArgs { - if index < len(messageFilterArgs) { - if arg != "" && messageFilterArgs[index] != arg { - return false - } - } - } - } - - return true -} - -func (filter *TransactionFilter) filterByMessageOfMsgAddPackage(messageValue MsgAddPackage) bool { - params := filter.Message.VMParam - if params == nil { - return true - } - - if params.MAddpkg == nil { - return false - } - - if params.MAddpkg.Creator != nil && Deref(params.MAddpkg.Creator) != messageValue.Creator { - return false - } - - if params.MAddpkg.Deposit != nil && Deref(params.MAddpkg.Deposit) != messageValue.Deposit { - return false - } - - if params.MAddpkg.Package != nil { - if params.MAddpkg.Package.Name != nil && Deref(params.MAddpkg.Package.Name) != messageValue.Package.Name { - return false - } - - if params.MAddpkg.Package.Path != nil && Deref(params.MAddpkg.Package.Path) != messageValue.Package.Path { - return false - } - } - - return true -} - -func (filter *TransactionFilter) filterByMessageOfMsgRun(messageValue MsgRun) bool { - params := filter.Message.VMParam - if params == nil { - return true - } - - if params.MRun == nil { - return false - } - - if params.MRun.Caller != nil && Deref(params.MRun.Caller) != messageValue.Caller { - return false - } - - if params.MRun.Send != nil && Deref(params.MRun.Send) != messageValue.Send { - return false - } - - if params.MRun.Package != nil { - if Deref(params.MRun.Package.Name) != messageValue.Package.Name { - return false - } - - if Deref(params.MRun.Package.Path) != messageValue.Package.Path { - return false - } - } - - return true -} From be287d9fe36d3e44e175c4c99883ac130f2ea1d0 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Tue, 2 Apr 2024 15:38:53 +0900 Subject: [PATCH 08/25] fix: Remove utils --- serve/graph/model/utils.go | 113 ------------------------------ serve/graph/resolvers/resolver.go | 11 +++ 2 files changed, 11 insertions(+), 113 deletions(-) delete mode 100644 serve/graph/model/utils.go diff --git a/serve/graph/model/utils.go b/serve/graph/model/utils.go deleted file mode 100644 index e8325d75..00000000 --- a/serve/graph/model/utils.go +++ /dev/null @@ -1,113 +0,0 @@ -package model - -import ( - "encoding/json" - - "github.com/gnolang/gno/gno.land/pkg/sdk/vm" - "github.com/gnolang/gno/tm2/pkg/sdk/bank" - "github.com/gnolang/gno/tm2/pkg/std" -) - -// Deref dereferences a pointer variable. -func Deref[T any](v *T) T { - if v == nil { - var zero T - - return zero - } - - return *v -} - -// Cast casts a type. -func Cast[T any](input any) (*T, error) { - encoded, err := json.Marshal(input) - if err != nil { - return nil, err - } - - var data T - if err := json.Unmarshal(encoded, &data); err != nil { - return nil, err - } - - return &data, nil -} - -func ParseBankMsgSend(value std.Msg) BankMsgSend { - decodedMessage, err := Cast[bank.MsgSend](value) - if err != nil { - return BankMsgSend{} - } - - return BankMsgSend{ - FromAddress: decodedMessage.FromAddress.String(), - ToAddress: decodedMessage.ToAddress.String(), - Amount: decodedMessage.Amount.String(), - } -} - -func ParseVMMsgCall(value std.Msg) MsgCall { - decodedMessage, err := Cast[vm.MsgCall](value) - if err != nil { - return MsgCall{} - } - - return MsgCall{ - Caller: decodedMessage.Caller.String(), - Send: decodedMessage.Send.String(), - PkgPath: decodedMessage.PkgPath, - Func: decodedMessage.Func, - Args: decodedMessage.Args, - } -} - -func ParseVMAddPackage(value std.Msg) MsgAddPackage { - decodedMessage, err := Cast[vm.MsgAddPackage](value) - if err != nil { - return MsgAddPackage{} - } - - memFiles := make([]*MemFile, 0) - for _, file := range decodedMessage.Package.Files { - memFiles = append(memFiles, &MemFile{ - Name: file.Name, - Body: file.Body, - }) - } - - return MsgAddPackage{ - Creator: decodedMessage.Creator.String(), - Package: &MemPackage{ - Name: decodedMessage.Package.Name, - Path: decodedMessage.Package.Path, - Files: memFiles, - }, - Deposit: decodedMessage.Deposit.String(), - } -} - -func ParseVMMsgRun(value std.Msg) MsgRun { - decodedMessage, err := Cast[vm.MsgRun](value) - if err != nil { - return MsgRun{} - } - - memFiles := make([]*MemFile, 0) - for _, file := range decodedMessage.Package.Files { - memFiles = append(memFiles, &MemFile{ - Name: file.Name, - Body: file.Body, - }) - } - - return MsgRun{ - Caller: decodedMessage.Caller.String(), - Send: decodedMessage.Send.String(), - Package: &MemPackage{ - Name: decodedMessage.Package.Name, - Path: decodedMessage.Package.Path, - Files: memFiles, - }, - } -} diff --git a/serve/graph/resolvers/resolver.go b/serve/graph/resolvers/resolver.go index 2e739032..b537ff84 100644 --- a/serve/graph/resolvers/resolver.go +++ b/serve/graph/resolvers/resolver.go @@ -18,6 +18,17 @@ import ( const maxElementsPerQuery = 10000 +// Deref dereferences a pointer variable. +func deref[T any](v *T) T { + if v == nil { + var zero T + + return zero + } + + return *v +} + type Resolver struct { store storage.Storage manager *events.Manager From aff5033dd764145fa94b0760c2fd2bce2a81cf15 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Tue, 2 Apr 2024 16:34:35 +0900 Subject: [PATCH 09/25] feat: Change filter logic --- serve/graph/model/transaction.go | 101 +++++- serve/graph/resolvers/block.resolvers.go | 36 +++ serve/graph/resolvers/query.resolvers.go | 23 +- serve/graph/resolvers/resolver.go | 12 +- .../graph/resolvers/subscription.resolvers.go | 11 +- .../graph/resolvers/transaction.resolvers.go | 295 ++++++++++++++++++ 6 files changed, 452 insertions(+), 26 deletions(-) create mode 100644 serve/graph/resolvers/block.resolvers.go create mode 100644 serve/graph/resolvers/transaction.resolvers.go diff --git a/serve/graph/model/transaction.go b/serve/graph/model/transaction.go index bfca13ef..c89059f2 100644 --- a/serve/graph/model/transaction.go +++ b/serve/graph/model/transaction.go @@ -2,6 +2,7 @@ package model import ( "encoding/base64" + "encoding/json" "fmt" "github.com/gnolang/gno/gno.land/pkg/sdk/vm" @@ -90,7 +91,7 @@ func NewTransactionMessage(message std.Msg) *TransactionMessage { contentMessage = &TransactionMessage{ Route: MessageRouteBank, TypeURL: MessageTypeSend, - Value: ParseBankMsgSend(message), + Value: makeBankMsgSend(message), } } case vm.RouterKey: @@ -99,19 +100,19 @@ func NewTransactionMessage(message std.Msg) *TransactionMessage { contentMessage = &TransactionMessage{ Route: MessageRouteVM, TypeURL: MessageTypeExec, - Value: ParseVMMsgCall(message), + Value: makeVMMsgCall(message), } case MessageTypeAddPackage.String(): contentMessage = &TransactionMessage{ Route: MessageRouteVM, TypeURL: MessageTypeAddPackage, - Value: ParseVMAddPackage(message), + Value: makeVMAddPackage(message), } case MessageTypeRun.String(): contentMessage = &TransactionMessage{ Route: MessageRouteVM, TypeURL: MessageTypeRun, - Value: ParseVMMsgRun(message), + Value: makeVMMsgRun(message), } } } @@ -134,3 +135,95 @@ func (tm *TransactionMessage) VMAddPackage() MsgAddPackage { func (tm *TransactionMessage) VMMsgRun() MsgRun { return tm.Value.(MsgRun) } + +func makeBankMsgSend(value std.Msg) BankMsgSend { + decodedMessage, err := cast[bank.MsgSend](value) + if err != nil { + return BankMsgSend{} + } + + return BankMsgSend{ + FromAddress: decodedMessage.FromAddress.String(), + ToAddress: decodedMessage.ToAddress.String(), + Amount: decodedMessage.Amount.String(), + } +} + +func makeVMMsgCall(value std.Msg) MsgCall { + decodedMessage, err := cast[vm.MsgCall](value) + if err != nil { + return MsgCall{} + } + + return MsgCall{ + Caller: decodedMessage.Caller.String(), + Send: decodedMessage.Send.String(), + PkgPath: decodedMessage.PkgPath, + Func: decodedMessage.Func, + Args: decodedMessage.Args, + } +} + +func makeVMAddPackage(value std.Msg) MsgAddPackage { + decodedMessage, err := cast[vm.MsgAddPackage](value) + if err != nil { + return MsgAddPackage{} + } + + memFiles := make([]*MemFile, 0) + for _, file := range decodedMessage.Package.Files { + memFiles = append(memFiles, &MemFile{ + Name: file.Name, + Body: file.Body, + }) + } + + return MsgAddPackage{ + Creator: decodedMessage.Creator.String(), + Package: &MemPackage{ + Name: decodedMessage.Package.Name, + Path: decodedMessage.Package.Path, + Files: memFiles, + }, + Deposit: decodedMessage.Deposit.String(), + } +} + +func makeVMMsgRun(value std.Msg) MsgRun { + decodedMessage, err := cast[vm.MsgRun](value) + if err != nil { + return MsgRun{} + } + + memFiles := make([]*MemFile, 0) + for _, file := range decodedMessage.Package.Files { + memFiles = append(memFiles, &MemFile{ + Name: file.Name, + Body: file.Body, + }) + } + + return MsgRun{ + Caller: decodedMessage.Caller.String(), + Send: decodedMessage.Send.String(), + Package: &MemPackage{ + Name: decodedMessage.Package.Name, + Path: decodedMessage.Package.Path, + Files: memFiles, + }, + } +} + +func cast[T any](input any) (*T, error) { + encoded, err := json.Marshal(input) + if err != nil { + return nil, err + } + + var data T + if err := json.Unmarshal(encoded, &data); err != nil { + return nil, err + } + + return &data, nil +} diff --git a/serve/graph/resolvers/block.resolvers.go b/serve/graph/resolvers/block.resolvers.go new file mode 100644 index 00000000..562ce1ea --- /dev/null +++ b/serve/graph/resolvers/block.resolvers.go @@ -0,0 +1,36 @@ +package resolvers + +import ( + "time" + + "github.com/gnolang/tx-indexer/serve/graph/model" +) + +// The resolver for handling the block model. +type BlockResolver struct { + block *model.Block +} + +func NewBlockResolver(block *model.Block) *BlockResolver { + return &BlockResolver{block: block} +} + +func (r *BlockResolver) GetBlock() *model.Block { + return r.block +} + +func (r *BlockResolver) FilteredBy(filter model.BlockFilter) bool { + if r.block == nil { + return false + } + + return r.filteredByBlockTime(filter.FromTime, filter.ToTime) +} + +func (r *BlockResolver) filteredByBlockTime(filterFromTime, filterToTime *time.Time) bool { + fromTime := deref(filterFromTime) + toTime := deref(filterToTime) + blockTime := r.block.Time() + + return (blockTime.After(fromTime) || blockTime.Equal(fromTime)) && (toTime.IsZero() || blockTime.Before(toTime)) +} diff --git a/serve/graph/resolvers/query.resolvers.go b/serve/graph/resolvers/query.resolvers.go index c534e058..3a490964 100644 --- a/serve/graph/resolvers/query.resolvers.go +++ b/serve/graph/resolvers/query.resolvers.go @@ -26,10 +26,10 @@ func (r *queryResolver) Transactions(ctx context.Context, filter model.Transacti it, err := r. store. TxIterator( - filter.GetFromBlockHeight(), - filter.GetToBlockHeight(), - filter.GetFromIndex(), - filter.GetToIndex(), + uint64(deref(filter.FromBlockHeight)), + uint64(deref(filter.ToBlockHeight)), + uint32(deref(filter.FromIndex)), + uint32(deref(filter.ToIndex)), ) if err != nil { return nil, gqlerror.Wrap(err) @@ -59,11 +59,11 @@ func (r *queryResolver) Transactions(ctx context.Context, filter model.Transacti return out, nil } - transaction := model.NewTransaction(t) - if !filter.FilterBy(transaction) { + transactionResolver := NewTransactionResolver(model.NewTransaction(t)) + if !transactionResolver.FilteredBy(filter) { continue } - out = append(out, transaction) + out = append(out, transactionResolver.GetTransaction()) i++ } } @@ -74,8 +74,8 @@ func (r *queryResolver) Blocks(ctx context.Context, filter model.BlockFilter) ([ it, err := r. store. BlockIterator( - filter.GetFromHeight(), - filter.GetToHeight(), + uint64(deref(filter.FromHeight)), + uint64(deref(filter.ToHeight)), ) if err != nil { return nil, gqlerror.Wrap(err) @@ -106,11 +106,12 @@ func (r *queryResolver) Blocks(ctx context.Context, filter model.BlockFilter) ([ return out, nil } - if !filter.FilterBy(b) { + blockResolver := NewBlockResolver(model.NewBlock(b)) + if !blockResolver.FilteredBy(filter) { continue } - out = append(out, model.NewBlock(b)) + out = append(out, blockResolver.GetBlock()) i++ } } diff --git a/serve/graph/resolvers/resolver.go b/serve/graph/resolvers/resolver.go index b537ff84..56dc91c5 100644 --- a/serve/graph/resolvers/resolver.go +++ b/serve/graph/resolvers/resolver.go @@ -7,6 +7,7 @@ import ( "fmt" "github.com/99designs/gqlgen/graphql" + "github.com/gnolang/tx-indexer/events" "github.com/gnolang/tx-indexer/storage" "github.com/gnolang/tx-indexer/types" @@ -18,7 +19,6 @@ import ( const maxElementsPerQuery = 10000 -// Deref dereferences a pointer variable. func deref[T any](v *T) T { if v == nil { var zero T @@ -29,11 +29,6 @@ func deref[T any](v *T) T { return *v } -type Resolver struct { - store storage.Storage - manager *events.Manager -} - func handleChannel[T any]( ctx context.Context, m *events.Manager, @@ -72,6 +67,11 @@ func handleChannel[T any]( return ch } +type Resolver struct { + store storage.Storage + manager *events.Manager +} + func NewResolver(s storage.Storage, m *events.Manager) *Resolver { return &Resolver{store: s, manager: m} } diff --git a/serve/graph/resolvers/subscription.resolvers.go b/serve/graph/resolvers/subscription.resolvers.go index ef5c9801..2505a1f0 100644 --- a/serve/graph/resolvers/subscription.resolvers.go +++ b/serve/graph/resolvers/subscription.resolvers.go @@ -16,9 +16,9 @@ import ( func (r *subscriptionResolver) Transactions(ctx context.Context, filter model.TransactionFilter) (<-chan *model.Transaction, error) { return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Transaction) { for _, tx := range nb.Results { - transaction := model.NewTransaction(tx) - if filter.FilterBy(transaction) { - c <- transaction + transactionResolver := NewTransactionResolver(model.NewTransaction(tx)) + if transactionResolver.FilteredBy(filter) { + c <- transactionResolver.GetTransaction() } } }), nil @@ -27,8 +27,9 @@ func (r *subscriptionResolver) Transactions(ctx context.Context, filter model.Tr // Blocks is the resolver for the blocks field. func (r *subscriptionResolver) Blocks(ctx context.Context, filter model.BlockFilter) (<-chan *model.Block, error) { return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Block) { - if filter.FilterBy(nb.Block) { - c <- model.NewBlock(nb.Block) + blockResolver := NewBlockResolver(model.NewBlock(nb.Block)) + if blockResolver.FilteredBy(filter) { + c <- blockResolver.GetBlock() } }), nil } diff --git a/serve/graph/resolvers/transaction.resolvers.go b/serve/graph/resolvers/transaction.resolvers.go new file mode 100644 index 00000000..9d98f84b --- /dev/null +++ b/serve/graph/resolvers/transaction.resolvers.go @@ -0,0 +1,295 @@ +package resolvers + +import ( + "math" + + "github.com/gnolang/tx-indexer/serve/graph/model" +) + +// The resolver for handling the transaction model. +type TransactionResolver struct { + transaction *model.Transaction +} + +func NewTransactionResolver(transaction *model.Transaction) *TransactionResolver { + return &TransactionResolver{ + transaction: transaction, + } +} + +func (r *TransactionResolver) GetTransaction() *model.Transaction { + return r.transaction +} + +func (r *TransactionResolver) FilteredBy(filter model.TransactionFilter) bool { + if !r.filteredByGasUsed(filter.FromGasUsed, filter.ToGasUsed) { + return false + } + + if !r.filteredByGasWanted(filter.FromGasWanted, filter.ToGasWanted) { + return false + } + + if !r.filteredByMemo(filter.Memo) { + return false + } + + if filter.Message != nil { + if !r.filteredByMessageRoute(filter.Message.Route) { + return false + } + + if !r.filteredByMessageType(filter.Message.TypeURL) { + return false + } + + if !r.filteredByMessages(filter.Message) { + return false + } + } + + return true +} + +func (r *TransactionResolver) filteredByGasUsed(filterFromGasUsed, filterToGasUsed *int) bool { + fromGasUsed := deref(filterFromGasUsed) + toGasUsed := deref(filterToGasUsed) + transactionGasUsed := r.transaction.GasUsed() + + if toGasUsed == 0 { + toGasUsed = math.MaxInt + } + + return transactionGasUsed >= fromGasUsed && transactionGasUsed <= toGasUsed +} + +func (r *TransactionResolver) filteredByGasWanted(filterFromGasWanted, filterToGasWanted *int) bool { + fromGasWanted := deref(filterFromGasWanted) + toGasWanted := deref(filterToGasWanted) + transactionGasUsed := r.transaction.GasWanted() + + if toGasWanted == 0 { + toGasWanted = math.MaxInt + } + + return transactionGasUsed >= fromGasWanted && transactionGasUsed <= toGasWanted +} + +func (r *TransactionResolver) filteredByMemo(filterMemo *string) bool { + if filterMemo == nil { + return true + } + + return deref(filterMemo) == r.transaction.Memo() +} + +func (r *TransactionResolver) filteredByMessages(messageInput *model.TransactionMessageInput) bool { + messages := r.transaction.Messages() + for _, message := range messages { + if !r.filteredByTransactionMessage(messageInput, message) { + return false + } + } + + return true +} + +func (r *TransactionResolver) filteredByMessageRoute(messageRoute *model.MessageRoute) bool { + if messageRoute == nil { + return true + } + + messages := r.transaction.Messages() + for _, message := range messages { + if message.Route.String() == messageRoute.String() { + return true + } + } + + return false +} + +func (r *TransactionResolver) filteredByMessageType(messageType *model.MessageType) bool { + if messageType == nil { + return true + } + + messages := r.transaction.Messages() + for _, message := range messages { + if message.TypeURL.String() == messageType.String() { + return true + } + } + + return false +} + +func (r *TransactionResolver) filteredByTransactionMessage(messageInput *model.TransactionMessageInput, tm *model.TransactionMessage) bool { + if messageInput.TypeURL != nil && messageInput.TypeURL.String() != tm.TypeURL.String() { + return false + } + + if messageInput.BankParam == nil && messageInput.VMParam == nil { + return true + } + + switch tm.Route { + case model.MessageRouteBank: + if messageInput.BankParam == nil { + return false + } + case model.MessageRouteVM: + if messageInput.VMParam == nil { + return false + } + } + + switch tm.TypeURL { + case model.MessageTypeSend: + if !checkMessageOfBankMsgSend(messageInput.BankParam, tm.BankMsgSend()) { + return false + } + case model.MessageTypeExec: + if !checkByMessageOfMsgCall(messageInput.VMParam, tm.VMMsgCall()) { + return false + } + case model.MessageTypeAddPackage: + if !checkMessageOfMsgAddPackage(messageInput.VMParam, tm.VMAddPackage()) { + return false + } + case model.MessageTypeRun: + if !checkMessageOfMsgRun(messageInput.VMParam, tm.VMMsgRun()) { + return false + } + } + + return true +} + +func checkMessageOfBankMsgSend(bankMessageInput *model.TransactionBankMessageInput, messageValue model.BankMsgSend) bool { + params := bankMessageInput + if params == nil || params.Send == nil { + return true + } + + if params.Send.Amount != nil && deref(params.Send.Amount) != messageValue.Amount { + return false + } + + if params.Send.FromAddress != nil && deref(params.Send.FromAddress) != messageValue.FromAddress { + return false + } + + if params.Send.ToAddress != nil && deref(params.Send.ToAddress) != messageValue.ToAddress { + return false + } + + return true +} + +func checkByMessageOfMsgCall(vmMessageInput *model.TransactionVMMessageInput, messageValue model.MsgCall) bool { + params := vmMessageInput + if params == nil { + return true + } + + if params.MCall == nil { + return false + } + + if params.MCall.Caller != nil && deref(params.MCall.Caller) != messageValue.Caller { + return false + } + + if params.MCall.Func != nil && deref(params.MCall.Func) != messageValue.Func { + return false + } + + if params.MCall.PkgPath != nil && deref(params.MCall.PkgPath) != messageValue.PkgPath { + return false + } + + if params.MCall.Send != nil && deref(params.MCall.Send) != messageValue.Send { + return false + } + + if params.MCall.Args != nil { + messageArgs := messageValue.Args + if messageArgs == nil { + return false + } + + messageFilterArgs := params.MCall.Args + for index, arg := range messageArgs { + if index < len(messageFilterArgs) { + if arg != "" && messageFilterArgs[index] != arg { + return false + } + } + } + } + + return true +} + +func checkMessageOfMsgAddPackage(vmMessageInput *model.TransactionVMMessageInput, messageValue model.MsgAddPackage) bool { + params := vmMessageInput + if params == nil { + return true + } + + if params.MAddpkg == nil { + return false + } + + if params.MAddpkg.Creator != nil && deref(params.MAddpkg.Creator) != messageValue.Creator { + return false + } + + if params.MAddpkg.Deposit != nil && deref(params.MAddpkg.Deposit) != messageValue.Deposit { + return false + } + + if params.MAddpkg.Package != nil { + if params.MAddpkg.Package.Name != nil && deref(params.MAddpkg.Package.Name) != messageValue.Package.Name { + return false + } + + if params.MAddpkg.Package.Path != nil && deref(params.MAddpkg.Package.Path) != messageValue.Package.Path { + return false + } + } + + return true +} + +func checkMessageOfMsgRun(vmMessageInput *model.TransactionVMMessageInput, messageValue model.MsgRun) bool { + params := vmMessageInput + if params == nil { + return true + } + + if params.MRun == nil { + return false + } + + if params.MRun.Caller != nil && deref(params.MRun.Caller) != messageValue.Caller { + return false + } + + if params.MRun.Send != nil && deref(params.MRun.Send) != messageValue.Send { + return false + } + + if params.MRun.Package != nil { + if deref(params.MRun.Package.Name) != messageValue.Package.Name { + return false + } + + if deref(params.MRun.Package.Path) != messageValue.Package.Path { + return false + } + } + + return true +} From 4a4a5862cc486f1e88056a7264b8470b1b918122 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Tue, 2 Apr 2024 16:38:15 +0900 Subject: [PATCH 10/25] fix: Fix lints --- .../graph/resolvers/transaction.resolvers.go | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/serve/graph/resolvers/transaction.resolvers.go b/serve/graph/resolvers/transaction.resolvers.go index 9d98f84b..115a6140 100644 --- a/serve/graph/resolvers/transaction.resolvers.go +++ b/serve/graph/resolvers/transaction.resolvers.go @@ -124,7 +124,10 @@ func (r *TransactionResolver) filteredByMessageType(messageType *model.MessageTy return false } -func (r *TransactionResolver) filteredByTransactionMessage(messageInput *model.TransactionMessageInput, tm *model.TransactionMessage) bool { +func (r *TransactionResolver) filteredByTransactionMessage( + messageInput *model.TransactionMessageInput, + tm *model.TransactionMessage, +) bool { if messageInput.TypeURL != nil && messageInput.TypeURL.String() != tm.TypeURL.String() { return false } @@ -166,7 +169,10 @@ func (r *TransactionResolver) filteredByTransactionMessage(messageInput *model.T return true } -func checkMessageOfBankMsgSend(bankMessageInput *model.TransactionBankMessageInput, messageValue model.BankMsgSend) bool { +func checkMessageOfBankMsgSend( + bankMessageInput *model.TransactionBankMessageInput, + messageValue model.BankMsgSend, +) bool { params := bankMessageInput if params == nil || params.Send == nil { return true @@ -187,7 +193,10 @@ func checkMessageOfBankMsgSend(bankMessageInput *model.TransactionBankMessageInp return true } -func checkByMessageOfMsgCall(vmMessageInput *model.TransactionVMMessageInput, messageValue model.MsgCall) bool { +func checkByMessageOfMsgCall( + vmMessageInput *model.TransactionVMMessageInput, + messageValue model.MsgCall, +) bool { params := vmMessageInput if params == nil { return true @@ -232,7 +241,10 @@ func checkByMessageOfMsgCall(vmMessageInput *model.TransactionVMMessageInput, me return true } -func checkMessageOfMsgAddPackage(vmMessageInput *model.TransactionVMMessageInput, messageValue model.MsgAddPackage) bool { +func checkMessageOfMsgAddPackage( + vmMessageInput *model.TransactionVMMessageInput, + messageValue model.MsgAddPackage, +) bool { params := vmMessageInput if params == nil { return true From 4db34fb69aeffe651a7f9916c3563936772b9e4c Mon Sep 17 00:00:00 2001 From: jinoosss Date: Tue, 2 Apr 2024 17:35:30 +0900 Subject: [PATCH 11/25] chore: Add graphql comments for docs --- serve/graph/generated/generated.go | 169 +++++++++++++++--- serve/graph/model/models_gen.go | 108 +++++++---- .../schema/filter/transaction_filter.graphql | 77 +++++--- serve/graph/schema/types/transaction.graphql | 92 ++++++++++ 4 files changed, 357 insertions(+), 89 deletions(-) diff --git a/serve/graph/generated/generated.go b/serve/graph/generated/generated.go index b053d85d..2a654fda 100644 --- a/serve/graph/generated/generated.go +++ b/serve/graph/generated/generated.go @@ -748,144 +748,169 @@ input TransactionMessageInput { route: MessageRoute """ - Input parameters required when the message router type is ` + "`" + `bank` + "`" + `. + ` + "`" + `TransactionBankMessageInput` + "`" + ` represents input parameters required when the message router is ` + "`" + `bank` + "`" + `. """ bank_param: TransactionBankMessageInput """ - Input parameters required when the message router type is ` + "`" + `vm` + "`" + `. + ` + "`" + `TransactionVmMessageInput` + "`" + ` represents input parameters required when the message router is ` + "`" + `vm` + "`" + `. """ vm_param: TransactionVmMessageInput } """ -Input parameters required when the message router is ` + "`" + `bank` + "`" + `. +` + "`" + `TransactionBankMessageInput` + "`" + ` represents input parameters required when the message router is ` + "`" + `bank` + "`" + `. """ input TransactionBankMessageInput { """ - Input parameters required when the message type is ` + "`" + `send` + "`" + `. + send represents input parameters required when the message type is ` + "`" + `send` + "`" + `. """ send: BankMsgSendInput } """ -Input parameters required when the message type is ` + "`" + `send` + "`" + `. +` + "`" + `BankMsgSendInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `send` + "`" + `. """ input BankMsgSendInput { """ - Filter by ` + "`" + `from_address` + "`" + `. + the bech32 address of the fund sender. """ from_address: String """ - Filter by ` + "`" + `to_address` + "`" + `. + the bech32 address of the fund receiver. """ to_address: String """ - Filter by ` + "`" + `amount` + "`" + `. + the denomination and amount of fund sent (""). """ amount: String } """ -Input parameters required when the message router is ` + "`" + `vm` + "`" + `. +` + "`" + `TransactionVmMessageInput` + "`" + ` represents input parameters required when the message router is ` + "`" + `vm` + "`" + `. """ input TransactionVmMessageInput { """ - Input parameters required when the message type is ` + "`" + `exec` + "`" + `. + ` + "`" + `MsgCallInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `exec` + "`" + `. """ m_call: MsgCallInput """ - Input parameters required when the message type is ` + "`" + `add_package` + "`" + `. + ` + "`" + `MsgAddPackageInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `add_package` + "`" + `. """ m_addpkg: MsgAddPackageInput """ - Input parameters required when the message type is ` + "`" + `run` + "`" + `. + ` + "`" + `MsgRunInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `run` + "`" + `. """ m_run: MsgRunInput } """ -Input parameters required when the message type is ` + "`" + `exec` + "`" + `. +` + "`" + `MsgCallInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `exec` + "`" + `. """ input MsgCallInput { """ - Filter by ` + "`" + `caller` + "`" + `. + the bech32 address of the caller. """ caller: String """ - Filter by ` + "`" + `send` + "`" + `. + the amount of funds to be deposited to the package, if any (""). """ send: String """ - Filter by ` + "`" + `pkg_path` + "`" + `. + the gno package path. """ pkg_path: String """ - Filter by ` + "`" + `func` + "`" + `. + the function name being invoked. """ func: String """ - Filter by ` + "`" + `args` + "`" + `, Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + ` + "`" + `args` + "`" + ` are the arguments passed to the executed function. + Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. """ args: [String!] } """ -Input parameters required when the message type is ` + "`" + `add_package` + "`" + `. +` + "`" + `MsgAddPackageInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `add_package` + "`" + `. """ input MsgAddPackageInput { """ - Filter by ` + "`" + `creator` + "`" + `. + the package deployer. """ creator: String """ - Filter by ` + "`" + `package` + "`" + `. + the package being deployed. """ package: MemPackageInput """ - Filter by ` + "`" + `deposit` + "`" + `. + the amount of funds to be deposited at deployment, if any (""). """ deposit: String } """ -Input parameters required when the message type is ` + "`" + `run` + "`" + `. +` + "`" + `MsgRunInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `run` + "`" + `. """ input MsgRunInput { """ - Filter by ` + "`" + `caller` + "`" + `. + the bech32 address of the caller. """ caller: String """ - Filter by ` + "`" + `send` + "`" + `. + the amount of funds to be deposited to the package, if any (""). """ send: String """ - Filter by ` + "`" + `package` + "`" + `. + the package being executed. """ package: MemPackageInput } +""" +` + "`" + `MemPackageInput` + "`" + ` represents a package stored in memory. +""" input MemPackageInput { + """ + the name of the package. + """ Name: String + + """ + the gno path of the package. + """ Path: String + + """ + the associated package gno source. + """ Files: [MemFileInput] } +""" +` + "`" + `MemFileInput` + "`" + ` is the metadata information tied to a single gno package / realm file. +""" input MemFileInput { + """ + the name of the source file. + """ Name: String + + """ + the content of the source file. + """ Body: String } `, BuiltIn: false}, @@ -981,19 +1006,50 @@ enum MessageType { } type TransactionMessage { + """ + The type of transaction message. + """ typeUrl: MessageType! + + """ + The route of transaction message. + """ route: MessageRoute! + + """ + MessageValue is the content of the transaction. + The content can be of type ` + "`" + `BankMsgSend` + "`" + ` or ` + "`" + `MsgCall` + "`" + ` or ` + "`" + `MsgAddPackage` + "`" + ` or ` + "`" + `MsgRun` + "`" + `. + """ value: MessageValue! } union MessageValue = BankMsgSend | MsgCall | MsgAddPackage | MsgRun +""" +` + "`" + `BankMsgSend` + "`" + ` is a message with a message router of ` + "`" + `bank` + "`" + ` and a message type of ` + "`" + `send` + "`" + `. +` + "`" + `BankMsgSend` + "`" + ` is the fund transfer tx message. +""" type BankMsgSend { + """ + the bech32 address of the fund sender. + """ from_address: String! + + """ + the bech32 address of the fund receiver. + """ to_address: String! + + """ + the denomination and amount of fund sent (""). + """ amount: String! } +""" +` + "`" + `MsgCall` + "`" + ` is a message with a message router of ` + "`" + `vm` + "`" + ` and a message type of ` + "`" + `exec` + "`" + `. +` + "`" + `MsgCall` + "`" + ` is the method invocation tx message. +""" type MsgCall { caller: String! send: String! @@ -1002,31 +1058,92 @@ type MsgCall { args: [String!] } +""" +` + "`" + `MsgAddPackage` + "`" + ` is a message with a message router of ` + "`" + `vm` + "`" + ` and a message type of ` + "`" + `add_package` + "`" + `. +` + "`" + `MsgAddPackage` + "`" + ` is the package deployment tx message. +""" type MsgAddPackage { + """ + the package deployer. + """ creator: String! + + """ + the package being deployed. + """ package: MemPackage! + + """ + the amount of funds to be deposited at deployment, if any (""). + """ deposit: String! } +""" +` + "`" + `MsgRun` + "`" + ` is a message with a message router of ` + "`" + `vm` + "`" + ` and a message type of ` + "`" + `run` + "`" + `. +` + "`" + `MsgRun is the execute arbitrary Gno code tx message` + "`" + `. +""" type MsgRun { + """ + the bech32 address of the caller. + """ caller: String! + + """ + the amount of funds to be deposited to the package, if any (""). + """ send: String! + + """ + the package being executed. + """ package: MemPackage! } +""" +` + "`" + `MemPackage` + "`" + ` is the metadata information tied to package / realm deployment. +""" type MemPackage { + """ + the name of the package. + """ Name: String! + + """ + the gno path of the package. + """ Path: String! + + """ + the associated package gno source. + """ Files: [MemFile!] } +""" +` + "`" + `MemFile` + "`" + ` is the metadata information tied to a single gno package / realm file +""" type MemFile { + """ + the name of the source file. + """ Name: String! + + """ + the content of the source file. + """ Body: String! } type TxFee { + """ + gas limit + """ gas_wanted: Int! + + """ + gas fee details () + """ gas_fee: Int! } `, BuiltIn: false}, diff --git a/serve/graph/model/models_gen.go b/serve/graph/model/models_gen.go index e753ef18..dccbd24b 100644 --- a/serve/graph/model/models_gen.go +++ b/serve/graph/model/models_gen.go @@ -13,21 +13,26 @@ type MessageValue interface { IsMessageValue() } +// `BankMsgSend` is a message with a message router of `bank` and a message type of `send`. +// `BankMsgSend` is the fund transfer tx message. type BankMsgSend struct { + // the bech32 address of the fund sender. FromAddress string `json:"from_address"` - ToAddress string `json:"to_address"` - Amount string `json:"amount"` + // the bech32 address of the fund receiver. + ToAddress string `json:"to_address"` + // the denomination and amount of fund sent (""). + Amount string `json:"amount"` } func (BankMsgSend) IsMessageValue() {} -// Input parameters required when the message type is `send`. +// `BankMsgSendInput` represents input parameters required when the message type is `send`. type BankMsgSendInput struct { - // Filter by `from_address`. + // the bech32 address of the fund sender. FromAddress *string `json:"from_address,omitempty"` - // Filter by `to_address`. + // the bech32 address of the fund receiver. ToAddress *string `json:"to_address,omitempty"` - // Filter by `amount`. + // the denomination and amount of fund sent (""). Amount *string `json:"amount,omitempty"` } @@ -43,46 +48,67 @@ type BlockFilter struct { ToTime *time.Time `json:"to_time,omitempty"` } +// `MemFile` is the metadata information tied to a single gno package / realm file type MemFile struct { + // the name of the source file. Name string `json:"Name"` + // the content of the source file. Body string `json:"Body"` } +// `MemFileInput` is the metadata information tied to a single gno package / realm file. type MemFileInput struct { + // the name of the source file. Name *string `json:"Name,omitempty"` + // the content of the source file. Body *string `json:"Body,omitempty"` } +// `MemPackage` is the metadata information tied to package / realm deployment. type MemPackage struct { - Name string `json:"Name"` - Path string `json:"Path"` + // the name of the package. + Name string `json:"Name"` + // the gno path of the package. + Path string `json:"Path"` + // the associated package gno source. Files []*MemFile `json:"Files,omitempty"` } +// `MemPackageInput` represents a package stored in memory. type MemPackageInput struct { - Name *string `json:"Name,omitempty"` - Path *string `json:"Path,omitempty"` + // the name of the package. + Name *string `json:"Name,omitempty"` + // the gno path of the package. + Path *string `json:"Path,omitempty"` + // the associated package gno source. Files []*MemFileInput `json:"Files,omitempty"` } +// `MsgAddPackage` is a message with a message router of `vm` and a message type of `add_package`. +// `MsgAddPackage` is the package deployment tx message. type MsgAddPackage struct { - Creator string `json:"creator"` + // the package deployer. + Creator string `json:"creator"` + // the package being deployed. Package *MemPackage `json:"package"` - Deposit string `json:"deposit"` + // the amount of funds to be deposited at deployment, if any (""). + Deposit string `json:"deposit"` } func (MsgAddPackage) IsMessageValue() {} -// Input parameters required when the message type is `add_package`. +// `MsgAddPackageInput` represents input parameters required when the message type is `add_package`. type MsgAddPackageInput struct { - // Filter by `creator`. + // the package deployer. Creator *string `json:"creator,omitempty"` - // Filter by `package`. + // the package being deployed. Package *MemPackageInput `json:"package,omitempty"` - // Filter by `deposit`. + // the amount of funds to be deposited at deployment, if any (""). Deposit *string `json:"deposit,omitempty"` } +// `MsgCall` is a message with a message router of `vm` and a message type of `exec`. +// `MsgCall` is the method invocation tx message. type MsgCall struct { Caller string `json:"caller"` Send string `json:"send"` @@ -93,35 +119,41 @@ type MsgCall struct { func (MsgCall) IsMessageValue() {} -// Input parameters required when the message type is `exec`. +// `MsgCallInput` represents input parameters required when the message type is `exec`. type MsgCallInput struct { - // Filter by `caller`. + // the bech32 address of the caller. Caller *string `json:"caller,omitempty"` - // Filter by `send`. + // the amount of funds to be deposited to the package, if any (""). Send *string `json:"send,omitempty"` - // Filter by `pkg_path`. + // the gno package path. PkgPath *string `json:"pkg_path,omitempty"` - // Filter by `func`. + // the function name being invoked. Func *string `json:"func,omitempty"` - // Filter by `args`, Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + // `args` are the arguments passed to the executed function. + // Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. Args []string `json:"args,omitempty"` } +// `MsgRun` is a message with a message router of `vm` and a message type of `run`. +// `MsgRun is the execute arbitrary Gno code tx message`. type MsgRun struct { - Caller string `json:"caller"` - Send string `json:"send"` + // the bech32 address of the caller. + Caller string `json:"caller"` + // the amount of funds to be deposited to the package, if any (""). + Send string `json:"send"` + // the package being executed. Package *MemPackage `json:"package"` } func (MsgRun) IsMessageValue() {} -// Input parameters required when the message type is `run`. +// `MsgRunInput` represents input parameters required when the message type is `run`. type MsgRunInput struct { - // Filter by `caller`. + // the bech32 address of the caller. Caller *string `json:"caller,omitempty"` - // Filter by `send`. + // the amount of funds to be deposited to the package, if any (""). Send *string `json:"send,omitempty"` - // Filter by `package`. + // the package being executed. Package *MemPackageInput `json:"package,omitempty"` } @@ -134,9 +166,9 @@ type Query struct { type Subscription struct { } -// Input parameters required when the message router is `bank`. +// `TransactionBankMessageInput` represents input parameters required when the message router is `bank`. type TransactionBankMessageInput struct { - // Input parameters required when the message type is `send`. + // send represents input parameters required when the message type is `send`. Send *BankMsgSendInput `json:"send,omitempty"` } @@ -172,25 +204,27 @@ type TransactionMessageInput struct { TypeURL *MessageType `json:"type_url,omitempty"` // The route of transaction message. Route *MessageRoute `json:"route,omitempty"` - // Input parameters required when the message router type is `bank`. + // `TransactionBankMessageInput` represents input parameters required when the message router is `bank`. BankParam *TransactionBankMessageInput `json:"bank_param,omitempty"` - // Input parameters required when the message router type is `vm`. + // `TransactionVmMessageInput` represents input parameters required when the message router is `vm`. VMParam *TransactionVMMessageInput `json:"vm_param,omitempty"` } -// Input parameters required when the message router is `vm`. +// `TransactionVmMessageInput` represents input parameters required when the message router is `vm`. type TransactionVMMessageInput struct { - // Input parameters required when the message type is `exec`. + // `MsgCallInput` represents input parameters required when the message type is `exec`. MCall *MsgCallInput `json:"m_call,omitempty"` - // Input parameters required when the message type is `add_package`. + // `MsgAddPackageInput` represents input parameters required when the message type is `add_package`. MAddpkg *MsgAddPackageInput `json:"m_addpkg,omitempty"` - // Input parameters required when the message type is `run`. + // `MsgRunInput` represents input parameters required when the message type is `run`. MRun *MsgRunInput `json:"m_run,omitempty"` } type TxFee struct { + // gas limit GasWanted int `json:"gas_wanted"` - GasFee int `json:"gas_fee"` + // gas fee details () + GasFee int `json:"gas_fee"` } type MessageRoute string diff --git a/serve/graph/schema/filter/transaction_filter.graphql b/serve/graph/schema/filter/transaction_filter.graphql index 1711ca51..e704fda3 100644 --- a/serve/graph/schema/filter/transaction_filter.graphql +++ b/serve/graph/schema/filter/transaction_filter.graphql @@ -73,143 +73,168 @@ input TransactionMessageInput { route: MessageRoute """ - Input parameters required when the message router type is `bank`. + `TransactionBankMessageInput` represents input parameters required when the message router is `bank`. """ bank_param: TransactionBankMessageInput """ - Input parameters required when the message router type is `vm`. + `TransactionVmMessageInput` represents input parameters required when the message router is `vm`. """ vm_param: TransactionVmMessageInput } """ -Input parameters required when the message router is `bank`. +`TransactionBankMessageInput` represents input parameters required when the message router is `bank`. """ input TransactionBankMessageInput { """ - Input parameters required when the message type is `send`. + send represents input parameters required when the message type is `send`. """ send: BankMsgSendInput } """ -Input parameters required when the message type is `send`. +`BankMsgSendInput` represents input parameters required when the message type is `send`. """ input BankMsgSendInput { """ - Filter by `from_address`. + the bech32 address of the fund sender. """ from_address: String """ - Filter by `to_address`. + the bech32 address of the fund receiver. """ to_address: String """ - Filter by `amount`. + the denomination and amount of fund sent (""). """ amount: String } """ -Input parameters required when the message router is `vm`. +`TransactionVmMessageInput` represents input parameters required when the message router is `vm`. """ input TransactionVmMessageInput { """ - Input parameters required when the message type is `exec`. + `MsgCallInput` represents input parameters required when the message type is `exec`. """ m_call: MsgCallInput """ - Input parameters required when the message type is `add_package`. + `MsgAddPackageInput` represents input parameters required when the message type is `add_package`. """ m_addpkg: MsgAddPackageInput """ - Input parameters required when the message type is `run`. + `MsgRunInput` represents input parameters required when the message type is `run`. """ m_run: MsgRunInput } """ -Input parameters required when the message type is `exec`. +`MsgCallInput` represents input parameters required when the message type is `exec`. """ input MsgCallInput { """ - Filter by `caller`. + the bech32 address of the caller. """ caller: String """ - Filter by `send`. + the amount of funds to be deposited to the package, if any (""). """ send: String """ - Filter by `pkg_path`. + the gno package path. """ pkg_path: String """ - Filter by `func`. + the function name being invoked. """ func: String """ - Filter by `args`, Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + `args` are the arguments passed to the executed function. + Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. """ args: [String!] } """ -Input parameters required when the message type is `add_package`. +`MsgAddPackageInput` represents input parameters required when the message type is `add_package`. """ input MsgAddPackageInput { """ - Filter by `creator`. + the package deployer. """ creator: String """ - Filter by `package`. + the package being deployed. """ package: MemPackageInput """ - Filter by `deposit`. + the amount of funds to be deposited at deployment, if any (""). """ deposit: String } """ -Input parameters required when the message type is `run`. +`MsgRunInput` represents input parameters required when the message type is `run`. """ input MsgRunInput { """ - Filter by `caller`. + the bech32 address of the caller. """ caller: String """ - Filter by `send`. + the amount of funds to be deposited to the package, if any (""). """ send: String """ - Filter by `package`. + the package being executed. """ package: MemPackageInput } +""" +`MemPackageInput` represents a package stored in memory. +""" input MemPackageInput { + """ + the name of the package. + """ Name: String + + """ + the gno path of the package. + """ Path: String + + """ + the associated package gno source. + """ Files: [MemFileInput] } +""" +`MemFileInput` is the metadata information tied to a single gno package / realm file. +""" input MemFileInput { + """ + the name of the source file. + """ Name: String + + """ + the content of the source file. + """ Body: String } diff --git a/serve/graph/schema/types/transaction.graphql b/serve/graph/schema/types/transaction.graphql index 4e10c095..07975bff 100644 --- a/serve/graph/schema/types/transaction.graphql +++ b/serve/graph/schema/types/transaction.graphql @@ -56,19 +56,50 @@ enum MessageType { } type TransactionMessage { + """ + The type of transaction message. + """ typeUrl: MessageType! + + """ + The route of transaction message. + """ route: MessageRoute! + + """ + MessageValue is the content of the transaction. + The content can be of type `BankMsgSend` or `MsgCall` or `MsgAddPackage` or `MsgRun`. + """ value: MessageValue! } union MessageValue = BankMsgSend | MsgCall | MsgAddPackage | MsgRun +""" +`BankMsgSend` is a message with a message router of `bank` and a message type of `send`. +`BankMsgSend` is the fund transfer tx message. +""" type BankMsgSend { + """ + the bech32 address of the fund sender. + """ from_address: String! + + """ + the bech32 address of the fund receiver. + """ to_address: String! + + """ + the denomination and amount of fund sent (""). + """ amount: String! } +""" +`MsgCall` is a message with a message router of `vm` and a message type of `exec`. +`MsgCall` is the method invocation tx message. +""" type MsgCall { caller: String! send: String! @@ -77,30 +108,91 @@ type MsgCall { args: [String!] } +""" +`MsgAddPackage` is a message with a message router of `vm` and a message type of `add_package`. +`MsgAddPackage` is the package deployment tx message. +""" type MsgAddPackage { + """ + the package deployer. + """ creator: String! + + """ + the package being deployed. + """ package: MemPackage! + + """ + the amount of funds to be deposited at deployment, if any (""). + """ deposit: String! } +""" +`MsgRun` is a message with a message router of `vm` and a message type of `run`. +`MsgRun is the execute arbitrary Gno code tx message`. +""" type MsgRun { + """ + the bech32 address of the caller. + """ caller: String! + + """ + the amount of funds to be deposited to the package, if any (""). + """ send: String! + + """ + the package being executed. + """ package: MemPackage! } +""" +`MemPackage` is the metadata information tied to package / realm deployment. +""" type MemPackage { + """ + the name of the package. + """ Name: String! + + """ + the gno path of the package. + """ Path: String! + + """ + the associated package gno source. + """ Files: [MemFile!] } +""" +`MemFile` is the metadata information tied to a single gno package / realm file +""" type MemFile { + """ + the name of the source file. + """ Name: String! + + """ + the content of the source file. + """ Body: String! } type TxFee { + """ + gas limit + """ gas_wanted: Int! + + """ + gas fee details () + """ gas_fee: Int! } From b11d85cedfc1cde3969721b64705e86283bcc34f Mon Sep 17 00:00:00 2001 From: jinoosss Date: Wed, 3 Apr 2024 10:35:58 +0900 Subject: [PATCH 12/25] refactor: Change a graph structure --- gqlgen.yml | 8 +- .../graph/{resolvers => }/block.resolvers.go | 2 +- serve/graph/{generated => }/generated.go | 580 +----------------- .../graph/{resolvers => }/query.resolvers.go | 5 +- serve/graph/{resolvers => }/resolver.go | 2 +- serve/graph/setup.go | 6 +- .../{resolvers => }/subscription.resolvers.go | 5 +- .../{resolvers => }/transaction.resolvers.go | 2 +- 8 files changed, 33 insertions(+), 577 deletions(-) rename serve/graph/{resolvers => }/block.resolvers.go (97%) rename serve/graph/{generated => }/generated.go (93%) rename serve/graph/{resolvers => }/query.resolvers.go (95%) rename serve/graph/{resolvers => }/resolver.go (98%) rename serve/graph/{resolvers => }/subscription.resolvers.go (88%) rename serve/graph/{resolvers => }/transaction.resolvers.go (99%) diff --git a/gqlgen.yml b/gqlgen.yml index 1bf62a60..af53e13f 100644 --- a/gqlgen.yml +++ b/gqlgen.yml @@ -5,8 +5,8 @@ schema: # Where should the generated server code go? exec: - filename: serve/graph/generated/generated.go - package: generated + filename: serve/graph/generated.go + package: graph # Where should any generated models go? model: @@ -16,8 +16,8 @@ model: # Where should the resolver implementations go? resolver: layout: follow-schema - dir: serve/graph/resolvers - package: resolvers + dir: serve/graph + package: graph filename_template: "{name}.resolvers.go" # Optional: turn on to not generate template comments above resolvers # omit_template_comment: false diff --git a/serve/graph/resolvers/block.resolvers.go b/serve/graph/block.resolvers.go similarity index 97% rename from serve/graph/resolvers/block.resolvers.go rename to serve/graph/block.resolvers.go index 562ce1ea..e1237921 100644 --- a/serve/graph/resolvers/block.resolvers.go +++ b/serve/graph/block.resolvers.go @@ -1,4 +1,4 @@ -package resolvers +package graph import ( "time" diff --git a/serve/graph/generated/generated.go b/serve/graph/generated.go similarity index 93% rename from serve/graph/generated/generated.go rename to serve/graph/generated.go index 2a654fda..e11c50fc 100644 --- a/serve/graph/generated/generated.go +++ b/serve/graph/generated.go @@ -1,10 +1,11 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package generated +package graph import ( "bytes" "context" + "embed" "errors" "fmt" "io" @@ -587,566 +588,25 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } +//go:embed "schema/query.graphql" "schema/schema.graphql" "schema/subscription.graphql" "schema/filter/block_filter.graphql" "schema/filter/transaction_filter.graphql" "schema/types/block.graphql" "schema/types/transaction.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + var sources = []*ast.Source{ - {Name: "../schema/query.graphql", Input: `""" -Root Query type to fetch data about Blocks and Transactions based on filters or retrieve the latest block height. -""" -type Query { - """ - Retrieves a list of Transactions that match the given filter criteria. If the result is incomplete due to errors, both partial results and errors are returned. - """ - transactions(filter: TransactionFilter!): [Transaction!] - - """ - Fetches Blocks matching the specified filter criteria. Incomplete results due to errors return both the partial Blocks and the associated errors. - """ - blocks(filter: BlockFilter!): [Block!] - - """ - Returns the height of the most recently processed Block by the blockchain indexer, indicating the current length of the blockchain. - """ - latestBlockHeight: Int! -} -`, BuiltIn: false}, - {Name: "../schema/schema.graphql", Input: `schema { - query: Query - subscription: Subscription -} - -""" -Field representing a point on time. It is following the RFC3339Nano format ("2006-01-02T15:04:05.999999999Z07:00") -""" -scalar Time -`, BuiltIn: false}, - {Name: "../schema/subscription.graphql", Input: `""" -Subscriptions provide a way for clients to receive real-time updates about Transactions and Blocks based on specified filter criteria. -Subscribers will only receive updates for events occurring after the subscription is established. -""" -type Subscription { - """ - Subscribes to real-time updates of Transactions that match the provided filter criteria. - This subscription starts immediately and only includes Transactions added to the blockchain after the subscription is active. - - This is useful for applications needing to track Transactions in real-time, such as wallets tracking incoming transactions - or analytics platforms monitoring blockchain activity. - - Returns: - - Transaction: Each received update is a Transaction object that matches the filter criteria. - """ - transactions(filter: TransactionFilter!): Transaction! - - """ - Subscribes to real-time updates of Blocks that match the provided filter criteria. Similar to the Transactions subscription, - this subscription is active immediately upon creation and only includes Blocks added after the subscription begins. - - This subscription is ideal for services that need to be notified of new Blocks for processing or analysis, such as block explorers, - data aggregators, or security monitoring tools. - - Returns: - - Block: Each update consists of a Block object that satisfies the filter criteria, allowing subscribers to process or analyze new Blocks in real time. - """ - blocks(filter: BlockFilter!): Block! -} -`, BuiltIn: false}, - {Name: "../schema/filter/block_filter.graphql", Input: `""" -Filters for querying Blocks within specified criteria related to their attributes. -""" -input BlockFilter { - """ - Minimum block height from which to start fetching Blocks, inclusive. If unspecified, there is no lower bound. - """ - from_height: Int - - """ - Maximum block height up to which Blocks should be fetched, exclusive. If unspecified, there is no upper bound. - """ - to_height: Int - - """ - Minimum timestamp from which to start fetching Blocks, inclusive. Blocks created at or after this time will be included. - """ - from_time: Time - - """ - Maximum timestamp up to which to fetch Blocks, exclusive. Only Blocks created before this time are included. - """ - to_time: Time -} -`, BuiltIn: false}, - {Name: "../schema/filter/transaction_filter.graphql", Input: `""" -Filters for querying Transactions within specified criteria related to their execution and placement within Blocks. -""" -input TransactionFilter { - """ - Minimum block height from which to start fetching Transactions, inclusive. Aids in scoping the search to recent Transactions. - """ - from_block_height: Int - - """ - Maximum block height up to which Transactions should be fetched, exclusive. Helps in limiting the search to older Transactions. - """ - to_block_height: Int - - """ - Minimum Transaction index from which to start fetching, inclusive. Facilitates ordering in Transaction queries. - """ - from_index: Int - - """ - Maximum Transaction index up to which to fetch, exclusive. Ensures a limit on the ordering range for Transaction queries. - """ - to_index: Int - - """ - Minimum ` + "`" + `gas_wanted` + "`" + ` value to filter Transactions by, inclusive. Filters Transactions based on the minimum computational effort declared. - """ - from_gas_wanted: Int - - """ - Maximum ` + "`" + `gas_wanted` + "`" + ` value for filtering Transactions, exclusive. Limits Transactions based on the declared computational effort. - """ - to_gas_wanted: Int - - """ - Minimum ` + "`" + `gas_used` + "`" + ` value to filter Transactions by, inclusive. Selects Transactions based on the minimum computational effort actually used. - """ - from_gas_used: Int - - """ - Maximum ` + "`" + `gas_used` + "`" + ` value for filtering Transactions, exclusive. Refines selection based on the computational effort actually consumed. - """ - to_gas_used: Int - - """ - Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. - """ - hash: String - - """ - Transaction's message to filter Transactions. - """ - message: TransactionMessageInput - - """ - ` + "`" + `memo` + "`" + ` value to filter Transaction's memo. - """ - memo: String -} - -""" -Input for filters by transaction message. -""" -input TransactionMessageInput { - """ - The type of transaction message. - """ - type_url: MessageType - - """ - The route of transaction message. - """ - route: MessageRoute - - """ - ` + "`" + `TransactionBankMessageInput` + "`" + ` represents input parameters required when the message router is ` + "`" + `bank` + "`" + `. - """ - bank_param: TransactionBankMessageInput - - """ - ` + "`" + `TransactionVmMessageInput` + "`" + ` represents input parameters required when the message router is ` + "`" + `vm` + "`" + `. - """ - vm_param: TransactionVmMessageInput -} - -""" -` + "`" + `TransactionBankMessageInput` + "`" + ` represents input parameters required when the message router is ` + "`" + `bank` + "`" + `. -""" -input TransactionBankMessageInput { - """ - send represents input parameters required when the message type is ` + "`" + `send` + "`" + `. - """ - send: BankMsgSendInput -} - -""" -` + "`" + `BankMsgSendInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `send` + "`" + `. -""" -input BankMsgSendInput { - """ - the bech32 address of the fund sender. - """ - from_address: String - - """ - the bech32 address of the fund receiver. - """ - to_address: String - - """ - the denomination and amount of fund sent (""). - """ - amount: String -} - -""" -` + "`" + `TransactionVmMessageInput` + "`" + ` represents input parameters required when the message router is ` + "`" + `vm` + "`" + `. -""" -input TransactionVmMessageInput { - """ - ` + "`" + `MsgCallInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `exec` + "`" + `. - """ - m_call: MsgCallInput - - """ - ` + "`" + `MsgAddPackageInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `add_package` + "`" + `. - """ - m_addpkg: MsgAddPackageInput - - """ - ` + "`" + `MsgRunInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `run` + "`" + `. - """ - m_run: MsgRunInput -} - -""" -` + "`" + `MsgCallInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `exec` + "`" + `. -""" -input MsgCallInput { - """ - the bech32 address of the caller. - """ - caller: String - - """ - the amount of funds to be deposited to the package, if any (""). - """ - send: String - - """ - the gno package path. - """ - pkg_path: String - - """ - the function name being invoked. - """ - func: String - - """ - ` + "`" + `args` + "`" + ` are the arguments passed to the executed function. - Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. - """ - args: [String!] -} - -""" -` + "`" + `MsgAddPackageInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `add_package` + "`" + `. -""" -input MsgAddPackageInput { - """ - the package deployer. - """ - creator: String - - """ - the package being deployed. - """ - package: MemPackageInput - - """ - the amount of funds to be deposited at deployment, if any (""). - """ - deposit: String -} - -""" -` + "`" + `MsgRunInput` + "`" + ` represents input parameters required when the message type is ` + "`" + `run` + "`" + `. -""" -input MsgRunInput { - """ - the bech32 address of the caller. - """ - caller: String - - """ - the amount of funds to be deposited to the package, if any (""). - """ - send: String - - """ - the package being executed. - """ - package: MemPackageInput -} - -""" -` + "`" + `MemPackageInput` + "`" + ` represents a package stored in memory. -""" -input MemPackageInput { - """ - the name of the package. - """ - Name: String - - """ - the gno path of the package. - """ - Path: String - - """ - the associated package gno source. - """ - Files: [MemFileInput] -} - -""" -` + "`" + `MemFileInput` + "`" + ` is the metadata information tied to a single gno package / realm file. -""" -input MemFileInput { - """ - the name of the source file. - """ - Name: String - - """ - the content of the source file. - """ - Body: String -} -`, BuiltIn: false}, - {Name: "../schema/types/block.graphql", Input: `""" -Represents a blockchain block with various attributes detailing its creation and content. -""" -type Block { - """ - A unique identifier for the Block determined by its position in the blockchain. - This integer is strictly increasing with each new Block. - """ - height: Int! - - """ - The software version of the node that created this Block, indicating the specific - implementation and versioning of the blockchain protocol used. - """ - version: String! - - """ - An identifier for the specific blockchain network this Block belongs to. Helps in - distinguishing between different networks like mainnet, testnet, etc. - """ - chain_id: String! - - """ - The timestamp at which this Block was proposed and finalized in the blockchain. Represented in UTC. - """ - time: Time! - - """ - Encoded data representing the blockchain address of the proposer who submitted this Block. - It is raw and requires decoding to be human-readable. - """ - proposer_address_raw: String! -} -`, BuiltIn: false}, - {Name: "../schema/types/transaction.graphql", Input: `""" -Defines a transaction within a block, detailing its execution specifics and content. -""" -type Transaction { - """ - A sequential index representing the order of this Transaction within its Block. Unique within the context of its Block. - """ - index: Int! - - """ - Hash from Transaction content in base64 encoding. - """ - hash: String! - - """ - The height of the Block in which this Transaction is included. Links the Transaction to its containing Block. - """ - block_height: Int! - - """ - The declared amount of computational effort the sender is willing to pay for executing this Transaction. - """ - gas_wanted: Int! - - """ - The actual amount of computational effort consumed to execute this Transaction. It could be less or equal to ` + "`" + `gas_wanted` + "`" + `. - """ - gas_used: Int! - - """ - The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. - """ - content_raw: String! - - """ - The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. - """ - messages: [TransactionMessage]! - - """ - The memo of the Transaction. - """ - memo: String! -} - -enum MessageRoute { - vm - bank -} - -enum MessageType { - send - exec - add_package - run -} - -type TransactionMessage { - """ - The type of transaction message. - """ - typeUrl: MessageType! - - """ - The route of transaction message. - """ - route: MessageRoute! - - """ - MessageValue is the content of the transaction. - The content can be of type ` + "`" + `BankMsgSend` + "`" + ` or ` + "`" + `MsgCall` + "`" + ` or ` + "`" + `MsgAddPackage` + "`" + ` or ` + "`" + `MsgRun` + "`" + `. - """ - value: MessageValue! -} - -union MessageValue = BankMsgSend | MsgCall | MsgAddPackage | MsgRun - -""" -` + "`" + `BankMsgSend` + "`" + ` is a message with a message router of ` + "`" + `bank` + "`" + ` and a message type of ` + "`" + `send` + "`" + `. -` + "`" + `BankMsgSend` + "`" + ` is the fund transfer tx message. -""" -type BankMsgSend { - """ - the bech32 address of the fund sender. - """ - from_address: String! - - """ - the bech32 address of the fund receiver. - """ - to_address: String! - - """ - the denomination and amount of fund sent (""). - """ - amount: String! -} - -""" -` + "`" + `MsgCall` + "`" + ` is a message with a message router of ` + "`" + `vm` + "`" + ` and a message type of ` + "`" + `exec` + "`" + `. -` + "`" + `MsgCall` + "`" + ` is the method invocation tx message. -""" -type MsgCall { - caller: String! - send: String! - pkg_path: String! - func: String! - args: [String!] -} - -""" -` + "`" + `MsgAddPackage` + "`" + ` is a message with a message router of ` + "`" + `vm` + "`" + ` and a message type of ` + "`" + `add_package` + "`" + `. -` + "`" + `MsgAddPackage` + "`" + ` is the package deployment tx message. -""" -type MsgAddPackage { - """ - the package deployer. - """ - creator: String! - - """ - the package being deployed. - """ - package: MemPackage! - - """ - the amount of funds to be deposited at deployment, if any (""). - """ - deposit: String! -} - -""" -` + "`" + `MsgRun` + "`" + ` is a message with a message router of ` + "`" + `vm` + "`" + ` and a message type of ` + "`" + `run` + "`" + `. -` + "`" + `MsgRun is the execute arbitrary Gno code tx message` + "`" + `. -""" -type MsgRun { - """ - the bech32 address of the caller. - """ - caller: String! - - """ - the amount of funds to be deposited to the package, if any (""). - """ - send: String! - - """ - the package being executed. - """ - package: MemPackage! -} - -""" -` + "`" + `MemPackage` + "`" + ` is the metadata information tied to package / realm deployment. -""" -type MemPackage { - """ - the name of the package. - """ - Name: String! - - """ - the gno path of the package. - """ - Path: String! - - """ - the associated package gno source. - """ - Files: [MemFile!] -} - -""" -` + "`" + `MemFile` + "`" + ` is the metadata information tied to a single gno package / realm file -""" -type MemFile { - """ - the name of the source file. - """ - Name: String! - - """ - the content of the source file. - """ - Body: String! -} - -type TxFee { - """ - gas limit - """ - gas_wanted: Int! - - """ - gas fee details () - """ - gas_fee: Int! -} -`, BuiltIn: false}, + {Name: "schema/query.graphql", Input: sourceData("schema/query.graphql"), BuiltIn: false}, + {Name: "schema/schema.graphql", Input: sourceData("schema/schema.graphql"), BuiltIn: false}, + {Name: "schema/subscription.graphql", Input: sourceData("schema/subscription.graphql"), BuiltIn: false}, + {Name: "schema/filter/block_filter.graphql", Input: sourceData("schema/filter/block_filter.graphql"), BuiltIn: false}, + {Name: "schema/filter/transaction_filter.graphql", Input: sourceData("schema/filter/transaction_filter.graphql"), BuiltIn: false}, + {Name: "schema/types/block.graphql", Input: sourceData("schema/types/block.graphql"), BuiltIn: false}, + {Name: "schema/types/transaction.graphql", Input: sourceData("schema/types/transaction.graphql"), BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) diff --git a/serve/graph/resolvers/query.resolvers.go b/serve/graph/query.resolvers.go similarity index 95% rename from serve/graph/resolvers/query.resolvers.go rename to serve/graph/query.resolvers.go index 3a490964..596c3a20 100644 --- a/serve/graph/resolvers/query.resolvers.go +++ b/serve/graph/query.resolvers.go @@ -1,4 +1,4 @@ -package resolvers +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. @@ -8,7 +8,6 @@ import ( "context" "github.com/99designs/gqlgen/graphql" - "github.com/gnolang/tx-indexer/serve/graph/generated" "github.com/gnolang/tx-indexer/serve/graph/model" "github.com/vektah/gqlparser/v2/gqlerror" ) @@ -124,6 +123,6 @@ func (r *queryResolver) LatestBlockHeight(ctx context.Context) (int, error) { } // Query returns generated.QueryResolver implementation. -func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } +func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } diff --git a/serve/graph/resolvers/resolver.go b/serve/graph/resolver.go similarity index 98% rename from serve/graph/resolvers/resolver.go rename to serve/graph/resolver.go index 56dc91c5..8241fc3b 100644 --- a/serve/graph/resolvers/resolver.go +++ b/serve/graph/resolver.go @@ -1,6 +1,6 @@ //go:generate go run github.com/99designs/gqlgen generate -package resolvers +package graph import ( "context" diff --git a/serve/graph/setup.go b/serve/graph/setup.go index 79307442..682155e6 100644 --- a/serve/graph/setup.go +++ b/serve/graph/setup.go @@ -5,15 +5,13 @@ import ( "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" "github.com/gnolang/tx-indexer/events" - "github.com/gnolang/tx-indexer/serve/graph/generated" - "github.com/gnolang/tx-indexer/serve/graph/resolvers" "github.com/gnolang/tx-indexer/storage" "github.com/go-chi/chi/v5" ) func Setup(s storage.Storage, manager *events.Manager, m *chi.Mux) *chi.Mux { - srv := handler.NewDefaultServer(generated.NewExecutableSchema( - generated.Config{Resolvers: resolvers.NewResolver(s, manager)}, + srv := handler.NewDefaultServer(NewExecutableSchema( + Config{Resolvers: NewResolver(s, manager)}, )) srv.AddTransport(&transport.Websocket{}) diff --git a/serve/graph/resolvers/subscription.resolvers.go b/serve/graph/subscription.resolvers.go similarity index 88% rename from serve/graph/resolvers/subscription.resolvers.go rename to serve/graph/subscription.resolvers.go index 2505a1f0..8ab88473 100644 --- a/serve/graph/resolvers/subscription.resolvers.go +++ b/serve/graph/subscription.resolvers.go @@ -1,4 +1,4 @@ -package resolvers +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. @@ -7,7 +7,6 @@ package resolvers import ( "context" - "github.com/gnolang/tx-indexer/serve/graph/generated" "github.com/gnolang/tx-indexer/serve/graph/model" "github.com/gnolang/tx-indexer/types" ) @@ -35,6 +34,6 @@ func (r *subscriptionResolver) Blocks(ctx context.Context, filter model.BlockFil } // Subscription returns generated.SubscriptionResolver implementation. -func (r *Resolver) Subscription() generated.SubscriptionResolver { return &subscriptionResolver{r} } +func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } type subscriptionResolver struct{ *Resolver } diff --git a/serve/graph/resolvers/transaction.resolvers.go b/serve/graph/transaction.resolvers.go similarity index 99% rename from serve/graph/resolvers/transaction.resolvers.go rename to serve/graph/transaction.resolvers.go index 115a6140..f3c1698f 100644 --- a/serve/graph/resolvers/transaction.resolvers.go +++ b/serve/graph/transaction.resolvers.go @@ -1,4 +1,4 @@ -package resolvers +package graph import ( "math" From 0427926c1c358e9e35a3ebd0b52c2bd73269b256 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Thu, 4 Apr 2024 14:16:26 +0900 Subject: [PATCH 13/25] chore: Add descriptions for docs --- serve/graph/model/models_gen.go | 38 +++++++++++++++---- serve/graph/query.resolvers.go | 2 +- .../schema/filter/transaction_filter.graphql | 24 ++++++++++-- serve/graph/schema/types/transaction.graphql | 30 +++++++++++++-- serve/graph/subscription.resolvers.go | 2 +- 5 files changed, 80 insertions(+), 16 deletions(-) diff --git a/serve/graph/model/models_gen.go b/serve/graph/model/models_gen.go index dccbd24b..6c65faf4 100644 --- a/serve/graph/model/models_gen.go +++ b/serve/graph/model/models_gen.go @@ -29,10 +29,15 @@ func (BankMsgSend) IsMessageValue() {} // `BankMsgSendInput` represents input parameters required when the message type is `send`. type BankMsgSendInput struct { // the bech32 address of the fund sender. + // You can filter by the fund sender address. + // ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` FromAddress *string `json:"from_address,omitempty"` // the bech32 address of the fund receiver. + // You can filter by the fund receiver address. + // ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` ToAddress *string `json:"to_address,omitempty"` // the denomination and amount of fund sent (""). + // ex) `1000000ugnot` Amount *string `json:"amount,omitempty"` } @@ -99,11 +104,14 @@ func (MsgAddPackage) IsMessageValue() {} // `MsgAddPackageInput` represents input parameters required when the message type is `add_package`. type MsgAddPackageInput struct { - // the package deployer. + // the bech32 address of the package deployer. + // You can filter by the package deployer's address. + // ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` Creator *string `json:"creator,omitempty"` // the package being deployed. Package *MemPackageInput `json:"package,omitempty"` // the amount of funds to be deposited at deployment, if any (""). + // ex) `1000000ugnot` Deposit *string `json:"deposit,omitempty"` } @@ -121,16 +129,21 @@ func (MsgCall) IsMessageValue() {} // `MsgCallInput` represents input parameters required when the message type is `exec`. type MsgCallInput struct { - // the bech32 address of the caller. + // the bech32 address of the function caller. + // You can filter by the function caller's address. + // ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` Caller *string `json:"caller,omitempty"` // the amount of funds to be deposited to the package, if any (""). + // ex) `1000000ugnot` Send *string `json:"send,omitempty"` // the gno package path. PkgPath *string `json:"pkg_path,omitempty"` // the function name being invoked. Func *string `json:"func,omitempty"` // `args` are the arguments passed to the executed function. - // Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + // The arguments are checked in the order of the argument array and + // if they are empty strings, they are excluded from the filtering criteria. + // ex) `["", "", "1"]` <- Empty strings skip the condition. Args []string `json:"args,omitempty"` } @@ -149,9 +162,12 @@ func (MsgRun) IsMessageValue() {} // `MsgRunInput` represents input parameters required when the message type is `run`. type MsgRunInput struct { - // the bech32 address of the caller. + // the bech32 address of the function caller. + // You can filter by the function caller's address. + // ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` Caller *string `json:"caller,omitempty"` // the amount of funds to be deposited to the package, if any (""). + // ex) `1000000ugnot` Send *string `json:"send,omitempty"` // the package being executed. Package *MemPackageInput `json:"package,omitempty"` @@ -271,10 +287,18 @@ func (e MessageRoute) MarshalGQL(w io.Writer) { type MessageType string const ( - MessageTypeSend MessageType = "send" - MessageTypeExec MessageType = "exec" + // The route value for this message type is `bank`, and the value for transactional messages is `BankMsgSend`. + // This is a transaction message used when sending native tokens. + MessageTypeSend MessageType = "send" + // The route value for this message type is `vm`, and the value for transactional messages is `MsgCall`. + // This is a transaction message that executes a function in realm or package that is deployed in the GNO chain. + MessageTypeExec MessageType = "exec" + // The route value for this message type is `vm`, and the value for transactional messages is `MsgAddPackage`. + // This is a transactional message that adds a package to the GNO chain. MessageTypeAddPackage MessageType = "add_package" - MessageTypeRun MessageType = "run" + // The route value for this message type is `vm`, and the value for transactional messages is `MsgRun`. + // This is a transactional message that executes an arbitrary Gno-coded TX message. + MessageTypeRun MessageType = "run" ) var AllMessageType = []MessageType{ diff --git a/serve/graph/query.resolvers.go b/serve/graph/query.resolvers.go index 596c3a20..026c13ca 100644 --- a/serve/graph/query.resolvers.go +++ b/serve/graph/query.resolvers.go @@ -122,7 +122,7 @@ func (r *queryResolver) LatestBlockHeight(ctx context.Context) (int, error) { return int(h), err } -// Query returns generated.QueryResolver implementation. +// Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } diff --git a/serve/graph/schema/filter/transaction_filter.graphql b/serve/graph/schema/filter/transaction_filter.graphql index e704fda3..f933e108 100644 --- a/serve/graph/schema/filter/transaction_filter.graphql +++ b/serve/graph/schema/filter/transaction_filter.graphql @@ -99,16 +99,21 @@ input TransactionBankMessageInput { input BankMsgSendInput { """ the bech32 address of the fund sender. + You can filter by the fund sender address. + ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` """ from_address: String """ the bech32 address of the fund receiver. + You can filter by the fund receiver address. + ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` """ to_address: String """ the denomination and amount of fund sent (""). + ex) `1000000ugnot` """ amount: String } @@ -138,12 +143,15 @@ input TransactionVmMessageInput { """ input MsgCallInput { """ - the bech32 address of the caller. + the bech32 address of the function caller. + You can filter by the function caller's address. + ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` """ caller: String """ the amount of funds to be deposited to the package, if any (""). + ex) `1000000ugnot` """ send: String @@ -159,7 +167,9 @@ input MsgCallInput { """ `args` are the arguments passed to the executed function. - Arguments are checked in the order of the argument array, and arguments that are not checked are left blank. + The arguments are checked in the order of the argument array and + if they are empty strings, they are excluded from the filtering criteria. + ex) `["", "", "1"]` <- Empty strings skip the condition. """ args: [String!] } @@ -169,7 +179,9 @@ input MsgCallInput { """ input MsgAddPackageInput { """ - the package deployer. + the bech32 address of the package deployer. + You can filter by the package deployer's address. + ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` """ creator: String @@ -180,6 +192,7 @@ input MsgAddPackageInput { """ the amount of funds to be deposited at deployment, if any (""). + ex) `1000000ugnot` """ deposit: String } @@ -189,12 +202,15 @@ input MsgAddPackageInput { """ input MsgRunInput { """ - the bech32 address of the caller. + the bech32 address of the function caller. + You can filter by the function caller's address. + ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` """ caller: String """ the amount of funds to be deposited to the package, if any (""). + ex) `1000000ugnot` """ send: String diff --git a/serve/graph/schema/types/transaction.graphql b/serve/graph/schema/types/transaction.graphql index 07975bff..60a24653 100644 --- a/serve/graph/schema/types/transaction.graphql +++ b/serve/graph/schema/types/transaction.graphql @@ -33,12 +33,15 @@ type Transaction { content_raw: String! """ - The payload of the Transaction in a raw format, typically containing the instructions and any data necessary for execution. + The payload of a message shows the contents of the messages in a transaction. + A message consists of `router`, `type`, and `value` (whose form depends on the `router` and `type`). """ messages: [TransactionMessage]! """ - The memo of the Transaction. + Notes are string information stored within a transaction. + Notes can be utilized to find or distinguish transactions. + For example, when trading a specific exchange, you would utilize the memo field of the transaction. """ memo: String! } @@ -49,26 +52,47 @@ enum MessageRoute { } enum MessageType { + """ + The route value for this message type is `bank`, and the value for transactional messages is `BankMsgSend`. + This is a transaction message used when sending native tokens. + """ send + + """ + The route value for this message type is `vm`, and the value for transactional messages is `MsgCall`. + This is a transaction message that executes a function in realm or package that is deployed in the GNO chain. + """ exec + + """ + The route value for this message type is `vm`, and the value for transactional messages is `MsgAddPackage`. + This is a transactional message that adds a package to the GNO chain. + """ add_package + + """ + The route value for this message type is `vm`, and the value for transactional messages is `MsgRun`. + This is a transactional message that executes an arbitrary Gno-coded TX message. + """ run } type TransactionMessage { """ The type of transaction message. + The value of `typeUrl` can be `send`, `exec`, `add_package`, `run`. """ typeUrl: MessageType! """ The route of transaction message. + The value of `route` can be `bank`, `vm`. """ route: MessageRoute! """ MessageValue is the content of the transaction. - The content can be of type `BankMsgSend` or `MsgCall` or `MsgAddPackage` or `MsgRun`. + `value` can be of type `BankMsgSend`, `MsgCall`, `MsgAddPackage`, `MsgRun`. """ value: MessageValue! } diff --git a/serve/graph/subscription.resolvers.go b/serve/graph/subscription.resolvers.go index 8ab88473..e0b49ccc 100644 --- a/serve/graph/subscription.resolvers.go +++ b/serve/graph/subscription.resolvers.go @@ -33,7 +33,7 @@ func (r *subscriptionResolver) Blocks(ctx context.Context, filter model.BlockFil }), nil } -// Subscription returns generated.SubscriptionResolver implementation. +// Subscription returns SubscriptionResolver implementation. func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } type subscriptionResolver struct{ *Resolver } From 8749b12396a2be4c8c31700635c8964ae502907e Mon Sep 17 00:00:00 2001 From: jinoosss Date: Thu, 4 Apr 2024 16:22:36 +0900 Subject: [PATCH 14/25] feat: Create Filter Functions --- serve/graph/block.resolvers.go | 36 ------ serve/graph/block_filter.go | 28 +++++ serve/graph/generated.go | 20 ++-- serve/graph/model/models_gen.go | 6 +- serve/graph/query.resolvers.go | 12 +- .../schema/filter/transaction_filter.graphql | 6 +- serve/graph/subscription.resolvers.go | 12 +- ...ion.resolvers.go => transaction_filter.go} | 113 ++++++++---------- 8 files changed, 105 insertions(+), 128 deletions(-) delete mode 100644 serve/graph/block.resolvers.go create mode 100644 serve/graph/block_filter.go rename serve/graph/{transaction.resolvers.go => transaction_filter.go} (51%) diff --git a/serve/graph/block.resolvers.go b/serve/graph/block.resolvers.go deleted file mode 100644 index e1237921..00000000 --- a/serve/graph/block.resolvers.go +++ /dev/null @@ -1,36 +0,0 @@ -package graph - -import ( - "time" - - "github.com/gnolang/tx-indexer/serve/graph/model" -) - -// The resolver for handling the block model. -type BlockResolver struct { - block *model.Block -} - -func NewBlockResolver(block *model.Block) *BlockResolver { - return &BlockResolver{block: block} -} - -func (r *BlockResolver) GetBlock() *model.Block { - return r.block -} - -func (r *BlockResolver) FilteredBy(filter model.BlockFilter) bool { - if r.block == nil { - return false - } - - return r.filteredByBlockTime(filter.FromTime, filter.ToTime) -} - -func (r *BlockResolver) filteredByBlockTime(filterFromTime, filterToTime *time.Time) bool { - fromTime := deref(filterFromTime) - toTime := deref(filterToTime) - blockTime := r.block.Time() - - return (blockTime.After(fromTime) || blockTime.Equal(fromTime)) && (toTime.IsZero() || blockTime.Before(toTime)) -} diff --git a/serve/graph/block_filter.go b/serve/graph/block_filter.go new file mode 100644 index 00000000..e49b3062 --- /dev/null +++ b/serve/graph/block_filter.go @@ -0,0 +1,28 @@ +package graph + +import ( + "time" + + "github.com/gnolang/tx-indexer/serve/graph/model" +) + +func FilteredBlockBy(block *model.Block, filter model.BlockFilter) bool { + if block == nil { + return false + } + + return filteredBlockByBlockTime(block, filter.FromTime, filter.ToTime) +} + +func filteredBlockByBlockTime(block *model.Block, filterFromTime, filterToTime *time.Time) bool { + fromTime := deref(filterFromTime) + toTime := deref(filterToTime) + + if filterToTime == nil { + toTime = time.Now() + } + + blockTime := block.Time() + + return (blockTime.After(fromTime) || blockTime.Equal(fromTime)) && (toTime.IsZero() || blockTime.Before(toTime)) +} diff --git a/serve/graph/generated.go b/serve/graph/generated.go index e11c50fc..389e3f8c 100644 --- a/serve/graph/generated.go +++ b/serve/graph/generated.go @@ -5107,34 +5107,34 @@ func (ec *executionContext) unmarshalInputTransactionVmMessageInput(ctx context. asMap[k] = v } - fieldsInOrder := [...]string{"m_call", "m_addpkg", "m_run"} + fieldsInOrder := [...]string{"exec", "add_package", "run"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "m_call": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("m_call")) + case "exec": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("exec")) data, err := ec.unmarshalOMsgCallInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgCallInput(ctx, v) if err != nil { return it, err } - it.MCall = data - case "m_addpkg": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("m_addpkg")) + it.Exec = data + case "add_package": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("add_package")) data, err := ec.unmarshalOMsgAddPackageInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgAddPackageInput(ctx, v) if err != nil { return it, err } - it.MAddpkg = data - case "m_run": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("m_run")) + it.AddPackage = data + case "run": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("run")) data, err := ec.unmarshalOMsgRunInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMsgRunInput(ctx, v) if err != nil { return it, err } - it.MRun = data + it.Run = data } } diff --git a/serve/graph/model/models_gen.go b/serve/graph/model/models_gen.go index 6c65faf4..d0b4244a 100644 --- a/serve/graph/model/models_gen.go +++ b/serve/graph/model/models_gen.go @@ -229,11 +229,11 @@ type TransactionMessageInput struct { // `TransactionVmMessageInput` represents input parameters required when the message router is `vm`. type TransactionVMMessageInput struct { // `MsgCallInput` represents input parameters required when the message type is `exec`. - MCall *MsgCallInput `json:"m_call,omitempty"` + Exec *MsgCallInput `json:"exec,omitempty"` // `MsgAddPackageInput` represents input parameters required when the message type is `add_package`. - MAddpkg *MsgAddPackageInput `json:"m_addpkg,omitempty"` + AddPackage *MsgAddPackageInput `json:"add_package,omitempty"` // `MsgRunInput` represents input parameters required when the message type is `run`. - MRun *MsgRunInput `json:"m_run,omitempty"` + Run *MsgRunInput `json:"run,omitempty"` } type TxFee struct { diff --git a/serve/graph/query.resolvers.go b/serve/graph/query.resolvers.go index 026c13ca..1abfb9a3 100644 --- a/serve/graph/query.resolvers.go +++ b/serve/graph/query.resolvers.go @@ -58,11 +58,11 @@ func (r *queryResolver) Transactions(ctx context.Context, filter model.Transacti return out, nil } - transactionResolver := NewTransactionResolver(model.NewTransaction(t)) - if !transactionResolver.FilteredBy(filter) { + transaction := model.NewTransaction(t) + if !FilteredTransactionBy(transaction, filter) { continue } - out = append(out, transactionResolver.GetTransaction()) + out = append(out, transaction) i++ } } @@ -105,12 +105,12 @@ func (r *queryResolver) Blocks(ctx context.Context, filter model.BlockFilter) ([ return out, nil } - blockResolver := NewBlockResolver(model.NewBlock(b)) - if !blockResolver.FilteredBy(filter) { + block := model.NewBlock(b) + if !FilteredBlockBy(block, filter) { continue } - out = append(out, blockResolver.GetBlock()) + out = append(out, block) i++ } } diff --git a/serve/graph/schema/filter/transaction_filter.graphql b/serve/graph/schema/filter/transaction_filter.graphql index f933e108..e4df0ed0 100644 --- a/serve/graph/schema/filter/transaction_filter.graphql +++ b/serve/graph/schema/filter/transaction_filter.graphql @@ -125,17 +125,17 @@ input TransactionVmMessageInput { """ `MsgCallInput` represents input parameters required when the message type is `exec`. """ - m_call: MsgCallInput + exec: MsgCallInput """ `MsgAddPackageInput` represents input parameters required when the message type is `add_package`. """ - m_addpkg: MsgAddPackageInput + add_package: MsgAddPackageInput """ `MsgRunInput` represents input parameters required when the message type is `run`. """ - m_run: MsgRunInput + run: MsgRunInput } """ diff --git a/serve/graph/subscription.resolvers.go b/serve/graph/subscription.resolvers.go index e0b49ccc..366b1636 100644 --- a/serve/graph/subscription.resolvers.go +++ b/serve/graph/subscription.resolvers.go @@ -15,9 +15,9 @@ import ( func (r *subscriptionResolver) Transactions(ctx context.Context, filter model.TransactionFilter) (<-chan *model.Transaction, error) { return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Transaction) { for _, tx := range nb.Results { - transactionResolver := NewTransactionResolver(model.NewTransaction(tx)) - if transactionResolver.FilteredBy(filter) { - c <- transactionResolver.GetTransaction() + transaction := model.NewTransaction(tx) + if FilteredTransactionBy(transaction, filter) { + c <- transaction } } }), nil @@ -26,9 +26,9 @@ func (r *subscriptionResolver) Transactions(ctx context.Context, filter model.Tr // Blocks is the resolver for the blocks field. func (r *subscriptionResolver) Blocks(ctx context.Context, filter model.BlockFilter) (<-chan *model.Block, error) { return handleChannel(ctx, r.manager, func(nb *types.NewBlock, c chan<- *model.Block) { - blockResolver := NewBlockResolver(model.NewBlock(nb.Block)) - if blockResolver.FilteredBy(filter) { - c <- blockResolver.GetBlock() + block := model.NewBlock(nb.Block) + if FilteredBlockBy(block, filter) { + c <- block } }), nil } diff --git a/serve/graph/transaction.resolvers.go b/serve/graph/transaction_filter.go similarity index 51% rename from serve/graph/transaction.resolvers.go rename to serve/graph/transaction_filter.go index f3c1698f..e395333d 100644 --- a/serve/graph/transaction.resolvers.go +++ b/serve/graph/transaction_filter.go @@ -6,44 +6,29 @@ import ( "github.com/gnolang/tx-indexer/serve/graph/model" ) -// The resolver for handling the transaction model. -type TransactionResolver struct { - transaction *model.Transaction -} - -func NewTransactionResolver(transaction *model.Transaction) *TransactionResolver { - return &TransactionResolver{ - transaction: transaction, - } -} - -func (r *TransactionResolver) GetTransaction() *model.Transaction { - return r.transaction -} - -func (r *TransactionResolver) FilteredBy(filter model.TransactionFilter) bool { - if !r.filteredByGasUsed(filter.FromGasUsed, filter.ToGasUsed) { +func FilteredTransactionBy(tx *model.Transaction, filter model.TransactionFilter) bool { + if !filteredTransactionByGasUsed(tx, filter.FromGasUsed, filter.ToGasUsed) { return false } - if !r.filteredByGasWanted(filter.FromGasWanted, filter.ToGasWanted) { + if !filteredTransactionByGasWanted(tx, filter.FromGasWanted, filter.ToGasWanted) { return false } - if !r.filteredByMemo(filter.Memo) { + if !filteredTransactionByMemo(tx, filter.Memo) { return false } if filter.Message != nil { - if !r.filteredByMessageRoute(filter.Message.Route) { + if !filteredTransactionByMessageRoute(tx, filter.Message.Route) { return false } - if !r.filteredByMessageType(filter.Message.TypeURL) { + if !filteredTransactionByMessageType(tx, filter.Message.TypeURL) { return false } - if !r.filteredByMessages(filter.Message) { + if !filteredTransactionByMessages(tx, filter.Message) { return false } } @@ -51,10 +36,10 @@ func (r *TransactionResolver) FilteredBy(filter model.TransactionFilter) bool { return true } -func (r *TransactionResolver) filteredByGasUsed(filterFromGasUsed, filterToGasUsed *int) bool { +func filteredTransactionByGasUsed(tx *model.Transaction, filterFromGasUsed, filterToGasUsed *int) bool { fromGasUsed := deref(filterFromGasUsed) toGasUsed := deref(filterToGasUsed) - transactionGasUsed := r.transaction.GasUsed() + transactionGasUsed := tx.GasUsed() if toGasUsed == 0 { toGasUsed = math.MaxInt @@ -63,10 +48,10 @@ func (r *TransactionResolver) filteredByGasUsed(filterFromGasUsed, filterToGasUs return transactionGasUsed >= fromGasUsed && transactionGasUsed <= toGasUsed } -func (r *TransactionResolver) filteredByGasWanted(filterFromGasWanted, filterToGasWanted *int) bool { +func filteredTransactionByGasWanted(tx *model.Transaction, filterFromGasWanted, filterToGasWanted *int) bool { fromGasWanted := deref(filterFromGasWanted) toGasWanted := deref(filterToGasWanted) - transactionGasUsed := r.transaction.GasWanted() + transactionGasUsed := tx.GasWanted() if toGasWanted == 0 { toGasWanted = math.MaxInt @@ -75,18 +60,18 @@ func (r *TransactionResolver) filteredByGasWanted(filterFromGasWanted, filterToG return transactionGasUsed >= fromGasWanted && transactionGasUsed <= toGasWanted } -func (r *TransactionResolver) filteredByMemo(filterMemo *string) bool { +func filteredTransactionByMemo(tx *model.Transaction, filterMemo *string) bool { if filterMemo == nil { return true } - return deref(filterMemo) == r.transaction.Memo() + return deref(filterMemo) == tx.Memo() } -func (r *TransactionResolver) filteredByMessages(messageInput *model.TransactionMessageInput) bool { - messages := r.transaction.Messages() +func filteredTransactionByMessages(tx *model.Transaction, messageInput *model.TransactionMessageInput) bool { + messages := tx.Messages() for _, message := range messages { - if !r.filteredByTransactionMessage(messageInput, message) { + if !filteredTransactionMessageBy(message, messageInput) { return false } } @@ -94,12 +79,12 @@ func (r *TransactionResolver) filteredByMessages(messageInput *model.Transaction return true } -func (r *TransactionResolver) filteredByMessageRoute(messageRoute *model.MessageRoute) bool { +func filteredTransactionByMessageRoute(tx *model.Transaction, messageRoute *model.MessageRoute) bool { if messageRoute == nil { return true } - messages := r.transaction.Messages() + messages := tx.Messages() for _, message := range messages { if message.Route.String() == messageRoute.String() { return true @@ -109,12 +94,12 @@ func (r *TransactionResolver) filteredByMessageRoute(messageRoute *model.Message return false } -func (r *TransactionResolver) filteredByMessageType(messageType *model.MessageType) bool { +func filteredTransactionByMessageType(tx *model.Transaction, messageType *model.MessageType) bool { if messageType == nil { return true } - messages := r.transaction.Messages() + messages := tx.Messages() for _, message := range messages { if message.TypeURL.String() == messageType.String() { return true @@ -124,9 +109,9 @@ func (r *TransactionResolver) filteredByMessageType(messageType *model.MessageTy return false } -func (r *TransactionResolver) filteredByTransactionMessage( - messageInput *model.TransactionMessageInput, +func filteredTransactionMessageBy( tm *model.TransactionMessage, + messageInput *model.TransactionMessageInput, ) bool { if messageInput.TypeURL != nil && messageInput.TypeURL.String() != tm.TypeURL.String() { return false @@ -149,19 +134,19 @@ func (r *TransactionResolver) filteredByTransactionMessage( switch tm.TypeURL { case model.MessageTypeSend: - if !checkMessageOfBankMsgSend(messageInput.BankParam, tm.BankMsgSend()) { + if !checkMessageOfBankMsgSend(tm.BankMsgSend(), messageInput.BankParam) { return false } case model.MessageTypeExec: - if !checkByMessageOfMsgCall(messageInput.VMParam, tm.VMMsgCall()) { + if !checkByMessageOfMsgCall(tm.VMMsgCall(), messageInput.VMParam) { return false } case model.MessageTypeAddPackage: - if !checkMessageOfMsgAddPackage(messageInput.VMParam, tm.VMAddPackage()) { + if !checkMessageOfMsgAddPackage(tm.VMAddPackage(), messageInput.VMParam) { return false } case model.MessageTypeRun: - if !checkMessageOfMsgRun(messageInput.VMParam, tm.VMMsgRun()) { + if !checkMessageOfMsgRun(tm.VMMsgRun(), messageInput.VMParam) { return false } } @@ -170,8 +155,8 @@ func (r *TransactionResolver) filteredByTransactionMessage( } func checkMessageOfBankMsgSend( - bankMessageInput *model.TransactionBankMessageInput, messageValue model.BankMsgSend, + bankMessageInput *model.TransactionBankMessageInput, ) bool { params := bankMessageInput if params == nil || params.Send == nil { @@ -194,41 +179,41 @@ func checkMessageOfBankMsgSend( } func checkByMessageOfMsgCall( - vmMessageInput *model.TransactionVMMessageInput, messageValue model.MsgCall, + vmMessageInput *model.TransactionVMMessageInput, ) bool { params := vmMessageInput if params == nil { return true } - if params.MCall == nil { + if params.Exec == nil { return false } - if params.MCall.Caller != nil && deref(params.MCall.Caller) != messageValue.Caller { + if params.Exec.Caller != nil && deref(params.Exec.Caller) != messageValue.Caller { return false } - if params.MCall.Func != nil && deref(params.MCall.Func) != messageValue.Func { + if params.Exec.Func != nil && deref(params.Exec.Func) != messageValue.Func { return false } - if params.MCall.PkgPath != nil && deref(params.MCall.PkgPath) != messageValue.PkgPath { + if params.Exec.PkgPath != nil && deref(params.Exec.PkgPath) != messageValue.PkgPath { return false } - if params.MCall.Send != nil && deref(params.MCall.Send) != messageValue.Send { + if params.Exec.Send != nil && deref(params.Exec.Send) != messageValue.Send { return false } - if params.MCall.Args != nil { + if params.Exec.Args != nil { messageArgs := messageValue.Args if messageArgs == nil { return false } - messageFilterArgs := params.MCall.Args + messageFilterArgs := params.Exec.Args for index, arg := range messageArgs { if index < len(messageFilterArgs) { if arg != "" && messageFilterArgs[index] != arg { @@ -242,32 +227,32 @@ func checkByMessageOfMsgCall( } func checkMessageOfMsgAddPackage( - vmMessageInput *model.TransactionVMMessageInput, messageValue model.MsgAddPackage, + vmMessageInput *model.TransactionVMMessageInput, ) bool { params := vmMessageInput if params == nil { return true } - if params.MAddpkg == nil { + if params.AddPackage == nil { return false } - if params.MAddpkg.Creator != nil && deref(params.MAddpkg.Creator) != messageValue.Creator { + if params.AddPackage.Creator != nil && deref(params.AddPackage.Creator) != messageValue.Creator { return false } - if params.MAddpkg.Deposit != nil && deref(params.MAddpkg.Deposit) != messageValue.Deposit { + if params.AddPackage.Deposit != nil && deref(params.AddPackage.Deposit) != messageValue.Deposit { return false } - if params.MAddpkg.Package != nil { - if params.MAddpkg.Package.Name != nil && deref(params.MAddpkg.Package.Name) != messageValue.Package.Name { + if params.AddPackage.Package != nil { + if params.AddPackage.Package.Name != nil && deref(params.AddPackage.Package.Name) != messageValue.Package.Name { return false } - if params.MAddpkg.Package.Path != nil && deref(params.MAddpkg.Package.Path) != messageValue.Package.Path { + if params.AddPackage.Package.Path != nil && deref(params.AddPackage.Package.Path) != messageValue.Package.Path { return false } } @@ -275,30 +260,30 @@ func checkMessageOfMsgAddPackage( return true } -func checkMessageOfMsgRun(vmMessageInput *model.TransactionVMMessageInput, messageValue model.MsgRun) bool { +func checkMessageOfMsgRun(messageValue model.MsgRun, vmMessageInput *model.TransactionVMMessageInput) bool { params := vmMessageInput if params == nil { return true } - if params.MRun == nil { + if params.Run == nil { return false } - if params.MRun.Caller != nil && deref(params.MRun.Caller) != messageValue.Caller { + if params.Run.Caller != nil && deref(params.Run.Caller) != messageValue.Caller { return false } - if params.MRun.Send != nil && deref(params.MRun.Send) != messageValue.Send { + if params.Run.Send != nil && deref(params.Run.Send) != messageValue.Send { return false } - if params.MRun.Package != nil { - if deref(params.MRun.Package.Name) != messageValue.Package.Name { + if params.Run.Package != nil { + if deref(params.Run.Package.Name) != messageValue.Package.Name { return false } - if deref(params.MRun.Package.Path) != messageValue.Package.Path { + if deref(params.Run.Package.Path) != messageValue.Package.Path { return false } } From 30969d9213d0ae22a1a5b9b54be3cb59c91a391f Mon Sep 17 00:00:00 2001 From: jinoosss Date: Thu, 4 Apr 2024 16:24:04 +0900 Subject: [PATCH 15/25] feat: Add a token amount filter --- serve/graph/generated.go | 58 +++++++++++++++++-- serve/graph/model/models_gen.go | 19 ++++-- .../schema/filter/transaction_filter.graphql | 29 ++++++++-- serve/graph/transaction_filter.go | 43 ++++++++++++-- 4 files changed, 133 insertions(+), 16 deletions(-) diff --git a/serve/graph/generated.go b/serve/graph/generated.go index 389e3f8c..341966f2 100644 --- a/serve/graph/generated.go +++ b/serve/graph/generated.go @@ -479,6 +479,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputAmountInput, ec.unmarshalInputBankMsgSendInput, ec.unmarshalInputBlockFilter, ec.unmarshalInputMemFileInput, @@ -4627,6 +4628,47 @@ func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Conte // region **************************** input.gotpl ***************************** +func (ec *executionContext) unmarshalInputAmountInput(ctx context.Context, obj interface{}) (model.AmountInput, error) { + var it model.AmountInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"from", "to", "denomination"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "from": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("from")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.From = data + case "to": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("to")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.To = data + case "denomination": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("denomination")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Denomination = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputBankMsgSendInput(ctx context.Context, obj interface{}) (model.BankMsgSendInput, error) { var it model.BankMsgSendInput asMap := map[string]interface{}{} @@ -4657,7 +4699,7 @@ func (ec *executionContext) unmarshalInputBankMsgSendInput(ctx context.Context, it.ToAddress = data case "amount": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("amount")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOAmountInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐAmountInput(ctx, v) if err != nil { return it, err } @@ -4821,7 +4863,7 @@ func (ec *executionContext) unmarshalInputMsgAddPackageInput(ctx context.Context it.Package = data case "deposit": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("deposit")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOAmountInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐAmountInput(ctx, v) if err != nil { return it, err } @@ -4855,7 +4897,7 @@ func (ec *executionContext) unmarshalInputMsgCallInput(ctx context.Context, obj it.Caller = data case "send": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("send")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOAmountInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐAmountInput(ctx, v) if err != nil { return it, err } @@ -4910,7 +4952,7 @@ func (ec *executionContext) unmarshalInputMsgRunInput(ctx context.Context, obj i it.Caller = data case "send": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("send")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOAmountInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐAmountInput(ctx, v) if err != nil { return it, err } @@ -6617,6 +6659,14 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return res } +func (ec *executionContext) unmarshalOAmountInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐAmountInput(ctx context.Context, v interface{}) (*model.AmountInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputAmountInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOBankMsgSendInput2ᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐBankMsgSendInput(ctx context.Context, v interface{}) (*model.BankMsgSendInput, error) { if v == nil { return nil, nil diff --git a/serve/graph/model/models_gen.go b/serve/graph/model/models_gen.go index d0b4244a..ff56a6ef 100644 --- a/serve/graph/model/models_gen.go +++ b/serve/graph/model/models_gen.go @@ -13,6 +13,17 @@ type MessageValue interface { IsMessageValue() } +// `AmountInput` is a range of token quantities to filter by. +type AmountInput struct { + // The minimum quantity of tokens to check for. + From *int `json:"from,omitempty"` + // The maximum quantity of tokens to check for. + To *int `json:"to,omitempty"` + // Filter by token's denomination. + // If set to an empty string, it will get an empty value. + Denomination *string `json:"denomination,omitempty"` +} + // `BankMsgSend` is a message with a message router of `bank` and a message type of `send`. // `BankMsgSend` is the fund transfer tx message. type BankMsgSend struct { @@ -38,7 +49,7 @@ type BankMsgSendInput struct { ToAddress *string `json:"to_address,omitempty"` // the denomination and amount of fund sent (""). // ex) `1000000ugnot` - Amount *string `json:"amount,omitempty"` + Amount *AmountInput `json:"amount,omitempty"` } // Filters for querying Blocks within specified criteria related to their attributes. @@ -112,7 +123,7 @@ type MsgAddPackageInput struct { Package *MemPackageInput `json:"package,omitempty"` // the amount of funds to be deposited at deployment, if any (""). // ex) `1000000ugnot` - Deposit *string `json:"deposit,omitempty"` + Deposit *AmountInput `json:"deposit,omitempty"` } // `MsgCall` is a message with a message router of `vm` and a message type of `exec`. @@ -135,7 +146,7 @@ type MsgCallInput struct { Caller *string `json:"caller,omitempty"` // the amount of funds to be deposited to the package, if any (""). // ex) `1000000ugnot` - Send *string `json:"send,omitempty"` + Send *AmountInput `json:"send,omitempty"` // the gno package path. PkgPath *string `json:"pkg_path,omitempty"` // the function name being invoked. @@ -168,7 +179,7 @@ type MsgRunInput struct { Caller *string `json:"caller,omitempty"` // the amount of funds to be deposited to the package, if any (""). // ex) `1000000ugnot` - Send *string `json:"send,omitempty"` + Send *AmountInput `json:"send,omitempty"` // the package being executed. Package *MemPackageInput `json:"package,omitempty"` } diff --git a/serve/graph/schema/filter/transaction_filter.graphql b/serve/graph/schema/filter/transaction_filter.graphql index e4df0ed0..ddbae724 100644 --- a/serve/graph/schema/filter/transaction_filter.graphql +++ b/serve/graph/schema/filter/transaction_filter.graphql @@ -115,7 +115,7 @@ input BankMsgSendInput { the denomination and amount of fund sent (""). ex) `1000000ugnot` """ - amount: String + amount: AmountInput } """ @@ -153,7 +153,7 @@ input MsgCallInput { the amount of funds to be deposited to the package, if any (""). ex) `1000000ugnot` """ - send: String + send: AmountInput """ the gno package path. @@ -194,7 +194,7 @@ input MsgAddPackageInput { the amount of funds to be deposited at deployment, if any (""). ex) `1000000ugnot` """ - deposit: String + deposit: AmountInput } """ @@ -212,7 +212,7 @@ input MsgRunInput { the amount of funds to be deposited to the package, if any (""). ex) `1000000ugnot` """ - send: String + send: AmountInput """ the package being executed. @@ -254,3 +254,24 @@ input MemFileInput { """ Body: String } + +""" +`AmountInput` is a range of token quantities to filter by. +""" +input AmountInput { + """ + The minimum quantity of tokens to check for. + """ + from: Int + + """ + The maximum quantity of tokens to check for. + """ + to: Int + + """ + Filter by token's denomination. + If set to an empty string, it will get an empty value. + """ + denomination: String +} diff --git a/serve/graph/transaction_filter.go b/serve/graph/transaction_filter.go index e395333d..51536fbd 100644 --- a/serve/graph/transaction_filter.go +++ b/serve/graph/transaction_filter.go @@ -3,6 +3,7 @@ package graph import ( "math" + "github.com/gnolang/gno/tm2/pkg/std" "github.com/gnolang/tx-indexer/serve/graph/model" ) @@ -36,6 +37,40 @@ func FilteredTransactionBy(tx *model.Transaction, filter model.TransactionFilter return true } +func filteredAmountBy(amountStr string, amountInput *model.AmountInput) bool { + if amountInput == nil { + return true + } + + coins, err := std.ParseCoins(amountStr) + if err != nil { + return false + } + + if amountInput.Denomination != nil { + if deref(amountInput.Denomination) == "" && coins.Empty() { + return true + } + } + + for _, coin := range coins { + if amountInput.Denomination == nil || coin.Denom == deref(amountInput.Denomination) { + fromAmount := int64(deref(amountInput.From)) + toAmount := int64(deref(amountInput.To)) + + if toAmount == 0 { + toAmount = math.MaxInt + } + + if coin.Amount >= fromAmount && coin.Amount <= toAmount { + return true + } + } + } + + return false +} + func filteredTransactionByGasUsed(tx *model.Transaction, filterFromGasUsed, filterToGasUsed *int) bool { fromGasUsed := deref(filterFromGasUsed) toGasUsed := deref(filterToGasUsed) @@ -163,7 +198,7 @@ func checkMessageOfBankMsgSend( return true } - if params.Send.Amount != nil && deref(params.Send.Amount) != messageValue.Amount { + if params.Send.Amount != nil && !filteredAmountBy(messageValue.Amount, params.Send.Amount) { return false } @@ -203,7 +238,7 @@ func checkByMessageOfMsgCall( return false } - if params.Exec.Send != nil && deref(params.Exec.Send) != messageValue.Send { + if params.Exec.Send != nil && filteredAmountBy(messageValue.Send, params.Exec.Send) { return false } @@ -243,7 +278,7 @@ func checkMessageOfMsgAddPackage( return false } - if params.AddPackage.Deposit != nil && deref(params.AddPackage.Deposit) != messageValue.Deposit { + if params.AddPackage.Deposit != nil && filteredAmountBy(messageValue.Deposit, params.AddPackage.Deposit) { return false } @@ -274,7 +309,7 @@ func checkMessageOfMsgRun(messageValue model.MsgRun, vmMessageInput *model.Trans return false } - if params.Run.Send != nil && deref(params.Run.Send) != messageValue.Send { + if params.Run.Send != nil && filteredAmountBy(messageValue.Send, params.Run.Send) { return false } From e221c7fcad3b116e66491d590385a5c65e548f7b Mon Sep 17 00:00:00 2001 From: jinoosss Date: Thu, 4 Apr 2024 18:28:54 +0900 Subject: [PATCH 16/25] feat: Improve transaction performance and handle exception cases --- serve/graph/generated.go | 133 +++++++++++++++---- serve/graph/model/models_gen.go | 7 + serve/graph/model/transaction.go | 108 +++++++++++---- serve/graph/schema/types/transaction.graphql | 13 +- serve/graph/transaction_filter.go | 18 +-- 5 files changed, 217 insertions(+), 62 deletions(-) diff --git a/serve/graph/generated.go b/serve/graph/generated.go index 341966f2..29d7ab42 100644 --- a/serve/graph/generated.go +++ b/serve/graph/generated.go @@ -126,6 +126,10 @@ type ComplexityRoot struct { GasFee func(childComplexity int) int GasWanted func(childComplexity int) int } + + UnexpectedMessage struct { + Raw func(childComplexity int) int + } } type QueryResolver interface { @@ -471,6 +475,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.TxFee.GasWanted(childComplexity), true + case "UnexpectedMessage.raw": + if e.complexity.UnexpectedMessage.Raw == nil { + break + } + + return e.complexity.UnexpectedMessage.Raw(childComplexity), true + } return 0, false } @@ -2661,9 +2672,9 @@ func (ec *executionContext) _TransactionMessage_typeUrl(ctx context.Context, fie } return graphql.Null } - res := resTmp.(model.MessageType) + res := resTmp.(string) fc.Result = res - return ec.marshalNMessageType2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_TransactionMessage_typeUrl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2673,7 +2684,7 @@ func (ec *executionContext) fieldContext_TransactionMessage_typeUrl(ctx context. IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type MessageType does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil @@ -2705,9 +2716,9 @@ func (ec *executionContext) _TransactionMessage_route(ctx context.Context, field } return graphql.Null } - res := resTmp.(model.MessageRoute) + res := resTmp.(string) fc.Result = res - return ec.marshalNMessageRoute2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_TransactionMessage_route(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2717,7 +2728,7 @@ func (ec *executionContext) fieldContext_TransactionMessage_route(ctx context.Co IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type MessageRoute does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil @@ -2855,6 +2866,50 @@ func (ec *executionContext) fieldContext_TxFee_gas_fee(ctx context.Context, fiel return fc, nil } +func (ec *executionContext) _UnexpectedMessage_raw(ctx context.Context, field graphql.CollectedField, obj *model.UnexpectedMessage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UnexpectedMessage_raw(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.Raw, 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_UnexpectedMessage_raw(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UnexpectedMessage", + 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) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { @@ -5219,6 +5274,13 @@ func (ec *executionContext) _MessageValue(ctx context.Context, sel ast.Selection return graphql.Null } return ec._MsgRun(ctx, sel, obj) + case model.UnexpectedMessage: + return ec._UnexpectedMessage(ctx, sel, &obj) + case *model.UnexpectedMessage: + if obj == nil { + return graphql.Null + } + return ec._UnexpectedMessage(ctx, sel, obj) default: panic(fmt.Errorf("unexpected type %T", obj)) } @@ -5879,6 +5941,45 @@ func (ec *executionContext) _TxFee(ctx context.Context, sel ast.SelectionSet, ob return out } +var unexpectedMessageImplementors = []string{"UnexpectedMessage", "MessageValue"} + +func (ec *executionContext) _UnexpectedMessage(ctx context.Context, sel ast.SelectionSet, obj *model.UnexpectedMessage) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, unexpectedMessageImplementors) + + 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("UnexpectedMessage") + case "raw": + out.Values[i] = ec._UnexpectedMessage_raw(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 __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { @@ -6289,26 +6390,6 @@ func (ec *executionContext) marshalNMemPackage2ᚖgithubᚗcomᚋgnolangᚋtxᚑ return ec._MemPackage(ctx, sel, v) } -func (ec *executionContext) unmarshalNMessageRoute2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx context.Context, v interface{}) (model.MessageRoute, error) { - var res model.MessageRoute - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNMessageRoute2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageRoute(ctx context.Context, sel ast.SelectionSet, v model.MessageRoute) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalNMessageType2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx context.Context, v interface{}) (model.MessageType, error) { - var res model.MessageType - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNMessageType2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageType(ctx context.Context, sel ast.SelectionSet, v model.MessageType) graphql.Marshaler { - return v -} - func (ec *executionContext) marshalNMessageValue2githubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMessageValue(ctx context.Context, sel ast.SelectionSet, v model.MessageValue) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { diff --git a/serve/graph/model/models_gen.go b/serve/graph/model/models_gen.go index ff56a6ef..9caca6e1 100644 --- a/serve/graph/model/models_gen.go +++ b/serve/graph/model/models_gen.go @@ -254,6 +254,13 @@ type TxFee struct { GasFee int `json:"gas_fee"` } +// `UnexpectedMessage` is an Undefined Message, which is a message that decoding failed. +type UnexpectedMessage struct { + Raw string `json:"raw"` +} + +func (UnexpectedMessage) IsMessageValue() {} + type MessageRoute string const ( diff --git a/serve/graph/model/transaction.go b/serve/graph/model/transaction.go index c89059f2..28453805 100644 --- a/serve/graph/model/transaction.go +++ b/serve/graph/model/transaction.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "sync" "github.com/gnolang/gno/gno.land/pkg/sdk/vm" "github.com/gnolang/gno/tm2/pkg/amino" @@ -13,24 +14,21 @@ import ( ) type Transaction struct { - memo string + stdTx *std.Tx txResult *types.TxResult messages []*TransactionMessage + + mu sync.Mutex + onceTx sync.Once + onceMessages sync.Once } func NewTransaction(txResult *types.TxResult) *Transaction { - var stdTx std.Tx - - if err := amino.Unmarshal(txResult.Tx, &stdTx); err != nil { - return nil + return &Transaction{ + txResult: txResult, + messages: make([]*TransactionMessage, 0), + stdTx: nil, } - - messages := make([]*TransactionMessage, 0) - for _, message := range stdTx.GetMsgs() { - messages = append(messages, NewTransactionMessage(message)) - } - - return &Transaction{txResult: txResult, messages: messages, memo: stdTx.GetMemo()} } func (t *Transaction) ID() string { @@ -62,11 +60,15 @@ func (t *Transaction) ContentRaw() string { } func (t *Transaction) Memo() string { - return t.memo + if t.getStdTx() == nil { + return "" + } + + return t.getStdTx().GetMemo() } func (t *Transaction) Messages() []*TransactionMessage { - return t.messages + return t.getMessages() } func (t *Transaction) Fee() *TxFee { @@ -76,10 +78,48 @@ func (t *Transaction) Fee() *TxFee { } } +func (t *Transaction) getStdTx() *std.Tx { + // The function to unmarshal a `std.Tx` is executed once. + unmarshalTx := func() { + var stdTx std.Tx + if err := amino.Unmarshal(t.txResult.Tx, &stdTx); err != nil { + t.stdTx = nil + } + + t.mu.Lock() + t.stdTx = &stdTx + t.mu.Unlock() + } + + t.onceTx.Do(unmarshalTx) + + return t.stdTx +} + +func (t *Transaction) getMessages() []*TransactionMessage { + // Functions that unmarshal transaction messages are executed once. + unmarshalMessages := func() { + stdTx := t.getStdTx() + messages := make([]*TransactionMessage, 0) + + for _, message := range stdTx.GetMsgs() { + messages = append(messages, NewTransactionMessage(message)) + } + + t.mu.Lock() + t.messages = messages + t.mu.Unlock() + } + + t.onceMessages.Do(unmarshalMessages) + + return t.messages +} + type TransactionMessage struct { Value MessageValue - TypeURL MessageType - Route MessageRoute + Route string + TypeURL string } func NewTransactionMessage(message std.Msg) *TransactionMessage { @@ -89,8 +129,8 @@ func NewTransactionMessage(message std.Msg) *TransactionMessage { case bank.RouterKey: if message.Type() == MessageTypeSend.String() { contentMessage = &TransactionMessage{ - Route: MessageRouteBank, - TypeURL: MessageTypeSend, + Route: MessageRouteBank.String(), + TypeURL: MessageTypeSend.String(), Value: makeBankMsgSend(message), } } @@ -98,25 +138,33 @@ func NewTransactionMessage(message std.Msg) *TransactionMessage { switch message.Type() { case MessageTypeExec.String(): contentMessage = &TransactionMessage{ - Route: MessageRouteVM, - TypeURL: MessageTypeExec, + Route: MessageRouteVM.String(), + TypeURL: MessageTypeExec.String(), Value: makeVMMsgCall(message), } case MessageTypeAddPackage.String(): contentMessage = &TransactionMessage{ - Route: MessageRouteVM, - TypeURL: MessageTypeAddPackage, + Route: MessageRouteVM.String(), + TypeURL: MessageTypeAddPackage.String(), Value: makeVMAddPackage(message), } case MessageTypeRun.String(): contentMessage = &TransactionMessage{ - Route: MessageRouteVM, - TypeURL: MessageTypeRun, + Route: MessageRouteVM.String(), + TypeURL: MessageTypeRun.String(), Value: makeVMMsgRun(message), } } } + if contentMessage == nil { + contentMessage = &TransactionMessage{ + Route: message.Route(), + TypeURL: message.Type(), + Value: makeUnexpectedMessage(message), + } + } + return contentMessage } @@ -214,6 +262,18 @@ func makeVMMsgRun(value std.Msg) MsgRun { } } +func makeUnexpectedMessage(value std.Msg) UnexpectedMessage { + raw, err := json.Marshal(value) + if err != nil { + return UnexpectedMessage{ + Raw: "", + } + } + return UnexpectedMessage{ + Raw: string(raw), + } +} + func cast[T any](input any) (*T, error) { encoded, err := json.Marshal(input) if err != nil { diff --git a/serve/graph/schema/types/transaction.graphql b/serve/graph/schema/types/transaction.graphql index 60a24653..e94f656a 100644 --- a/serve/graph/schema/types/transaction.graphql +++ b/serve/graph/schema/types/transaction.graphql @@ -82,13 +82,13 @@ type TransactionMessage { The type of transaction message. The value of `typeUrl` can be `send`, `exec`, `add_package`, `run`. """ - typeUrl: MessageType! + typeUrl: String! """ The route of transaction message. The value of `route` can be `bank`, `vm`. """ - route: MessageRoute! + route: String! """ MessageValue is the content of the transaction. @@ -97,7 +97,7 @@ type TransactionMessage { value: MessageValue! } -union MessageValue = BankMsgSend | MsgCall | MsgAddPackage | MsgRun +union MessageValue = BankMsgSend | MsgCall | MsgAddPackage | MsgRun | UnexpectedMessage """ `BankMsgSend` is a message with a message router of `bank` and a message type of `send`. @@ -174,6 +174,13 @@ type MsgRun { package: MemPackage! } +""" +`UnexpectedMessage` is an Undefined Message, which is a message that decoding failed. +""" +type UnexpectedMessage { + raw: String! +} + """ `MemPackage` is the metadata information tied to package / realm deployment. """ diff --git a/serve/graph/transaction_filter.go b/serve/graph/transaction_filter.go index 51536fbd..363d6eb8 100644 --- a/serve/graph/transaction_filter.go +++ b/serve/graph/transaction_filter.go @@ -121,7 +121,7 @@ func filteredTransactionByMessageRoute(tx *model.Transaction, messageRoute *mode messages := tx.Messages() for _, message := range messages { - if message.Route.String() == messageRoute.String() { + if message.Route == messageRoute.String() { return true } } @@ -136,7 +136,7 @@ func filteredTransactionByMessageType(tx *model.Transaction, messageType *model. messages := tx.Messages() for _, message := range messages { - if message.TypeURL.String() == messageType.String() { + if message.TypeURL == messageType.String() { return true } } @@ -148,7 +148,7 @@ func filteredTransactionMessageBy( tm *model.TransactionMessage, messageInput *model.TransactionMessageInput, ) bool { - if messageInput.TypeURL != nil && messageInput.TypeURL.String() != tm.TypeURL.String() { + if messageInput.TypeURL != nil && messageInput.TypeURL.String() != tm.TypeURL { return false } @@ -157,30 +157,30 @@ func filteredTransactionMessageBy( } switch tm.Route { - case model.MessageRouteBank: + case model.MessageRouteBank.String(): if messageInput.BankParam == nil { return false } - case model.MessageRouteVM: + case model.MessageRouteVM.String(): if messageInput.VMParam == nil { return false } } switch tm.TypeURL { - case model.MessageTypeSend: + case model.MessageTypeSend.String(): if !checkMessageOfBankMsgSend(tm.BankMsgSend(), messageInput.BankParam) { return false } - case model.MessageTypeExec: + case model.MessageTypeExec.String(): if !checkByMessageOfMsgCall(tm.VMMsgCall(), messageInput.VMParam) { return false } - case model.MessageTypeAddPackage: + case model.MessageTypeAddPackage.String(): if !checkMessageOfMsgAddPackage(tm.VMAddPackage(), messageInput.VMParam) { return false } - case model.MessageTypeRun: + case model.MessageTypeRun.String(): if !checkMessageOfMsgRun(tm.VMMsgRun(), messageInput.VMParam) { return false } From 598eda183e7653474c42db606cfc8bfa8415fc94 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Thu, 4 Apr 2024 18:49:08 +0900 Subject: [PATCH 17/25] chore: Add descriptions for docs --- .../schema/filter/transaction_filter.graphql | 10 +++- serve/graph/schema/types/transaction.graphql | 46 +++++++++++++++++-- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/serve/graph/schema/filter/transaction_filter.graphql b/serve/graph/schema/filter/transaction_filter.graphql index ddbae724..e047fb7b 100644 --- a/serve/graph/schema/filter/transaction_filter.graphql +++ b/serve/graph/schema/filter/transaction_filter.graphql @@ -49,26 +49,32 @@ input TransactionFilter { """ Transaction's message to filter Transactions. + `message` can be configured as a filter with a transaction message's `router` and `type` and `parameters(bank / vm)`. """ message: TransactionMessageInput """ - `memo` value to filter Transaction's memo. + `memo` are string information stored within a transaction. + `memo` can be utilized to find or distinguish transactions. + For example, when trading a specific exchange, you would utilize the memo field of the transaction. """ memo: String } """ -Input for filters by transaction message. +Transaction's message to filter Transactions. +`message` can be of type `BankMsgSend`, `MsgCall`, `MsgAddPackage`, `MsgRun`. """ input TransactionMessageInput { """ The type of transaction message. + The value of `typeUrl` can be `send`, `exec`, `add_package`, `run`. """ type_url: MessageType """ The route of transaction message. + The value of `route` can be `bank`, `vm`. """ route: MessageRoute diff --git a/serve/graph/schema/types/transaction.graphql b/serve/graph/schema/types/transaction.graphql index e94f656a..f6aba4fe 100644 --- a/serve/graph/schema/types/transaction.graphql +++ b/serve/graph/schema/types/transaction.graphql @@ -39,18 +39,26 @@ type Transaction { messages: [TransactionMessage]! """ - Notes are string information stored within a transaction. - Notes can be utilized to find or distinguish transactions. + `memo` are string information stored within a transaction. + `memo` can be utilized to find or distinguish transactions. For example, when trading a specific exchange, you would utilize the memo field of the transaction. """ memo: String! } +""" +`MessageRoute` is route type of the transactional message. +`MessageRoute` has the values of vm and bank. +""" enum MessageRoute { vm bank } +""" +`MessageType` is message type of the transaction. +`MessageType` has the values `send`, `exec`, `add_package`, and `run`. +""" enum MessageType { """ The route value for this message type is `bank`, and the value for transactional messages is `BankMsgSend`. @@ -92,7 +100,7 @@ type TransactionMessage { """ MessageValue is the content of the transaction. - `value` can be of type `BankMsgSend`, `MsgCall`, `MsgAddPackage`, `MsgRun`. + `value` can be of type `BankMsgSend`, `MsgCall`, `MsgAddPackage`, `MsgRun`, `UnexpectedMessage`. """ value: MessageValue! } @@ -106,16 +114,19 @@ union MessageValue = BankMsgSend | MsgCall | MsgAddPackage | MsgRun | Unexpected type BankMsgSend { """ the bech32 address of the fund sender. + ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` """ from_address: String! """ the bech32 address of the fund receiver. + ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` """ to_address: String! """ the denomination and amount of fund sent (""). + ex) `1000000ugnot` """ amount: String! } @@ -125,10 +136,31 @@ type BankMsgSend { `MsgCall` is the method invocation tx message. """ type MsgCall { + """ + the bech32 address of the function caller. + ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` + """ caller: String! + + """ + the amount of funds to be deposited to the package, if any (""). + ex) `1000000ugnot` + """ send: String! + + """ + the gno package path. + """ pkg_path: String! + + """ + the function name being invoked. + """ func: String! + + """ + `args` are the arguments passed to the executed function. + """ args: [String!] } @@ -138,7 +170,8 @@ type MsgCall { """ type MsgAddPackage { """ - the package deployer. + the bech32 address of the package deployer. + ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` """ creator: String! @@ -149,6 +182,7 @@ type MsgAddPackage { """ the amount of funds to be deposited at deployment, if any (""). + ex) `1000000ugnot` """ deposit: String! } @@ -159,12 +193,14 @@ type MsgAddPackage { """ type MsgRun { """ - the bech32 address of the caller. + the bech32 address of the function caller. + ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` """ caller: String! """ the amount of funds to be deposited to the package, if any (""). + ex) `1000000ugnot` """ send: String! From 2f854735755db28a4dd825f2720c41a7ac625800 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Thu, 4 Apr 2024 18:49:16 +0900 Subject: [PATCH 18/25] fix: Fix lints --- serve/graph/model/transaction.go | 1 + 1 file changed, 1 insertion(+) diff --git a/serve/graph/model/transaction.go b/serve/graph/model/transaction.go index 28453805..77e80aff 100644 --- a/serve/graph/model/transaction.go +++ b/serve/graph/model/transaction.go @@ -269,6 +269,7 @@ func makeUnexpectedMessage(value std.Msg) UnexpectedMessage { Raw: "", } } + return UnexpectedMessage{ Raw: string(raw), } From 1ccd5be2af51b7c5f5b9f0dcf13191aa341c190d Mon Sep 17 00:00:00 2001 From: jinoosss Date: Thu, 4 Apr 2024 21:13:58 +0900 Subject: [PATCH 19/25] chore: Add descriptions for docs --- serve/graph/schema/filter/transaction_filter.graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serve/graph/schema/filter/transaction_filter.graphql b/serve/graph/schema/filter/transaction_filter.graphql index e047fb7b..72ee555b 100644 --- a/serve/graph/schema/filter/transaction_filter.graphql +++ b/serve/graph/schema/filter/transaction_filter.graphql @@ -63,7 +63,7 @@ input TransactionFilter { """ Transaction's message to filter Transactions. -`message` can be of type `BankMsgSend`, `MsgCall`, `MsgAddPackage`, `MsgRun`. +`TransactionMessageInput` can be configured as a filter with a transaction message's `router` and `type` and `parameters(bank / vm)`. """ input TransactionMessageInput { """ From bb12ca26f99575c693081ac8879021df2d817250 Mon Sep 17 00:00:00 2001 From: jinoosss Date: Thu, 4 Apr 2024 21:58:25 +0900 Subject: [PATCH 20/25] fix: Added descriptions to filter functions and made minor fixes --- serve/graph/block_filter.go | 3 ++ serve/graph/transaction_filter.go | 50 ++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/serve/graph/block_filter.go b/serve/graph/block_filter.go index e49b3062..36075216 100644 --- a/serve/graph/block_filter.go +++ b/serve/graph/block_filter.go @@ -6,6 +6,8 @@ import ( "github.com/gnolang/tx-indexer/serve/graph/model" ) +// `FilteredBlockBy` checks for conditions in BlockTime. +// By default, the condition is only checked if the input parameter exists. func FilteredBlockBy(block *model.Block, filter model.BlockFilter) bool { if block == nil { return false @@ -14,6 +16,7 @@ func FilteredBlockBy(block *model.Block, filter model.BlockFilter) bool { return filteredBlockByBlockTime(block, filter.FromTime, filter.ToTime) } +// `filteredBlockByBlockTime` checks block based on block time. func filteredBlockByBlockTime(block *model.Block, filterFromTime, filterToTime *time.Time) bool { fromTime := deref(filterFromTime) toTime := deref(filterToTime) diff --git a/serve/graph/transaction_filter.go b/serve/graph/transaction_filter.go index 363d6eb8..eaee6a67 100644 --- a/serve/graph/transaction_filter.go +++ b/serve/graph/transaction_filter.go @@ -7,6 +7,8 @@ import ( "github.com/gnolang/tx-indexer/serve/graph/model" ) +// `FilteredTransactionBy` checks for conditions in GasUsed, GasWanted, Memo, and Message. +// By default, the condition is only checked if the input parameter exists. func FilteredTransactionBy(tx *model.Transaction, filter model.TransactionFilter) bool { if !filteredTransactionByGasUsed(tx, filter.FromGasUsed, filter.ToGasUsed) { return false @@ -37,6 +39,8 @@ func FilteredTransactionBy(tx *model.Transaction, filter model.TransactionFilter return true } +// `filteredAmountBy` checks a token represented as a string() +// against a range of amount and a denomination. func filteredAmountBy(amountStr string, amountInput *model.AmountInput) bool { if amountInput == nil { return true @@ -47,14 +51,17 @@ func filteredAmountBy(amountStr string, amountInput *model.AmountInput) bool { return false } - if amountInput.Denomination != nil { + // If the input parameter for denomination is not used, all denominations are checked. + isAllDenomination := amountInput.Denomination == nil + if !isAllDenomination { if deref(amountInput.Denomination) == "" && coins.Empty() { return true } } for _, coin := range coins { - if amountInput.Denomination == nil || coin.Denom == deref(amountInput.Denomination) { + isSameDenomination := coin.Denom == deref(amountInput.Denomination) + if isAllDenomination || isSameDenomination { fromAmount := int64(deref(amountInput.From)) toAmount := int64(deref(amountInput.To)) @@ -71,30 +78,33 @@ func filteredAmountBy(amountStr string, amountInput *model.AmountInput) bool { return false } +// `filteredTransactionByGasUsed` checks transactions based on gasUsed. func filteredTransactionByGasUsed(tx *model.Transaction, filterFromGasUsed, filterToGasUsed *int) bool { + gasUsed := tx.GasUsed() fromGasUsed := deref(filterFromGasUsed) toGasUsed := deref(filterToGasUsed) - transactionGasUsed := tx.GasUsed() if toGasUsed == 0 { toGasUsed = math.MaxInt } - return transactionGasUsed >= fromGasUsed && transactionGasUsed <= toGasUsed + return gasUsed >= fromGasUsed && gasUsed <= toGasUsed } +// `filteredTransactionByGasWanted` checks transactions based on gasWanted. func filteredTransactionByGasWanted(tx *model.Transaction, filterFromGasWanted, filterToGasWanted *int) bool { + gasWanted := tx.GasWanted() fromGasWanted := deref(filterFromGasWanted) toGasWanted := deref(filterToGasWanted) - transactionGasUsed := tx.GasWanted() if toGasWanted == 0 { toGasWanted = math.MaxInt } - return transactionGasUsed >= fromGasWanted && transactionGasUsed <= toGasWanted + return gasWanted >= fromGasWanted && gasWanted <= toGasWanted } +// `filteredTransactionByMemo` checks transactions based on memo. func filteredTransactionByMemo(tx *model.Transaction, filterMemo *string) bool { if filterMemo == nil { return true @@ -103,6 +113,7 @@ func filteredTransactionByMemo(tx *model.Transaction, filterMemo *string) bool { return deref(filterMemo) == tx.Memo() } +// `filteredTransactionByMessages` checks transaction's messages. func filteredTransactionByMessages(tx *model.Transaction, messageInput *model.TransactionMessageInput) bool { messages := tx.Messages() for _, message := range messages { @@ -114,6 +125,7 @@ func filteredTransactionByMessages(tx *model.Transaction, messageInput *model.Tr return true } +// `filteredTransactionByMessageRoute` checks if the transaction message contains the route value. func filteredTransactionByMessageRoute(tx *model.Transaction, messageRoute *model.MessageRoute) bool { if messageRoute == nil { return true @@ -129,6 +141,7 @@ func filteredTransactionByMessageRoute(tx *model.Transaction, messageRoute *mode return false } +// `filteredTransactionByMessageType` checks if the transaction message contains the type value. func filteredTransactionByMessageType(tx *model.Transaction, messageType *model.MessageType) bool { if messageType == nil { return true @@ -144,6 +157,7 @@ func filteredTransactionByMessageType(tx *model.Transaction, messageType *model. return false } +// `filteredTransactionMessageBy` checks for conditions based on the transaction message type. func filteredTransactionMessageBy( tm *model.TransactionMessage, messageInput *model.TransactionMessageInput, @@ -165,31 +179,36 @@ func filteredTransactionMessageBy( if messageInput.VMParam == nil { return false } + default: + return false } switch tm.TypeURL { case model.MessageTypeSend.String(): - if !checkMessageOfBankMsgSend(tm.BankMsgSend(), messageInput.BankParam) { + if !filteredMessageOfBankMsgSendBy(tm.BankMsgSend(), messageInput.BankParam) { return false } case model.MessageTypeExec.String(): - if !checkByMessageOfMsgCall(tm.VMMsgCall(), messageInput.VMParam) { + if !filteredMessageOfMsgCallBy(tm.VMMsgCall(), messageInput.VMParam) { return false } case model.MessageTypeAddPackage.String(): - if !checkMessageOfMsgAddPackage(tm.VMAddPackage(), messageInput.VMParam) { + if !filteredMessageOfMsgAddPackageBy(tm.VMAddPackage(), messageInput.VMParam) { return false } case model.MessageTypeRun.String(): - if !checkMessageOfMsgRun(tm.VMMsgRun(), messageInput.VMParam) { + if !filteredMessageOfMsgRunBy(tm.VMMsgRun(), messageInput.VMParam) { return false } + default: + return false } return true } -func checkMessageOfBankMsgSend( +// `filteredMessageOfBankMsgSendBy` checks the conditions of a message of type BankMsgSend +func filteredMessageOfBankMsgSendBy( messageValue model.BankMsgSend, bankMessageInput *model.TransactionBankMessageInput, ) bool { @@ -213,7 +232,8 @@ func checkMessageOfBankMsgSend( return true } -func checkByMessageOfMsgCall( +// `filteredMessageOfMsgCallBy` checks the conditions of a message of type MsgCall +func filteredMessageOfMsgCallBy( messageValue model.MsgCall, vmMessageInput *model.TransactionVMMessageInput, ) bool { @@ -261,7 +281,8 @@ func checkByMessageOfMsgCall( return true } -func checkMessageOfMsgAddPackage( +// `filteredMessageOfMsgAddPackageBy` checks the conditions of a message of type MsgAddPackage +func filteredMessageOfMsgAddPackageBy( messageValue model.MsgAddPackage, vmMessageInput *model.TransactionVMMessageInput, ) bool { @@ -295,7 +316,8 @@ func checkMessageOfMsgAddPackage( return true } -func checkMessageOfMsgRun(messageValue model.MsgRun, vmMessageInput *model.TransactionVMMessageInput) bool { +// `filteredMessageOfMsgRunBy` checks the conditions of a message of type MsgRun +func filteredMessageOfMsgRunBy(messageValue model.MsgRun, vmMessageInput *model.TransactionVMMessageInput) bool { params := vmMessageInput if params == nil { return true From 03647cb0df5de5e5b657d832864a5849d7ea64dd Mon Sep 17 00:00:00 2001 From: jinoosss <112360739+jinoosss@users.noreply.github.com> Date: Mon, 8 Apr 2024 10:10:35 +0900 Subject: [PATCH 21/25] fix: Fix naming conventions Co-authored-by: Antonio Navarro Perez --- serve/graph/schema/filter/transaction_filter.graphql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/serve/graph/schema/filter/transaction_filter.graphql b/serve/graph/schema/filter/transaction_filter.graphql index 72ee555b..37515810 100644 --- a/serve/graph/schema/filter/transaction_filter.graphql +++ b/serve/graph/schema/filter/transaction_filter.graphql @@ -233,17 +233,17 @@ input MemPackageInput { """ the name of the package. """ - Name: String + name: String """ the gno path of the package. """ - Path: String + path: String """ the associated package gno source. """ - Files: [MemFileInput] + files: [MemFileInput] } """ From 1aec0e3386789f33b6c96b1f37e4f0f70b55b5f2 Mon Sep 17 00:00:00 2001 From: jinoosss <112360739+jinoosss@users.noreply.github.com> Date: Mon, 8 Apr 2024 10:10:52 +0900 Subject: [PATCH 22/25] fix: Fix naming conventions Co-authored-by: Antonio Navarro Perez --- serve/graph/schema/filter/transaction_filter.graphql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/serve/graph/schema/filter/transaction_filter.graphql b/serve/graph/schema/filter/transaction_filter.graphql index 37515810..d9b8aeb2 100644 --- a/serve/graph/schema/filter/transaction_filter.graphql +++ b/serve/graph/schema/filter/transaction_filter.graphql @@ -253,12 +253,12 @@ input MemFileInput { """ the name of the source file. """ - Name: String + name: String """ the content of the source file. """ - Body: String + body: String } """ From 6c8865f6a8ec8298391b7833579e47a909593017 Mon Sep 17 00:00:00 2001 From: jinoosss <112360739+jinoosss@users.noreply.github.com> Date: Mon, 8 Apr 2024 10:11:01 +0900 Subject: [PATCH 23/25] fix: Fix naming conventions Co-authored-by: Antonio Navarro Perez --- serve/graph/schema/types/transaction.graphql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/serve/graph/schema/types/transaction.graphql b/serve/graph/schema/types/transaction.graphql index f6aba4fe..4280989c 100644 --- a/serve/graph/schema/types/transaction.graphql +++ b/serve/graph/schema/types/transaction.graphql @@ -224,17 +224,17 @@ type MemPackage { """ the name of the package. """ - Name: String! + name: String! """ the gno path of the package. """ - Path: String! + path: String! """ the associated package gno source. """ - Files: [MemFile!] + files: [MemFile!] } """ From 36796cf1c5095007b33bb6eafc3ae9251eeac520 Mon Sep 17 00:00:00 2001 From: jinoosss <112360739+jinoosss@users.noreply.github.com> Date: Mon, 8 Apr 2024 10:11:08 +0900 Subject: [PATCH 24/25] fix: Fix naming conventions Co-authored-by: Antonio Navarro Perez --- serve/graph/schema/types/transaction.graphql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/serve/graph/schema/types/transaction.graphql b/serve/graph/schema/types/transaction.graphql index 4280989c..7dc2f291 100644 --- a/serve/graph/schema/types/transaction.graphql +++ b/serve/graph/schema/types/transaction.graphql @@ -244,12 +244,12 @@ type MemFile { """ the name of the source file. """ - Name: String! + name: String! """ the content of the source file. """ - Body: String! + body: String! } type TxFee { From d4437af8fd4455dd6479fdea5a3aaeeb85b8d55f Mon Sep 17 00:00:00 2001 From: jinoosss Date: Mon, 8 Apr 2024 10:54:40 +0900 Subject: [PATCH 25/25] feat: Update generated models --- serve/graph/generated.go | 116 ++++++++++++++++---------------- serve/graph/model/models_gen.go | 62 +++++++++++------ 2 files changed, 101 insertions(+), 77 deletions(-) diff --git a/serve/graph/generated.go b/serve/graph/generated.go index 29d7ab42..a72f4ee6 100644 --- a/serve/graph/generated.go +++ b/serve/graph/generated.go @@ -217,35 +217,35 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Block.Version(childComplexity), true - case "MemFile.Body": + case "MemFile.body": if e.complexity.MemFile.Body == nil { break } return e.complexity.MemFile.Body(childComplexity), true - case "MemFile.Name": + case "MemFile.name": if e.complexity.MemFile.Name == nil { break } return e.complexity.MemFile.Name(childComplexity), true - case "MemPackage.Files": + case "MemPackage.files": if e.complexity.MemPackage.Files == nil { break } return e.complexity.MemPackage.Files(childComplexity), true - case "MemPackage.Name": + case "MemPackage.name": if e.complexity.MemPackage.Name == nil { break } return e.complexity.MemPackage.Name(childComplexity), true - case "MemPackage.Path": + case "MemPackage.path": if e.complexity.MemPackage.Path == nil { break } @@ -1091,8 +1091,8 @@ func (ec *executionContext) fieldContext_Block_proposer_address_raw(ctx context. return fc, nil } -func (ec *executionContext) _MemFile_Name(ctx context.Context, field graphql.CollectedField, obj *model.MemFile) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_MemFile_Name(ctx, field) +func (ec *executionContext) _MemFile_name(ctx context.Context, field graphql.CollectedField, obj *model.MemFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemFile_name(ctx, field) if err != nil { return graphql.Null } @@ -1122,7 +1122,7 @@ func (ec *executionContext) _MemFile_Name(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_MemFile_Name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemFile_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MemFile", Field: field, @@ -1135,8 +1135,8 @@ func (ec *executionContext) fieldContext_MemFile_Name(ctx context.Context, field return fc, nil } -func (ec *executionContext) _MemFile_Body(ctx context.Context, field graphql.CollectedField, obj *model.MemFile) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_MemFile_Body(ctx, field) +func (ec *executionContext) _MemFile_body(ctx context.Context, field graphql.CollectedField, obj *model.MemFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemFile_body(ctx, field) if err != nil { return graphql.Null } @@ -1166,7 +1166,7 @@ func (ec *executionContext) _MemFile_Body(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_MemFile_Body(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemFile_body(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MemFile", Field: field, @@ -1179,8 +1179,8 @@ func (ec *executionContext) fieldContext_MemFile_Body(ctx context.Context, field return fc, nil } -func (ec *executionContext) _MemPackage_Name(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_MemPackage_Name(ctx, field) +func (ec *executionContext) _MemPackage_name(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemPackage_name(ctx, field) if err != nil { return graphql.Null } @@ -1210,7 +1210,7 @@ func (ec *executionContext) _MemPackage_Name(ctx context.Context, field graphql. return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_MemPackage_Name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemPackage_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MemPackage", Field: field, @@ -1223,8 +1223,8 @@ func (ec *executionContext) fieldContext_MemPackage_Name(ctx context.Context, fi return fc, nil } -func (ec *executionContext) _MemPackage_Path(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_MemPackage_Path(ctx, field) +func (ec *executionContext) _MemPackage_path(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemPackage_path(ctx, field) if err != nil { return graphql.Null } @@ -1254,7 +1254,7 @@ func (ec *executionContext) _MemPackage_Path(ctx context.Context, field graphql. return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_MemPackage_Path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemPackage_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MemPackage", Field: field, @@ -1267,8 +1267,8 @@ func (ec *executionContext) fieldContext_MemPackage_Path(ctx context.Context, fi return fc, nil } -func (ec *executionContext) _MemPackage_Files(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_MemPackage_Files(ctx, field) +func (ec *executionContext) _MemPackage_files(ctx context.Context, field graphql.CollectedField, obj *model.MemPackage) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MemPackage_files(ctx, field) if err != nil { return graphql.Null } @@ -1295,7 +1295,7 @@ func (ec *executionContext) _MemPackage_Files(ctx context.Context, field graphql return ec.marshalOMemFile2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_MemPackage_Files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_MemPackage_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MemPackage", Field: field, @@ -1303,10 +1303,10 @@ func (ec *executionContext) fieldContext_MemPackage_Files(ctx context.Context, f IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "Name": - return ec.fieldContext_MemFile_Name(ctx, field) - case "Body": - return ec.fieldContext_MemFile_Body(ctx, field) + case "name": + return ec.fieldContext_MemFile_name(ctx, field) + case "body": + return ec.fieldContext_MemFile_body(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type MemFile", field.Name) }, @@ -1397,12 +1397,12 @@ func (ec *executionContext) fieldContext_MsgAddPackage_package(ctx context.Conte IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "Name": - return ec.fieldContext_MemPackage_Name(ctx, field) - case "Path": - return ec.fieldContext_MemPackage_Path(ctx, field) - case "Files": - return ec.fieldContext_MemPackage_Files(ctx, field) + case "name": + return ec.fieldContext_MemPackage_name(ctx, field) + case "path": + return ec.fieldContext_MemPackage_path(ctx, field) + case "files": + return ec.fieldContext_MemPackage_files(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type MemPackage", field.Name) }, @@ -1798,12 +1798,12 @@ func (ec *executionContext) fieldContext_MsgRun_package(ctx context.Context, fie IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "Name": - return ec.fieldContext_MemPackage_Name(ctx, field) - case "Path": - return ec.fieldContext_MemPackage_Path(ctx, field) - case "Files": - return ec.fieldContext_MemPackage_Files(ctx, field) + case "name": + return ec.fieldContext_MemPackage_name(ctx, field) + case "path": + return ec.fieldContext_MemPackage_path(ctx, field) + case "files": + return ec.fieldContext_MemPackage_files(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type MemPackage", field.Name) }, @@ -4820,22 +4820,22 @@ func (ec *executionContext) unmarshalInputMemFileInput(ctx context.Context, obj asMap[k] = v } - fieldsInOrder := [...]string{"Name", "Body"} + fieldsInOrder := [...]string{"name", "body"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "Name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Name = data - case "Body": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Body")) + case "body": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("body")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err @@ -4854,29 +4854,29 @@ func (ec *executionContext) unmarshalInputMemPackageInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"Name", "Path", "Files"} + fieldsInOrder := [...]string{"name", "path", "files"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "Name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Name = data - case "Path": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Path")) + case "path": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("path")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Path = data - case "Files": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Files")) + case "files": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("files")) data, err := ec.unmarshalOMemFileInput2ᚕᚖgithubᚗcomᚋgnolangᚋtxᚑindexerᚋserveᚋgraphᚋmodelᚐMemFileInput(ctx, v) if err != nil { return it, err @@ -5409,13 +5409,13 @@ func (ec *executionContext) _MemFile(ctx context.Context, sel ast.SelectionSet, switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MemFile") - case "Name": - out.Values[i] = ec._MemFile_Name(ctx, field, obj) + case "name": + out.Values[i] = ec._MemFile_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "Body": - out.Values[i] = ec._MemFile_Body(ctx, field, obj) + case "body": + out.Values[i] = ec._MemFile_body(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -5453,18 +5453,18 @@ func (ec *executionContext) _MemPackage(ctx context.Context, sel ast.SelectionSe switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MemPackage") - case "Name": - out.Values[i] = ec._MemPackage_Name(ctx, field, obj) + case "name": + out.Values[i] = ec._MemPackage_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "Path": - out.Values[i] = ec._MemPackage_Path(ctx, field, obj) + case "path": + out.Values[i] = ec._MemPackage_path(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "Files": - out.Values[i] = ec._MemPackage_Files(ctx, field, obj) + case "files": + out.Values[i] = ec._MemPackage_files(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } diff --git a/serve/graph/model/models_gen.go b/serve/graph/model/models_gen.go index 9caca6e1..20bd7425 100644 --- a/serve/graph/model/models_gen.go +++ b/serve/graph/model/models_gen.go @@ -28,10 +28,13 @@ type AmountInput struct { // `BankMsgSend` is the fund transfer tx message. type BankMsgSend struct { // the bech32 address of the fund sender. + // ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` FromAddress string `json:"from_address"` // the bech32 address of the fund receiver. + // ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` ToAddress string `json:"to_address"` // the denomination and amount of fund sent (""). + // ex) `1000000ugnot` Amount string `json:"amount"` } @@ -67,47 +70,49 @@ type BlockFilter struct { // `MemFile` is the metadata information tied to a single gno package / realm file type MemFile struct { // the name of the source file. - Name string `json:"Name"` + Name string `json:"name"` // the content of the source file. - Body string `json:"Body"` + Body string `json:"body"` } // `MemFileInput` is the metadata information tied to a single gno package / realm file. type MemFileInput struct { // the name of the source file. - Name *string `json:"Name,omitempty"` + Name *string `json:"name,omitempty"` // the content of the source file. - Body *string `json:"Body,omitempty"` + Body *string `json:"body,omitempty"` } // `MemPackage` is the metadata information tied to package / realm deployment. type MemPackage struct { // the name of the package. - Name string `json:"Name"` + Name string `json:"name"` // the gno path of the package. - Path string `json:"Path"` + Path string `json:"path"` // the associated package gno source. - Files []*MemFile `json:"Files,omitempty"` + Files []*MemFile `json:"files,omitempty"` } // `MemPackageInput` represents a package stored in memory. type MemPackageInput struct { // the name of the package. - Name *string `json:"Name,omitempty"` + Name *string `json:"name,omitempty"` // the gno path of the package. - Path *string `json:"Path,omitempty"` + Path *string `json:"path,omitempty"` // the associated package gno source. - Files []*MemFileInput `json:"Files,omitempty"` + Files []*MemFileInput `json:"files,omitempty"` } // `MsgAddPackage` is a message with a message router of `vm` and a message type of `add_package`. // `MsgAddPackage` is the package deployment tx message. type MsgAddPackage struct { - // the package deployer. + // the bech32 address of the package deployer. + // ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` Creator string `json:"creator"` // the package being deployed. Package *MemPackage `json:"package"` // the amount of funds to be deposited at deployment, if any (""). + // ex) `1000000ugnot` Deposit string `json:"deposit"` } @@ -129,11 +134,18 @@ type MsgAddPackageInput struct { // `MsgCall` is a message with a message router of `vm` and a message type of `exec`. // `MsgCall` is the method invocation tx message. type MsgCall struct { - Caller string `json:"caller"` - Send string `json:"send"` - PkgPath string `json:"pkg_path"` - Func string `json:"func"` - Args []string `json:"args,omitempty"` + // the bech32 address of the function caller. + // ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` + Caller string `json:"caller"` + // the amount of funds to be deposited to the package, if any (""). + // ex) `1000000ugnot` + Send string `json:"send"` + // the gno package path. + PkgPath string `json:"pkg_path"` + // the function name being invoked. + Func string `json:"func"` + // `args` are the arguments passed to the executed function. + Args []string `json:"args,omitempty"` } func (MsgCall) IsMessageValue() {} @@ -161,9 +173,11 @@ type MsgCallInput struct { // `MsgRun` is a message with a message router of `vm` and a message type of `run`. // `MsgRun is the execute arbitrary Gno code tx message`. type MsgRun struct { - // the bech32 address of the caller. + // the bech32 address of the function caller. + // ex) `g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` Caller string `json:"caller"` // the amount of funds to be deposited to the package, if any (""). + // ex) `1000000ugnot` Send string `json:"send"` // the package being executed. Package *MemPackage `json:"package"` @@ -220,16 +234,22 @@ type TransactionFilter struct { // Hash from Transaction content in base64 encoding. If this filter is used, any other filter will be ignored. Hash *string `json:"hash,omitempty"` // Transaction's message to filter Transactions. + // `message` can be configured as a filter with a transaction message's `router` and `type` and `parameters(bank / vm)`. Message *TransactionMessageInput `json:"message,omitempty"` - // `memo` value to filter Transaction's memo. + // `memo` are string information stored within a transaction. + // `memo` can be utilized to find or distinguish transactions. + // For example, when trading a specific exchange, you would utilize the memo field of the transaction. Memo *string `json:"memo,omitempty"` } -// Input for filters by transaction message. +// Transaction's message to filter Transactions. +// `TransactionMessageInput` can be configured as a filter with a transaction message's `router` and `type` and `parameters(bank / vm)`. type TransactionMessageInput struct { // The type of transaction message. + // The value of `typeUrl` can be `send`, `exec`, `add_package`, `run`. TypeURL *MessageType `json:"type_url,omitempty"` // The route of transaction message. + // The value of `route` can be `bank`, `vm`. Route *MessageRoute `json:"route,omitempty"` // `TransactionBankMessageInput` represents input parameters required when the message router is `bank`. BankParam *TransactionBankMessageInput `json:"bank_param,omitempty"` @@ -261,6 +281,8 @@ type UnexpectedMessage struct { func (UnexpectedMessage) IsMessageValue() {} +// `MessageRoute` is route type of the transactional message. +// `MessageRoute` has the values of vm and bank. type MessageRoute string const ( @@ -302,6 +324,8 @@ func (e MessageRoute) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +// `MessageType` is message type of the transaction. +// `MessageType` has the values `send`, `exec`, `add_package`, and `run`. type MessageType string const (