rpc

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: BSD-3-Clause Imports: 24 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 {
	Symbol   []byte `json:"symbol"`
	Decimals uint8  `json:"decimals"`
	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 BlockHeadersResponse added in v0.4.0

type BlockHeadersResponse struct {
	From   uint64      `json:"from"`
	Blocks []BlockInfo `json:"blocks"`
	Prev   BlockInfo   `json:"prev"`
	Next   BlockInfo   `json:"next"`
}

type BlockInfo added in v0.4.0

type BlockInfo struct {
	BlockId   string `json:"id"`
	Timestamp int64  `json:"timestamp"`
	L1Head    uint64 `json:"l1_head"`
	Height    uint64 `json:"height"`
}

type Controller

type Controller interface {
	Genesis() *genesis.Genesis
	Tracer() trace.Tracer
	GetTransaction(context.Context, ids.ID) (bool, int64, bool, chain.Dimensions, uint64, error)
	GetAssetFromState(context.Context, ids.ID) (bool, []byte, uint8, []byte, uint64, ed25519.PublicKey, bool, error)
	GetBalanceFromState(context.Context, ed25519.PublicKey, ids.ID) (uint64, error)
	GetLoanFromState(context.Context, ids.ID, ids.ID) (uint64, error)
	UnitPrices(ctx context.Context) (chain.Dimensions, error)
	GetAcceptedBlockWindow() int
	Submit(
		ctx context.Context,
		verifySig bool,
		txs []*chain.Transaction,
	) (errs []error)
}

type GenesisReply

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

type GetBlockCommitmentArgs added in v0.8.22

type GetBlockCommitmentArgs struct {
	First         uint64 `json:"first"`
	CurrentHeight uint64 `json:"current_height"`
	MaxBlocks     int    `json:"max_blocks"`
}

type GetBlockHeadersByHeightArgs added in v0.4.0

type GetBlockHeadersByHeightArgs struct {
	Height uint64 `json:"height"`
	End    int64  `json:"end"`
}

type GetBlockHeadersByStartArgs added in v0.4.0

type GetBlockHeadersByStartArgs struct {
	Start int64 `json:"start"`
	End   int64 `json:"end"`
}

type GetBlockHeadersIDArgs added in v0.4.0

type GetBlockHeadersIDArgs struct {
	ID  string `json:"id"`
	End int64  `json:"end"`
}

type GetBlockTransactionsArgs added in v0.4.0

type GetBlockTransactionsArgs struct {
	ID string `json:"block_id"`
}

type GetBlockTransactionsByNamespaceArgs added in v0.4.0

type GetBlockTransactionsByNamespaceArgs struct {
	Height    uint64 `json:"height"`
	Namespace string `json:"namespace"`
}

type JSONRPCClient

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

func NewJSONRPCClient

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

New creates a new client object.

func (*JSONRPCClient) Asset

func (cli *JSONRPCClient) Asset(
	ctx context.Context,
	asset ids.ID,
	useCache bool,
) (bool, []byte, uint8, []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) GetAcceptedBlockWindow added in v0.9.7

func (cli *JSONRPCClient) GetAcceptedBlockWindow(ctx context.Context) (int, error)

func (*JSONRPCClient) GetBlockHeadersByHeight added in v0.5.0

func (cli *JSONRPCClient) GetBlockHeadersByHeight(
	ctx context.Context,
	height uint64,
	end int64,
) (*BlockHeadersResponse, error)

func (*JSONRPCClient) GetBlockHeadersByStart added in v0.5.0

func (cli *JSONRPCClient) GetBlockHeadersByStart(
	ctx context.Context,
	start int64,
	end int64,
) (*BlockHeadersResponse, error)

func (*JSONRPCClient) GetBlockHeadersID added in v0.5.0

func (cli *JSONRPCClient) GetBlockHeadersID(
	ctx context.Context,
	id string,
	end int64,
) (*BlockHeadersResponse, error)

func (*JSONRPCClient) GetBlockTransactions added in v0.5.0

func (cli *JSONRPCClient) GetBlockTransactions(
	ctx context.Context,
	id string,
) (*TransactionResponse, error)

func (*JSONRPCClient) GetBlockTransactionsByNamespace added in v0.5.0

func (cli *JSONRPCClient) GetBlockTransactionsByNamespace(
	ctx context.Context,
	height uint64,
	namespace string,
) (*SEQTransactionResponse, error)

func (*JSONRPCClient) GetCommitmentBlocks added in v0.8.22

func (cli *JSONRPCClient) GetCommitmentBlocks(
	ctx context.Context,
	first uint64,
	height uint64,
	maxBlocks int,
) (*SequencerWarpBlockResponse, 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, uint64, 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, uint64, error)

type JSONRPCServer

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

func NewJSONRPCServer

func NewJSONRPCServer(c Controller) *JSONRPCServer

func (*JSONRPCServer) AcceptBlock added in v0.4.0

func (j *JSONRPCServer) AcceptBlock(blk *chain.StatelessBlock) error

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) GetAcceptedBlockWindow added in v0.9.7

