query

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

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

		return nil
	},

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

		return nil
	},
})

Base64 is the graphql object representing a base64 scalar.

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 ContractInfo = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "ContractInfo",
		Fields: graphql.Fields{
			"method": &graphql.Field{
				Type: graphql.String,
			},
			"contract": &graphql.Field{
				Type: Hex,
			},
		},
	},
)

ContractInfo is the graphql object representing Intercontract Call.

View Source
var Header = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Header",
		Fields: graphql.Fields{
			"height": &graphql.Field{
				Type: graphql.Float,
			},
			"gaslimit": &graphql.Field{
				Type: graphql.Float,
			},
			"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,
			},
			"generatorblspubkey": &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,
			},
			"step": &graphql.Field{
				Type:    graphql.Int,
				Resolve: resolveStep,
			},
		},
	},
)

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 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,
			},
			"blockheight": &graphql.Field{
				Type: graphql.Float,
			},
			"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,
			},
			"contractinfo": &graphql.Field{
				Type: ContractInfo,
			},
			"raw": &graphql.Field{
				Type: Base64,
			},
		},
	},
)

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