nearapi

package
v0.0.0-...-43fc98a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsWellFormedHash

func IsWellFormedHash(hash string) error

Types

type Block

type Block struct {
	Header BlockHeader
	// contains filtered or unexported fields
}

func NewBlockFromBytes

func NewBlockFromBytes(bytes []byte) (Block, error)

func (Block) ChunkHashes

func (b Block) ChunkHashes() []ChunkHeader

func (Block) Timestamp

func (b Block) Timestamp() uint64

type BlockHeader

type BlockHeader struct {
	Hash           string
	PrevBlockHash  string
	Height         uint64
	Timestamp      uint64
	LastFinalBlock string
}

type Chunk

type Chunk struct {
	Hash string
	// contains filtered or unexported fields
}

func NewChunkFromBytes

func NewChunkFromBytes(bytes []byte) (Chunk, error)

func (Chunk) Height

func (c Chunk) Height() uint64

func (Chunk) Transactions

func (c Chunk) Transactions() []Transaction

type ChunkHeader

type ChunkHeader struct {
	Hash string
}

type HttpNearRpc

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

func NewHttpNearRpc

func NewHttpNearRpc(nearRPC string) HttpNearRpc

func (HttpNearRpc) Query

func (n HttpNearRpc) Query(ctx context.Context, s string) ([]byte, error)

type NearApi

type NearApi interface {
	GetBlock(ctx context.Context, blockId string) (Block, error)
	GetBlockByHeight(ctx context.Context, blockHeight uint64) (Block, error)
	GetFinalBlock(ctx context.Context) (Block, error)
	GetChunk(ctx context.Context, chunkHeader ChunkHeader) (Chunk, error)
	GetTxStatus(ctx context.Context, txHash string, senderAccountId string) ([]byte, error)
}

type NearApiImpl

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

func NewNearApiImpl

func NewNearApiImpl(nearRpc NearRpc) NearApiImpl

func (NearApiImpl) GetBlock

func (n NearApiImpl) GetBlock(ctx context.Context, blockId string) (Block, error)

getBlock calls the NEAR RPC API to retrieve a block by its hash (https://docs.near.org/api/rpc/block-chunk#block-details)

func (NearApiImpl) GetBlockByHeight

func (n NearApiImpl) GetBlockByHeight(ctx context.Context, blockHeight uint64) (Block, error)

getBlockByHeight calls the NEAR RPC API to retrieve a block by its height (https://docs.near.org/api/rpc/block-chunk#block-details)

func (NearApiImpl) GetChunk

func (n NearApiImpl) GetChunk(ctx context.Context, chunkHeader ChunkHeader) (Chunk, error)

getChunk gets a chunk from the NEAR RPC API: https://docs.near.org/api/rpc/block-chunk#chunk-details

func (NearApiImpl) GetFinalBlock

func (n NearApiImpl) GetFinalBlock(ctx context.Context) (Block, error)

getFinalBlock gets a finalized block from the NEAR RPC API using the parameter "finality": "final" (https://docs.near.org/api/rpc/block-chunk)

func (NearApiImpl) GetTxStatus

func (n NearApiImpl) GetTxStatus(ctx context.Context, txHash string, senderAccountId string) ([]byte, error)

getTxStatus queries status of a transaction by hash, returning the transaction_outcomes and receipts_outcomes sender_account_id is used to determine which shard to query for the transaction See https://docs.near.org/api/rpc/transactions#transaction-status

type NearRpc

type NearRpc interface {
	Query(ctx context.Context, s string) ([]byte, error)
}

type Transaction

type Transaction struct {
	Hash     string
	SignerId string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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