near

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBase64

func DecodeBase64(data string) ([]byte, error)

DecodeBase64 decodes a base64 string.

Types

type AccessKey

type AccessKey struct{}

type Action

type Action struct {
	CreateAccount   *CreateAccountAction  `json:"CreateAccount,omitempty"`
	DeployContract  *DeployContractAction `json:"DeployContract,omitempty"`
	FunctionCall    *FunctionCallAction   `json:"FunctionCall,omitempty"`
	Transfer        *TransferAction       `json:"Transfer,omitempty"`
	Stake           *StakeAction          `json:"Stake,omitempty"`
	AddKey          *AddKeyAction         `json:"AddKey,omitempty"`
	DeleteKey       *DeleteKeyAction      `json:"DeleteKey,omitempty"`
	DeleteAccount   *DeleteAccountAction  `json:"DeleteAccount,omitempty"`
	DelegateActions *SignedDelegateAction `json:"Delegate,omitempty"`
}

func (*Action) UnmarshalJSON

func (a *Action) UnmarshalJSON(data []byte) error

nolint:gocognit

type AddKeyAction

type AddKeyAction struct {
	PublicKey string    `json:"public_key"`
	AccessKey AccessKey `json:"access_key"`
}

type Block

type Block struct {
	Author string       `json:"author"`
	Chunks []BlockChunk `json:"chunks"`
	Header BlockHeader  `json:"header"`
}

type BlockChunk

type BlockChunk struct {
	ChunkHash            string         `json:"chunk_hash"`
	PrevBlockHash        string         `json:"prev_block_hash"`
	OutcomeRoot          string         `json:"outcome_root"`
	PrevStateRoot        string         `json:"prev_state_root"`
	EncodedMerkleRoot    string         `json:"encoded_merkle_root"`
	EncodedLength        int            `json:"encoded_length"`
	HeightCreated        int            `json:"height_created"`
	HeightIncluded       int            `json:"height_included"`
	ShardID              int            `json:"shard_id"`
	GasUsed              int64          `json:"gas_used"`
	GasLimit             int64          `json:"gas_limit"`
	RentPaid             string         `json:"rent_paid"`
	ValidatorReward      string         `json:"validator_reward"`
	BalanceBurnt         string         `json:"balance_burnt"`
	OutgoingReceiptsRoot string         `json:"outgoing_receipts_root"`
	TxRoot               string         `json:"tx_root"`
	ValidatorProposals   []interface{}  `json:"validator_proposals"`
	Signature            string         `json:"signature"`
	CongestionInfo       CongestionInfo `json:"congestion_info"`
}

type BlockHeader

type BlockHeader struct {
	Approvals             []string      `json:"approvals"`
	BlockBodyHash         string        `json:"block_body_hash"`
	BlockMerkleRoot       string        `json:"block_merkle_root"`
	BlockOrdinal          int           `json:"block_ordinal"`
	ChallengesResult      []interface{} `json:"challenges_result"`
	ChallengesRoot        string        `json:"challenges_root"`
	ChunkHeadersRoot      string        `json:"chunk_headers_root"`
	ChunkMask             []bool        `json:"chunk_mask"`
	ChunkReceiptsRoot     string        `json:"chunk_receipts_root"`
	ChunkTxRoot           string        `json:"chunk_tx_root"`
	ChunksIncluded        int           `json:"chunks_included"`
	EpochID               string        `json:"epoch_id"`
	EpochSyncDataHash     interface{}   `json:"epoch_sync_data_hash"`
	GasPrice              string        `json:"gas_price"`
	Hash                  string        `json:"hash"`
	Height                int           `json:"height"`
	LastDsFinalBlock      string        `json:"last_ds_final_block"`
	LastFinalBlock        string        `json:"last_final_block"`
	LatestProtocolVersion int           `json:"latest_protocol_version"`
	NextBpHash            string        `json:"next_bp_hash"`
	NextEpochID           string        `json:"next_epoch_id"`
	OutcomeRoot           string        `json:"outcome_root"`
	PrevHash              string        `json:"prev_hash"`
	PrevHeight            int           `json:"prev_height"`
	PrevStateRoot         string        `json:"prev_state_root"`
	RandomValue           string        `json:"random_value"`
	RentPaid              string        `json:"rent_paid"`
	Signature             string        `json:"signature"`
	Timestamp             int64         `json:"timestamp"`
	TimestampNanosec      string        `json:"timestamp_nanosec"`
	TotalSupply           string        `json:"total_supply"`
	ValidatorProposals    []interface{} `json:"validator_proposals"`
	ValidatorReward       string        `json:"validator_reward"`
}

