gql

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: LGPL-3.0 Imports: 31 Imported by: 0

README

Cerc-io laconic gql

Browser : http://localhost:9473 for gql

Start server

./build/laconicd start --gql-playground --gql-server

Basic node status:

{
  getStatus {
    version
    node {
      id
      network
      moniker
    }
    sync {
      latest_block_height
      catching_up
    }
    num_peers
    peers {
      is_outbound
      remote_ip
    }
    disk_usage
  }
}

Full node status:

{
  getStatus {
    version
    node {
      id
      network
      moniker
    }
    sync {
      latest_block_hash
      latest_block_time
      latest_block_height
      catching_up
    }
    validator {
      address
      voting_power
      proposer_priority
    }
    validators {
      address
      voting_power
      proposer_priority
    }
    num_peers
    peers {
      node {
        id
        network
        moniker
      }
      is_outbound
      remote_ip
    }
    disk_usage
  }
}

Get records by IDs.

{
  getRecordsByIds(ids: ["QmYDtNCKtTu6u6jaHaFAC5PWZXcj7fAmry6NoWwMaixFHz"]) {
    id
    names
    bondId
    createTime
    expiryTime
    owners
    attributes {
      key
      value {
        string
      }
    }
  }
}

Query records.

{
  queryRecords(attributes: [{ key: "type", value: { string: "crn:bot" } }]) {
    id
    names
    bondId
    createTime
    expiryTime
    owners
    attributes {
      key
      value {
        string
      }
    }
  }
}

Get account details:

{
  getAccounts(addresses: ["cosmos1wh8vvd0ymc5nt37h29z8kk2g2ays45ct2qu094"]) {
    address
    pubKey
    number
    sequence
    balance {
      type
      quantity
    }
  }
}

Query bonds:

{
  queryBonds(
    attributes: [
      {
        key: "owner"
        value: { string: "cosmos1wh8vvd0ymc5nt37h29z8kk2g2ays45ct2qu094" }
      }
    ]
  ) {
    id
    owner
    balance {
      type
      quantity
    }
  }
}

Get bonds by IDs.

{
  getBondsByIds(
    ids: [
      "1c2b677cb2a27c88cc6bf8acf675c94b69051125b40c4fd073153b10f046dd87"
      "c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440"
    ]
  ) {
    id
    owner
    balance {
      type
      quantity
    }
  }
}

Query Bonds by Owner

{
  queryBondsByOwner(
    ownerAddresses: ["ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk"]
  ) {
    owner
    bonds {
      id
      owner
      balance {
        type
        quantity
      }
    }
  }
}

Query auctions by ids

{
  getAuctionsByIds(
    ids: ["be98f2073c246194276554eefdb4c95b682a35a0f06fbe619a6da57c10c93e90"]
  ) {
    id
    ownerAddress
    createTime
    minimumBid {
      type
      quantity
    }
    commitFee {
      type
      quantity
    }
    commitsEndTime
    revealFee {
      type
      quantity
    }
    revealsEndTime
    winnerBid {
      type
      quantity
    }
    winnerPrice {
      type
      quantity
    }
    winnerAddress
    bids {
      bidderAddress
      commitHash
      commitTime
      commitFee {
        type
        quantity
      }
      revealFee {
        type
        quantity
      }
      revealTime
      bidAmount {
        type
        quantity
      }
      status
    }
  }
}

LookUp Authorities

{
  lookupAuthorities(names: []) {
    ownerAddress
    ownerAddress
    height
    bondId
    status
    expiryTime
    auction {
      id
      ownerAddress
      createTime
      minimumBid {
        type
        quantity
      }
      commitFee {
        type
        quantity
      }
      commitsEndTime
      revealFee {
        type
        quantity
      }
      revealsEndTime
      winnerBid {
        type
        quantity
      }
      winnerPrice {
        type
        quantity
      }
      winnerAddress
      bids {
        bidderAddress
        commitHash
        commitTime
        commitFee {
          type
          quantity
        }
        revealFee {
          type
          quantity
        }
        revealTime
        bidAmount {
          type
          quantity
        }
        status
      }
    }
  }
}

LookUp Names

{
  lookupNames(names: ["crn://hello/test"]) {
    latest {
      id
      height
    }
    history {
      id
      height
    }
  }
}

Resolve Names

