kugo

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 14 Imported by: 3

README

Kugo

Licence

Kugo is a golang client library for interacting with Kupo, a chain-indexer for Cardano.

This is a pre-release package: until we release v1.0.0, the interface may change as we identify the optimal usage patterns.

QuickStart

Getting started

$ go get github.com/SundaeSwap-finance/kugo


ctx := context.Background()
k := kugo.New(WithEndpoint("http://localhost:1442"))

matches, err := k.Matches(ctx,
    OnlyUnspent(),
    Address("addr1vyc29pvl2uyzqt8nwxrcxnf558ffm27u3d9calxn8tdudjgz4xq9p"),
)
if err != nil {
    return fmt.Errorf("failed to fetch matches: %w", err)
}

How to use

We don't yet have our own documentation set up, but the code is fairly simple to follow.

We currently support three methods:

  • .Matches(...): query UTXOs that match various supported criteria
  • .Patterns(...): query what patterns are currently being indexed by Kupo
  • .Checkpoints(...): query "checkpoints" (block/slot combinations) that kupo is aware of

For more information, please refer to the Kupo documentation.

Contributing

Want to contribute? See CONTRIBUTING.md to know how.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckpointsFilter

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

func BySlot

func BySlot(slot uint64) CheckpointsFilter

func Latest

func Latest() CheckpointsFilter

func Recent

func Recent() CheckpointsFilter

Return a recent sampling of kupo checkpoints NOTE: equivalent to providing no filters, but useful for documenting your purpose

type Client

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

func New

func New(opts ...Option) *Client

New returns a new Client

func (*Client) Checkpoints

func (c *Client) Checkpoints(ctx context.Context, filters ...CheckpointsFilter) (points []Point, err error)

func (*Client) Datum added in v0.1.2

func (c *Client) Datum(ctx context.Context, datumHash string) (datum string, err error)

func (*Client) Matches

func (c *Client) Matches(ctx context.Context, filters ...MatchesFilter) (matches []Match, err error)

func (*Client) Metadata added in v0.1.3

func (c *Client) Metadata(ctx context.Context, slotNo int, txId string) (metadatum []Metadatum, err error)

func (*Client) Patterns

func (c *Client) Patterns(ctx context.Context) (matches []string, err error)

func (*Client) Script added in v1.1.0

func (c *Client) Script(ctx context.Context, scriptHash string) (script *Script, err error)

type CompatibleValue added in v1.1.0

type CompatibleValue shared.Value

func (*CompatibleValue) UnmarshalJSON added in v1.1.0

func (c *CompatibleValue) UnmarshalJSON(data []byte) error

type Match

type Match struct {
	TransactionIndex int             `json:"transaction_index,omitempty"`
	TransactionID    string          `json:"transaction_id,omitempty"`
	OutputIndex      int             `json:"output_index,omitempty"`
	Address          string          `json:"address,omitempty"`
	DatumHash        string          `json:"datum_hash,omitempty"`
	DatumType        string          `json:"datum_type,omitempty"`
	Value            CompatibleValue `json:"value,omitempty"`
	CreatedAt        Point           `json:"created_at,omitempty"`
	SpentAt          Point           `json:"spent_at,omitempty"`
}

type MatchesFilter

type MatchesFilter func(*matchesOptions)

func Address

func Address(address string) MatchesFilter

func All

func All() MatchesFilter

func AssetID

func AssetID(assetID shared.AssetID) MatchesFilter

func CreatedAfter

func CreatedAfter(slot uint64) MatchesFilter

func CreatedBefore

func CreatedBefore(slot uint64) MatchesFilter

func OnlySpent

func OnlySpent() MatchesFilter

func OnlyUnspent

func OnlyUnspent() MatchesFilter

func Overlapping

func Overlapping(slot uint64) MatchesFilter

func Pattern

func Pattern(pattern string) MatchesFilter

func PolicyID

func PolicyID(policyId string) MatchesFilter

func SpentAfter

func SpentAfter(slot uint64) MatchesFilter

func SpentBefore

func SpentBefore(slot uint64) MatchesFilter

func Transaction added in v0.1.1

func Transaction(txHash string) MatchesFilter

func TxOut added in v0.1.1

func TxOut(txOutId chainsync.TxID) MatchesFilter

NOTE(pi): chainsync.TxID is named poorly, and we plan to rename it at some point

type Metadatum added in v0.1.3

type Metadatum struct {
	Hash   string
	Raw    string
	Schema json.RawMessage
}

type Option

type Option func(*Options)

Option to kugo client

func WithEndpoint

func WithEndpoint(endpoint string) Option

WithEndpoint allows kupo endpoint to be set; defaults to http://127.0.0.1:1442

func WithLogger

func WithLogger(logger ogmigo.Logger) Option

WithLogger allows custom logger to be specified

func WithTimeout added in v1.1.0

func WithTimeout(timeout time.Duration) Option

Set a specific timeout for all requests

func WithoutTimeout added in v1.1.0

func WithoutTimeout() Option

Keep the http connection open as long as possible

type Options

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

Options available to kugo client

type Point

type Point struct {
	SlotNo     int    `json:"slot_no,omitempty"`
	HeaderHash string `json:"header_hash,omitempty"`
}

type Script added in v1.1.0

type Script struct {
	Language string `json:"language"`
	Script   string `json:"script"`
}

func (Script) Hash added in v1.1.0

func (s Script) Hash() []byte

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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