func (j *JSONRPCServer) GetAcceptedBlockWindow(req *http.Request, _ *struct{}, reply *int) error

func (*JSONRPCServer) GetBlockHeadersByHeight added in v0.5.0

func (j *JSONRPCServer) GetBlockHeadersByHeight(req *http.Request, args *GetBlockHeadersByHeightArgs, reply *BlockHeadersResponse) error

func (*JSONRPCServer) GetBlockHeadersByStart added in v0.5.0

func (j *JSONRPCServer) GetBlockHeadersByStart(req *http.Request, args *GetBlockHeadersByStartArgs, reply *BlockHeadersResponse) error

func (*JSONRPCServer) GetBlockHeadersID added in v0.5.0

func (j *JSONRPCServer) GetBlockHeadersID(req *http.Request, args *GetBlockHeadersIDArgs, reply *BlockHeadersResponse) error

func (*JSONRPCServer) GetBlockTransactions added in v0.5.0

func (j *JSONRPCServer) GetBlockTransactions(req *http.Request, args *GetBlockTransactionsArgs, reply *TransactionResponse) error

func (*JSONRPCServer) GetBlockTransactionsByNamespace added in v0.5.0

func (j *JSONRPCServer) GetBlockTransactionsByNamespace(req *http.Request, args *GetBlockTransactionsByNamespaceArgs, reply *SEQTransactionResponse) error

func (*JSONRPCServer) GetCommitmentBlocks added in v0.8.22

func (j *JSONRPCServer) GetCommitmentBlocks(req *http.Request, args *GetBlockCommitmentArgs, reply *SequencerWarpBlockResponse) error

func (*JSONRPCServer) Loan

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

func (*JSONRPCServer) ServerParser added in v0.4.0

func (j *JSONRPCServer) ServerParser(ctx context.Context, networkId uint32, chainId ids.ID) chain.Parser

func (*JSONRPCServer) SubmitMsgTx added in v0.8.0

func (j *JSONRPCServer) SubmitMsgTx(
	req *http.Request,
	args *SubmitMsgTxArgs,
	reply *SubmitMsgTxReply,
) 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 SEQTransactionResponse added in v0.4.0

type SEQTransactionResponse struct {
	Txs     []*types.SEQTransaction `json:"txs"`
	BlockId string                  `json:"id"`
}

type SequencerWarpBlock added in v0.8.22

type SequencerWarpBlock struct {
	BlockId    string   `json:"id"`
	Timestamp  int64    `json:"timestamp"`
	L1Head     uint64   `json:"l1_head"`
	Height     *big.Int `json:"height"`
	BlockRoot  *big.Int `json:"root"`
	ParentRoot *big.Int `json:"parent"`
}

type SequencerWarpBlockResponse added in v0.8.22

type SequencerWarpBlockResponse struct {
	Blocks []SequencerWarpBlock `json:"blocks"`
}

type ServerParser added in v0.4.0

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

func (*ServerParser) ChainID added in v0.4.0

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

func (*ServerParser) Registry added in v0.4.0

func (*ServerParser) Rules added in v0.4.0

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

type SubmitMsgTxArgs added in v0.8.0

type SubmitMsgTxArgs struct {
	ChainId          string `json:"chain_id"`
	NetworkID        uint32 `json:"network_id"`
	SecondaryChainId []byte `json:"secondary_chain_id"`
	Data             []byte `json:"data"`
}

type SubmitMsgTxReply added in v0.8.0

type SubmitMsgTxReply struct {
	TxID string `json:"txId"`
}

type TransactionResponse added in v0.4.0

type TransactionResponse struct {
	Txs     []*chain.Transaction `json:"txs"`
	BlockId string               `json:"id"`
}

TODO need to fix this. Tech debt

type TxArgs

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

type TxReply

type TxReply struct {
	Timestamp int64            `json:"timestamp"`
	Success   bool             `json:"success"`
	Units     chain.Dimensions `json:"units"`
	Fee       uint64           `json:"fee"`
}

Jump to

Keyboard shortcuts

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