Documentation
¶
Index ¶
- type CallFunctionOption
- type CallFunctionResponse
- type Cause
- type Change
- type ChangeData
- type Client
- func (c *Client) Account(accountID string) *account.Account
- func (c *Client) CallFunction(ctx context.Context, accountID string, methodName string, ...) (*CallFunctionResponse, error)
- func (c *Client) DataChanges(ctx context.Context, accountIDs []string, opts ...DataChangesOption) (*DataChangesResponse, error)
- func (c *Client) GetBlockResult(ctx context.Context) (*itypes.BlockResult, error)
- func (c *Client) GetGasPrice(ctx context.Context, gp *GasPriceOpts) (*itypes.BlockHeader, error)
- func (c *Client) NetworkInfo(ctx context.Context) (*models.NetworkInfo, error)
- func (c *Client) NodeStatus(ctx context.Context) (*NodeStatusResponse, error)
- func (c *Client) ViewCode(ctx context.Context, accountID string, opts ...ViewCodeOption) (*ViewCodeResponse, error)
- type DataChangesOption
- type DataChangesResponse
- type EpochKickout
- type Fisherman
- type GasPriceOpts
- type NodeStatusResponse
- type SyncInfo
- type Validator
- type Validators
- type ValidatorsResponse
- type Version
- type ViewCodeOption
- type ViewCodeResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallFunctionOption ¶
type CallFunctionOption func(*itypes.QueryRequest) error
CallFunctionOption controls the behavior when calling CallFunction.
func CallFunctionWithArgs ¶
func CallFunctionWithArgs(args interface{}) CallFunctionOption
CallFunctionWithArgs specified the args to call the function with. Should be a JSON encodable object.
func CallFunctionWithBlockHash ¶
func CallFunctionWithBlockHash(blockHash string) CallFunctionOption
CallFunctionWithBlockHash specifies the block hash to call the function for.
func CallFunctionWithBlockHeight ¶
func CallFunctionWithBlockHeight(blockHeight int) CallFunctionOption
CallFunctionWithBlockHeight specifies the block height to call the function for.
func CallFunctionWithFinality ¶
func CallFunctionWithFinality(finalaity string) CallFunctionOption
CallFunctionWithFinality specifies the finality to be used when calling the function.
type CallFunctionResponse ¶
type CallFunctionResponse struct { Result []byte `json:"result"` Logs []string `json:"logs"` BlockHeight int `json:"block_height"` BlockHash string `json:"block_hash"` }
CallFunctionResponse holds information about the result of a function call.
type Change ¶
type Change struct { AccountID string `json:"account_id"` KeyBase64 string `json:"key_base64"` ValueBase64 string `json:"value_base64"` }
Change holds information about a state change of a key-value pair.
type ChangeData ¶
type ChangeData struct { Cause Cause `json:"cause"` Type string `json:"type"` Change Change `json:"change"` }
ChangeData holds information about a state change.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with the NEAR API.
func (*Client) CallFunction ¶
func (c *Client) CallFunction( ctx context.Context, accountID string, methodName string, opts ...CallFunctionOption, ) (*CallFunctionResponse, error)
CallFunction calls a function on a contract.
func (*Client) DataChanges ¶
func (c *Client) DataChanges( ctx context.Context, accountIDs []string, opts ...DataChangesOption, ) (*DataChangesResponse, error)
DataChanges queries changes to contract data changes.
func (*Client) GetBlockResult ¶ added in v0.2.5
func (*Client) GetGasPrice ¶ added in v0.2.9
func (c *Client) GetGasPrice(ctx context.Context, gp *GasPriceOpts) (*itypes.BlockHeader, error)
func (*Client) NetworkInfo ¶
NetworkInfo returns the current state of node network connections (active peers, transmitted data, etc.)
func (*Client) NodeStatus ¶
func (c *Client) NodeStatus(ctx context.Context) (*NodeStatusResponse, error)
NodeStatus returns the node status.
func (*Client) ViewCode ¶
func (c *Client) ViewCode(ctx context.Context, accountID string, opts ...ViewCodeOption) (*ViewCodeResponse, error)
ViewCode returns the smart contract code for the provided account id.
type DataChangesOption ¶
type DataChangesOption func(*itypes.ChangesRequest)
DataChangesOption controls behavior when calling DataChanges.
func DataChangesWithBlockHash ¶
func DataChangesWithBlockHash(blockHash string) DataChangesOption
DataChangesWithBlockHash specifies the block id to query data changes for.
func DataChangesWithBlockHeight ¶
func DataChangesWithBlockHeight(blockHeight int) DataChangesOption
DataChangesWithBlockHeight specifies the block id to query data changes for.
func DataChangesWithFinality ¶
func DataChangesWithFinality(finalaity string) DataChangesOption
DataChangesWithFinality specifies the finality to be used when querying data changes.
func DataChangesWithPrefix ¶
func DataChangesWithPrefix(prefix string) DataChangesOption
DataChangesWithPrefix sets the data key prefix to query for.
type DataChangesResponse ¶
type DataChangesResponse struct { BlockHash string `json:"block_hash"` Changes []ChangeData `json:"changes"` }
DataChangesResponse holds information about all data changes in a block.
type EpochKickout ¶
type EpochKickout struct { AccountID string `json:"account_id"` Reason map[string]interface{} `json:"reason"` }
EpochKickout struct
type Fisherman ¶
type Fisherman struct { AccountID string `json:"account_id"` PublicKey string `json:"public_key"` Stake string `json:"stake"` }
Fisherman struct
type GasPriceOpts ¶ added in v0.2.9
type NodeStatusResponse ¶
type NodeStatusResponse struct { ChainID string `json:"chain_id"` RPCAddr string `json:"rpc_addr"` SyncInfo SyncInfo `json:"sync_info"` Validators Validators `json:"validators"` Version Version `json:"version"` }
NodeStatusResponse holds information about node status.
type SyncInfo ¶
type SyncInfo struct { LatestBlockHash string `json:"latest_block_hash"` LatestBlockHeight int `json:"latest_block_height"` // TODO: make this time.Time and use custom json conversion. LatestBlockTime string `json:"latest_block_time"` LatestStateRoot string `json:"latest_state_root"` Syncing bool `json:"syncing"` }
SyncInfo holds information about the sync status of a node.
type Validator ¶
type Validator struct { AccountID string `json:"account_id"` IsSlashed bool `json:"is_slashed"` ExpectedBlocksNum int64 `json:"num_expected_blocks,omitempty"` ProducedBlocksNum int64 `json:"num_produced_blocks,omitempty"` PublicKey string `json:"public_key,omitempty"` Shards []int64 `json:"shards,omitempty"` Stake string `json:"stake,omitempty"` }
Validator struct
type ValidatorsResponse ¶
type ValidatorsResponse struct { CurrentFishermans []Fisherman `json:"current_fishermen,omitempty"` NextFishermans []Fisherman `json:"next_fishermen,omitempty"` CurrentValidators Validators `json:"current_validators,omitempty"` NextValidators Validators `json:"next_validators,omitempty"` CurrentProposal string `json:"current_proposal,omitempty"` EpochStartHeight int64 `json:"epoch_start_height"` PrevEpochKickout []EpochKickout `json:"prev_epoch_kickout"` }
ValidatorsResponse struct
type ViewCodeOption ¶
type ViewCodeOption func(*itypes.QueryRequest)
ViewCodeOption controls the behavior when calling ViewCode.
func ViewCodeWithBlockHash ¶
func ViewCodeWithBlockHash(blockHash string) ViewCodeOption
ViewCodeWithBlockHash specifies the block hash to call the function for.
func ViewCodeWithBlockHeight ¶
func ViewCodeWithBlockHeight(blockHeight int) ViewCodeOption
ViewCodeWithBlockHeight specifies the block height to call the function for.
func ViewCodeWithFinality ¶
func ViewCodeWithFinality(finalaity string) ViewCodeOption
ViewCodeWithFinality specifies the finality to be used when calling the function.