type BlockNumberResponse

type BlockNumberResponse struct {
	Jsonrpc string `json:"jsonrpc"`
	Result  Block  `json:"result"`
	ID      string `json:"id"`
}

type Chunk

type Chunk struct {
	Author       string               `json:"author"`
	Header       ChunkHeader          `json:"header"`
	Transactions []TransactionDetails `json:"transactions"`
	Receipts     []ChunkReceipt       `json:"receipts"`
}

type ChunkHeader

type ChunkHeader struct {
	ChunkHash            string         `json:"chunk_hash"`
	PrevBlockHash        string         `json:"prev_block_hash"`
	OutcomeRoot          string         `json:"outcome_root"`
	PrevStateRoot        string         `json:"prev_state_root"`
	EncodedMerkleRoot    string         `json:"encoded_merkle_root"`
	EncodedLength        int            `json:"encoded_length"`
	HeightCreated        int            `json:"height_created"`
	HeightIncluded       int            `json:"height_included"`
	ShardID              int            `json:"shard_id"`
	GasUsed              int64          `json:"gas_used"`
	GasLimit             int64          `json:"gas_limit"`
	RentPaid             string         `json:"rent_paid"`
	ValidatorReward      string         `json:"validator_reward"`
	BalanceBurnt         string         `json:"balance_burnt"`
	OutgoingReceiptsRoot string         `json:"outgoing_receipts_root"`
	TxRoot               string         `json:"tx_root"`
	ValidatorProposals   []interface{}  `json:"validator_proposals"`
	Signature            string         `json:"signature"`
	CongestionInfo       CongestionInfo `json:"congestion_info"`
}

type ChunkReceipt

type ChunkReceipt struct {
	PredecessorID string        `json:"predecessor_id"`
	ReceiverID    string        `json:"receiver_id"`
	ReceiptID     string        `json:"receipt_id"`
	Receipt       ReceiptAction `json:"receipt"`
	Priority      int           `json:"priority"`
}

type Client

type Client interface {
	BlockByHeight(ctx context.Context, blockHeight *big.Int) (*Block, error)
	ChunkByHash(ctx context.Context, hash string) (*Chunk, error)
	ChunkByHeight(ctx context.Context, blockHeight *big.Int, shardID int) (*Chunk, error)
	TransactionByHash(ctx context.Context, txHash string, senderAccountID string) (*Transaction, error)
	GetBlockHeight(ctx context.Context) (int64, error)
}

Client provides basic RPC methods for NEAR Protocol.

func Dial

func Dial(_ context.Context, endpoint string) (Client, error)

Dial creates a new client for a given URL.

type CongestionInfo

type CongestionInfo struct {
	DelayedReceiptsGas  string `json:"delayed_receipts_gas"`
	BufferedReceiptsGas string `json:"buffered_receipts_gas"`
	ReceiptBytes        int    `json:"receipt_bytes"`
	AllowedShard        int    `json:"allowed_shard"`
}

type CreateAccountAction

type CreateAccountAction struct{}

type DelegateAction

type DelegateAction struct {
	SenderID       string              `json:"sender_id"`
	ReceiverID     string              `json:"receiver_id"`
	Actions        []NonDelegateAction `json:"actions"`
	Nonce          int64               `json:"nonce"`
	MaxBlockHeight int64               `json:"max_block_height"`
	PublicKey      string              `json:"public_key"`
}

type DeleteAccountAction

type DeleteAccountAction struct {
	BeneficiaryID string `json:"beneficiary_id"`
}

type DeleteKeyAction

type DeleteKeyAction struct {
	PublicKey string `json:"public_key"`
}

type DeployContractAction

type DeployContractAction struct {
	Code []byte `json:"code"`
}

type FunctionCallAction

type FunctionCallAction struct {
	MethodName string `json:"method_name"`
	Args       string `json:"args"`
	Gas        int64  `json:"gas"`
	Deposit    string `json:"deposit"`
}

type NonDelegateAction

type NonDelegateAction struct{}

type Outcome

type Outcome struct {
	Logs        []string                   `json:"logs"`
	ReceiptIDs  []string                   `json:"receipt_ids"`
	GasBurnt    int64                      `json:"gas_burnt"`
	TokensBurnt string                     `json:"tokens_burnt"`
	ExecutorID  string                     `json:"executor_id"`
	Status      TransactionOutcomeStatus   `json:"status"`
	Metadata    TransactionOutcomeMetadata `json:"metadata"`
}

type ReceiptAction

type ReceiptAction struct {
	Action ReceiptActionDetails `json:"Action"`
}

type ReceiptActionDetails

type ReceiptActionDetails struct {
	SignerID            string        `json:"signer_id"`
	SignerPublicKey     string        `json:"signer_public_key"`
	GasPrice            string        `json:"gas_price"`
	OutputDataReceivers []interface{} `json:"output_data_receivers"`
	InputDataIDs        []interface{} `json:"input_data_ids"`
	Actions             []interface{} `json:"actions"` // Change to interface{} to accept any action type
	IsPromiseYield      bool          `json:"is_promise_yield"`
}

type ReceiptOutcome

type ReceiptOutcome struct {
	Proof     []TransactionOutcomeProof `json:"proof"`
	BlockHash string                    `json:"block_hash"`
	ID        string                    `json:"id"`
	Outcome   Outcome                   `json:"outcome"`
}

type SignedDelegateAction

type SignedDelegateAction struct {
	DelegateAction DelegateAction `json:"delegate_action"`
	Signature      string         `json:"signature"`
}

type StakeAction

type StakeAction struct {
	Stake     string `json:"stake"`
	PublicKey string `json:"public_key"`
}

type Transaction

type Transaction struct {
	Status               TransactionStatus  `json:"status"`
	Transaction          TransactionDetails `json:"transaction"`
	TransactionOutcome   TransactionOutcome `json:"transaction_outcome"`
	ReceiptsOutcome      []ReceiptOutcome   `json:"receipts_outcome"`
	FinalExecutionStatus string             `json:"final_execution_status"`
}

type TransactionDetails

type TransactionDetails struct {
	SignerID    string   `json:"signer_id"`
	PublicKey   string   `json:"public_key"`
	Nonce       uint64   `json:"nonce"`
	ReceiverID  string   `json:"receiver_id"`
	Actions     []Action `json:"actions"`
	Signature   string   `json:"signature"`
	Hash        string   `json:"hash"`
	PriorityFee uint64   `json:"priority_fee"`
}

type TransactionOutcome

type TransactionOutcome struct {
	Proof     []TransactionOutcomeProof `json:"proof"`
	BlockHash string                    `json:"block_hash"`
	ID        string                    `json:"id"`
	Outcome   Outcome                   `json:"outcome"`
}

type TransactionOutcomeMetadata

type TransactionOutcomeMetadata struct {
	Version    int         `json:"version"`
	GasProfile interface{} `json:"gas_profile"`
}

type TransactionOutcomeProof

type TransactionOutcomeProof struct {
	Hash      string `json:"hash"`
	Direction string `json:"direction"`
}

type TransactionOutcomeStatus

type TransactionOutcomeStatus struct {
	SuccessReceiptID string `json:"SuccessReceiptId"`
}

type TransactionStatus

type TransactionStatus struct {
	SuccessValue string `json:"SuccessValue"`
}

type TransferAction

type TransferAction struct {
	Deposit string `json:"deposit"`
}

Jump to

Keyboard shortcuts

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