{
  resolveNames(names: ["asd"]) {
    id
    names
    bondId
    createTime
    expiryTime
    owners
    attributes {
      key
      value {
        string
      }
    }
  }
}

Documentation

Index

Constants

View Source
const BondIDAttributeName = "bondId"

BondIDAttributeName denotes the record bond ID.

View Source
const DefaultLogNumLines = 50

DefaultLogNumLines is the number of log lines to tail by default.

View Source
const ExpiryTimeAttributeName = "expiryTime"

ExpiryTimeAttributeName denotes the record expiry time.

View Source
const MaxLogNumLines = 1000

MaxLogNumLines is the max number of log lines that can be tailed.

View Source
const OwnerAttributeName = "owner"

OwnerAttributeName denotes the owner attribute name for a bond.

View Source
const RegistryVersion = "0.3.0"

RegistryVersion is the registry API version.

Variables

View Source
var NodeDataPath = os.ExpandEnv("$HOME/.laconicd/data")

NodeDataPath is the path to the laconicd data folder.

Functions

func GetDiskUsage

func GetDiskUsage(dirPath string) (string, error)

GetDiskUsage returns disk usage for the given path.

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func PlaygroundHandler added in v0.7.0

func PlaygroundHandler(apiURL string) http.HandlerFunc

func Server

func Server(ctx client.Context)

Server configures and starts the GQL server.

Types

type Account

type Account struct {
	Address  string  `json:"address"`
	PubKey   *string `json:"pubKey"`
	Number   string  `json:"number"`
	Sequence string  `json:"sequence"`
	Balance  []*Coin `json:"balance"`
}

type Auction

type Auction struct {
	ID             string        `json:"id"`
	Status         string        `json:"status"`
	OwnerAddress   string        `json:"ownerAddress"`
	CreateTime     string        `json:"createTime"`
	CommitsEndTime string        `json:"commitsEndTime"`
	RevealsEndTime string        `json:"revealsEndTime"`
	CommitFee      *Coin         `json:"commitFee"`
	RevealFee      *Coin         `json:"revealFee"`
	MinimumBid     *Coin         `json:"minimumBid"`
	WinnerAddress  string        `json:"winnerAddress"`
	WinnerBid      *Coin         `json:"winnerBid"`
	WinnerPrice    *Coin         `json:"winnerPrice"`
	Bids           []*AuctionBid `json:"bids"`
}

func GetGQLAuction

func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Auction, error)

type AuctionBid

type AuctionBid struct {
	BidderAddress string `json:"bidderAddress"`
	Status        string `json:"status"`
	CommitHash    string `json:"commitHash"`
	CommitTime    string `json:"commitTime"`
	CommitFee     *Coin  `json:"commitFee"`
	RevealTime    string `json:"revealTime"`
	RevealFee     *Coin  `json:"revealFee"`
	BidAmount     *Coin  `json:"bidAmount"`
}

type AuthorityRecord

type AuthorityRecord struct {
	OwnerAddress   string   `json:"ownerAddress"`
	OwnerPublicKey string   `json:"ownerPublicKey"`
	Height         string   `json:"height"`
	Status         string   `json:"status"`
	BondID         string   `json:"bondId"`
	ExpiryTime     string   `json:"expiryTime"`
	Auction        *Auction `json:"auction"`
}

func GetGQLNameAuthorityRecord

func GetGQLNameAuthorityRecord(record *registrytypes.NameAuthority) (*AuthorityRecord, error)

type Bond

type Bond struct {
	ID      string  `json:"id"`
	Owner   string  `json:"owner"`
	Balance []*Coin `json:"balance"`
}

type Coin

type Coin struct {
	Type     string `json:"type"`
	Quantity string `json:"quantity"`
}

type ComplexityRoot

type ComplexityRoot struct {
	Account struct {
		Address  func(childComplexity int) int
		Balance  func(childComplexity int) int
		Number   func(childComplexity int) int
		PubKey   func(childComplexity int) int
		Sequence func(childComplexity int) int
	}

	Auction struct {
		Bids           func(childComplexity int) int
		CommitFee      func(childComplexity int) int
		CommitsEndTime func(childComplexity int) int
		CreateTime     func(childComplexity int) int
		ID             func(childComplexity int) int
		MinimumBid     func(childComplexity int) int
		OwnerAddress   func(childComplexity int) int
		RevealFee      func(childComplexity int) int
		RevealsEndTime func(childComplexity int) int
		Status         func(childComplexity int) int
		WinnerAddress  func(childComplexity int) int
		WinnerBid      func(childComplexity int) int
		WinnerPrice    func(childComplexity int) int
	}

	AuctionBid struct {
		BidAmount     func(childComplexity int) int
		BidderAddress func(childComplexity int) int
		CommitFee     func(childComplexity int) int
		CommitHash    func(childComplexity int) int
		CommitTime    func(childComplexity int) int
		RevealFee     func(childComplexity int) int
		RevealTime    func(childComplexity int) int
		Status        func(childComplexity int) int
	}

	AuthorityRecord struct {
		Auction        func(childComplexity int) int
		BondID         func(childComplexity int) int
		ExpiryTime     func(childComplexity int) int
		Height         func(childComplexity int) int
		OwnerAddress   func(childComplexity int) int
		OwnerPublicKey func(childComplexity int) int
		Status         func(childComplexity int) int
	}

	Bond struct {
		Balance func(childComplexity int) int
		ID      func(childComplexity int) int
		Owner   func(childComplexity int) int
	}

	Coin struct {
		Quantity func(childComplexity int) int
		Type     func(childComplexity int) int
	}

	KeyValue struct {
		Key   func(childComplexity int) int
		Value func(childComplexity int) int
	}

	NameRecord struct {
		History func(childComplexity int) int
		Latest  func(childComplexity int) int
	}

	NameRecordEntry struct {
		Height func(childComplexity int) int
		ID     func(childComplexity int) int
	}

	NodeInfo struct {
		ID      func(childComplexity int) int
		Moniker func(childComplexity int) int
		Network func(childComplexity int) int
	}

	OwnerBonds struct {
		Bonds func(childComplexity int) int
		Owner func(childComplexity int) int
	}

	PeerInfo struct {
		IsOutbound func(childComplexity int) int
		Node       func(childComplexity int) int
		RemoteIP   func(childComplexity int) int
	}

	Query struct {
		GetAccounts       func(childComplexity int, addresses []string) int
		GetAuctionsByIds  func(childComplexity int, ids []string) int
		GetBondsByIds     func(childComplexity int, ids []string) int
		GetRecordsByIds   func(childComplexity int, ids []string) int
		GetStatus         func(childComplexity int) int
		LookupAuthorities func(childComplexity int, names []string) int
		LookupNames       func(childComplexity int, names []string) int
		QueryBonds        func(childComplexity int, attributes []*KeyValueInput) int
		QueryBondsByOwner func(childComplexity int, ownerAddresses []string) int
		QueryRecords      func(childComplexity int, attributes []*KeyValueInput, all *bool) int
		ResolveNames      func(childComplexity int, names []string) int
	}

	Record struct {
		Attributes func(childComplexity int) int
		BondID     func(childComplexity int) int
		CreateTime func(childComplexity int) int
		ExpiryTime func(childComplexity int) int
		ID         func(childComplexity int) int
		Names      func(childComplexity int) int
		Owners     func(childComplexity int) int
		References func(childComplexity int) int
	}

	Reference struct {
		ID func(childComplexity int) int
	}

	Status struct {
		DiskUsage  func(childComplexity int) int
		Node       func(childComplexity int) int
		NumPeers   func(childComplexity int) int
		Peers      func(childComplexity int) int
		Sync       func(childComplexity int) int
		Validator  func(childComplexity int) int
		Validators func(childComplexity int) int
		Version    func(childComplexity int) int
	}

	SyncInfo struct {
		CatchingUp        func(childComplexity int) int
		LatestBlockHash   func(childComplexity int) int
		LatestBlockHeight func(childComplexity int) int
		LatestBlockTime   func(childComplexity int) int
	}

	ValidatorInfo struct {
		Address          func(childComplexity int) int
		ProposerPriority func(childComplexity int) int
		VotingPower      func(childComplexity int) int
	}

	Value struct {
		Boolean   func(childComplexity int) int
		Float     func(childComplexity int) int
		Int       func(childComplexity int) int
		JSON      func(childComplexity int) int
		Null      func(childComplexity int) int
		Reference func(childComplexity int) int
		String    func(childComplexity int) int
		Values    func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
}

type KeyValue

type KeyValue struct {
	Key   string `json:"key"`
	Value *Value `json:"value"`
}

type KeyValueInput

type KeyValueInput struct {
	Key   string      `json:"key"`
	Value *ValueInput `json:"value"`
}

type NameRecord

type NameRecord struct {
	Latest  *NameRecordEntry   `json:"latest"`
	History []*NameRecordEntry `json:"history"`
}

type NameRecordEntry

type NameRecordEntry struct {
	ID     string `json:"id"`
	Height string `json:"height"`
}

type NodeInfo

type NodeInfo struct {
	ID      string `json:"id"`
	Network string `json:"network"`
	Moniker string `json:"moniker"`
}

type OwnerBonds

type OwnerBonds struct {
	Owner string  `json:"owner"`
	Bonds []*Bond `json:"bonds"`
}

type PeerInfo

type PeerInfo struct {
	Node       *NodeInfo `json:"node"`
	IsOutbound bool      `json:"is_outbound"`
	RemoteIP   string    `json:"remote_ip"`
}

type QueryResolver

type QueryResolver interface {
	GetStatus(ctx context.Context) (*Status, error)
	GetAccounts(ctx context.Context, addresses []string) ([]*Account, error)
	GetBondsByIds(ctx context.Context, ids []string) ([]*Bond, error)
	QueryBonds(ctx context.Context, attributes []*KeyValueInput) ([]*Bond, error)
	QueryBondsByOwner(ctx context.Context, ownerAddresses []string) ([]*OwnerBonds, error)
	GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error)
	QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool) ([]*Record, error)
	LookupAuthorities(ctx context.Context, names []string) ([]*AuthorityRecord, error)
	LookupNames(ctx context.Context, names []string) ([]*NameRecord, error)
	ResolveNames(ctx context.Context, names []string) ([]*Record, error)
	GetAuctionsByIds(ctx context.Context, ids []string) ([]*Auction, error)
}

