query

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Block = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Block",
		Fields: graphql.Fields{
			"header": &graphql.Field{
				Type: Header,
			},
			"transactions": &graphql.Field{
				Type:    graphql.NewList(Transaction),
				Resolve: resolveTxs,
			},
		},
	},
)

Block is the graphql object representing blocks.

View Source
var Header = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Header",
		Fields: graphql.Fields{
			"height": &graphql.Field{
				Type: graphql.Int,
			},
			"hash": &graphql.Field{
				Type: Hex,
			},
			"version": &graphql.Field{
				Type: graphql.String,
			},
			"prevblockhash": &graphql.Field{
				Type: Hex,
			},
			"statehash": &graphql.Field{
				Type: Hex,
			},
			"seed": &graphql.Field{
				Type: Hex,
			},
			"txroot": &graphql.Field{
				Type: Hex,
			},
			"timestamp": &graphql.Field{
				Type: UnixTimestamp,
			},
			"reward": &graphql.Field{
				Type:    graphql.Float,
				Resolve: resolveReward,
			},
			"feespaid": &graphql.Field{
				Type:    graphql.Float,
				Resolve: resolveFee,
			},
		},
	},
)

Header is the graphql object representing block header.

View Source
var Hex = graphql.NewScalar(graphql.ScalarConfig{
	Name:        "Hex",
	Description: "Hex scalar type represents a byte array",

	Serialize: func(value interface{}) interface{} {
		switch value := value.(type) {
		case []byte:
			return hex.EncodeToString(value)
		default:
			return nil
		}
	},

	ParseValue: func(value interface{}) interface{} {
		switch value := value.(type) {
		case string:
			bytes, _ := hex.DecodeString(value)
			return bytes
		default:
			return nil
		}
	},

	ParseLiteral: func(valueAST ast.Value) interface{} {

		return nil
	},
})

Hex is the graphql object representing a hex scalar.

View Source
var Input = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Input",
		Fields: graphql.Fields{
			"keyimage": &graphql.Field{
				Type: Hex,
			},
		},
	},
)

Input is the graphql object representing input.

View Source
var Output = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Output",
		Fields: graphql.Fields{
			"pubkey": &graphql.Field{
				Type: Hex,
			},
		},
	},
)

Output is the graphql object representing output.

View Source
var Transaction = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Transaction",
		Fields: graphql.Fields{
			"txid": &graphql.Field{
				Type: Hex,
			},
			"txtype": &graphql.Field{
				Type: graphql.String,
			},
			"blockhash": &graphql.Field{
				Type: Hex,
			},
			"blocktimestamp": &graphql.Field{
				Type: UnixTimestamp,
			},
			"output": &graphql.Field{
				Type: graphql.NewList(Output),
			},
			"input": &graphql.Field{
				Type: graphql.NewList(Input),
			},
			"score": &graphql.Field{
				Type: Hex,
			},
			"size": &graphql.Field{
				Type: graphql.Int,
			},
			"gaslimit": &graphql.Field{
				Type: graphql.Float,
			},
			"gasprice": &graphql.Field{
				Type: graphql.Int,
			},
			"gasspent": &graphql.Field{
				Type: graphql.Float,
			},
			"json": &graphql.Field{
				Type: graphql.String,
			},
			"txerror": &graphql.Field{
				Type: graphql.String,
			},
		},
	},
)

Transaction is the graphql object representing transactions.

View Source
var UnixTimestamp = graphql.NewScalar(graphql.ScalarConfig{
	Name:        "UnixTimestamp",
	Description: "UnixTimestamp scalar type represents a unix time field",

	Serialize: func(value interface{}) interface{} {
		switch value := value.(type) {
		case int64:
			tm := time.Unix(value, 0)
			return tm.String()
		default:
			return nil
		}
	},

	ParseValue: func(value interface{}) interface{} {

		return nil
	},

	ParseLiteral: func(valueAST ast.Value) interface{} {

		return nil
	},
})

UnixTimestamp the one and only.

Functions

This section is empty.

Types

type Root

type Root struct {
	Query *graphql.Object
}

Root represents the root of the graphql object.

func NewRoot

func NewRoot(rpcBus *rpcbus.RPCBus) *Root

NewRoot returns a Root with blocks, transactions and mempool setup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL