rpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: BSD-3-Clause Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	JSONRPCEndpoint = "/tokenapi"
)

Variables

View Source
var (
	ErrTxNotFound    = errors.New("tx not found")
	ErrAssetNotFound = errors.New("asset not found")
)

Functions

This section is empty.

Types

type AssetArgs

type AssetArgs struct {
	Asset ids.ID `json:"asset"`
}

type AssetReply

type AssetReply struct {
	Metadata []byte `json:"metadata"`
	Supply   uint64 `json:"supply"`
	Owner    string `json:"owner"`
	Warp     bool   `json:"warp"`
}

type BalanceArgs

type BalanceArgs struct {
	Address string `json:"address"`
	Asset   ids.ID `json:"asset"`
}

type BalanceReply

type BalanceReply struct {
	Amount uint64 `json:"amount"`
}

type Controller

type Controller interface {
	Genesis() *genesis.Genesis
	Tracer() trace.Tracer
	GetTransaction(context.Context, ids.ID) (bool, int64, bool, uint64, error)
	GetAssetFromState(context.Context, ids.ID) (bool, []byte, uint64, crypto.PublicKey, bool, error)
	GetBalanceFromState(context.Context, crypto.PublicKey, ids.ID) (uint64, error)
	GetLoanFromState(context.Context, ids.ID, ids.ID) (uint64, error)
}

type GenesisReply

type GenesisReply struct {
	Genesis *genesis.Genesis `json:"genesis"`
}

type JSONRPCClient

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

func NewJSONRPCClient

func NewJSONRPCClient(uri string, chainID ids.ID) *JSONRPCClient

New creates a new client object.

func (*JSONRPCClient) Asset

func (cli *JSONRPCClient) Asset(
	ctx context.Context,
	asset ids.ID,
) (bool, []byte, uint64, string, bool, error)

func (*JSONRPCClient) Balance

func (cli *JSONRPCClient) Balance(ctx context.Context, addr string, asset ids.ID) (uint64, error)

func (*JSONRPCClient) Genesis

func (cli *JSONRPCClient) Genesis(ctx context.Context) (*genesis.Genesis, error)

func (*JSONRPCClient) Loan

func (cli *JSONRPCClient) Loan(
	ctx context.Context,
	asset ids.ID,
	destination ids.ID,
) (uint64, error)

func (*JSONRPCClient) Parser

func (cli *JSONRPCClient) Parser(ctx context.Context) (chain.Parser, error)

func (*JSONRPCClient) Tx

func (cli *JSONRPCClient) Tx(ctx context.Context, id ids.ID) (bool, bool, int64, error)

func (*JSONRPCClient) WaitForBalance

func (cli *JSONRPCClient) WaitForBalance(
	ctx context.Context,
	addr string,
	asset ids.ID,
	min uint64,
) error

TODO add more methods

func (*JSONRPCClient) WaitForTransaction

func (cli *JSONRPCClient) WaitForTransaction(ctx context.Context, txID ids.ID) (bool, error)

type JSONRPCServer

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

func NewJSONRPCServer

func NewJSONRPCServer(c Controller) *JSONRPCServer

func (*JSONRPCServer) Asset

func (j *JSONRPCServer) Asset(req *http.Request, args *AssetArgs, reply *AssetReply) error

func (*JSONRPCServer) Balance

func (j *JSONRPCServer) Balance(req *http.Request, args *BalanceArgs, reply *BalanceReply) error

func (*JSONRPCServer) Genesis

func (j *JSONRPCServer) Genesis(_ *http.Request, _ *struct{}, reply *GenesisReply) (err error)

func (*JSONRPCServer) Loan

func (j *JSONRPCServer) Loan(req *http.Request, args *LoanArgs, reply *LoanReply) error

func (*JSONRPCServer) Tx

func (j *JSONRPCServer) Tx(req *http.Request, args *TxArgs, reply *TxReply) error

type LoanArgs

type LoanArgs struct {
	Destination ids.ID `json:"destination"`
	Asset       ids.ID `json:"asset"`
}

type LoanReply

type LoanReply struct {
	Amount uint64 `json:"amount"`
}

type Parser

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

func (*Parser) ChainID

func (p *Parser) ChainID() ids.ID

func (*Parser) Registry

func (*Parser) Registry() (chain.ActionRegistry, chain.AuthRegistry)

func (*Parser) Rules

func (p *Parser) Rules(t int64) chain.Rules

type TxArgs

type TxArgs struct {
	TxID ids.ID `json:"txId"`
}

type TxReply

type TxReply struct {
	Timestamp int64  `json:"timestamp"`
	Success   bool   `json:"success"`
	Units     uint64 `json:"units"`
}

Jump to

Keyboard shortcuts

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