type Record

type Record struct {
	ID         string      `json:"id"`
	Names      []string    `json:"names"`
	BondID     string      `json:"bondId"`
	CreateTime string      `json:"createTime"`
	ExpiryTime string      `json:"expiryTime"`
	Owners     []string    `json:"owners"`
	Attributes []*KeyValue `json:"attributes"`
	References []*Record   `json:"references"`
}

type Reference

type Reference struct {
	ID string `json:"id"`
}

type ReferenceInput

type ReferenceInput struct {
	ID string `json:"id"`
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query is the entry point to query execution.

type ResolverRoot

type ResolverRoot interface {
	Query() QueryResolver
}

type Status

type Status struct {
	Version    string           `json:"version"`
	Node       *NodeInfo        `json:"node"`
	Sync       *SyncInfo        `json:"sync"`
	Validator  *ValidatorInfo   `json:"validator"`
	Validators []*ValidatorInfo `json:"validators"`
	NumPeers   string           `json:"num_peers"`
	Peers      []*PeerInfo      `json:"peers"`
	DiskUsage  string           `json:"disk_usage"`
}

type SyncInfo

type SyncInfo struct {
	LatestBlockHash   string `json:"latest_block_hash"`
	LatestBlockHeight string `json:"latest_block_height"`
	LatestBlockTime   string `json:"latest_block_time"`
	CatchingUp        bool   `json:"catching_up"`
}

type ValidatorInfo

type ValidatorInfo struct {
	Address          string  `json:"address"`
	VotingPower      string  `json:"voting_power"`
	ProposerPriority *string `json:"proposer_priority"`
}

type Value

type Value struct {
	Null      *bool      `json:"null"`
	Int       *int       `json:"int"`
	Float     *float64   `json:"float"`
	String    *string    `json:"string"`
	Boolean   *bool      `json:"boolean"`
	JSON      *string    `json:"json"`
	Reference *Reference `json:"reference"`
	Values    []*Value   `json:"values"`
}

type ValueInput

type ValueInput struct {
	Null      *bool           `json:"null"`
	Int       *int            `json:"int"`
	Float     *float64        `json:"float"`
	String    *string         `json:"string"`
	Boolean   *bool           `json:"boolean"`
	Reference *ReferenceInput `json:"reference"`
	Values    []*ValueInput   `json:"values"`
}

Jump to

Keyboard shortcuts

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