Documentation ¶
Index ¶
- type BlockRequest
- type BlockResponse
- type CallFunctionResponse
- type Client
- func (c *Client) Block(ctx context.Context, blockID uint64) (BlockResponse, error)
- func (c *Client) CallFunction(ctx context.Context, accountID string, methodName string, opts ...QueryOption) (CallFunctionResponse, error)
- func (c *Client) ProtocolConfig(ctx context.Context) (ProtocolConfigResponse, error)
- func (c *Client) Query(ctx context.Context, req QueryRequest, resp interface{}) error
- func (c *Client) Request(ctx context.Context, method string, params interface{}) (*Response, error)
- func (c *Client) Status(ctx context.Context) (StatusResponse, error)
- func (c *Client) Tx(ctx context.Context, params interface{}) (TxResponse, error)
- func (c *Client) Validators(ctx context.Context, params interface{}) (ValidatorsResponse, error)
- type Option
- type Payload
- type ProtocolConfigResponse
- type QueryOption
- type QueryRequest
- type QueryResponse
- type Response
- type StatusResponse
- type TxResponse
- type Validator
- type ValidatorsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockRequest ¶
type BlockRequest struct { Finality string `json:"finality,omitempty"` BlockID interface{} `json:"block_id,omitempty"` }
type BlockResponse ¶
type BlockResponse struct { Author string `json:"author"` Header struct { Height int `json:"height"` EpochID string `json:"epoch_id"` NextEpochID string `json:"next_epoch_id"` Hash string `json:"hash"` PrevHash string `json:"prev_hash"` PrevStateRoot string `json:"prev_state_root"` ChunkReceiptsRoot string `json:"chunk_receipts_root"` ChunkHeadersRoot string `json:"chunk_headers_root"` ChunkTxRoot string `json:"chunk_tx_root"` OutcomeRoot string `json:"outcome_root"` ChunksIncluded int `json:"chunks_included"` ChallengesRoot string `json:"challenges_root"` Timestamp int64 `json:"timestamp"` TimestampNanosec string `json:"timestamp_nanosec"` RandomValue string `json:"random_value"` ValidatorProposals []interface{} `json:"validator_proposals"` ChunkMask []bool `json:"chunk_mask"` GasPrice string `json:"gas_price"` RentPaid string `json:"rent_paid"` ValidatorReward string `json:"validator_reward"` TotalSupply string `json:"total_supply"` ChallengesResult []interface{} `json:"challenges_result"` LastFinalBlock string `json:"last_final_block"` LastDsFinalBlock string `json:"last_ds_final_block"` NextBpHash string `json:"next_bp_hash"` BlockMerkleRoot string `json:"block_merkle_root"` Approvals []interface{} `json:"approvals"` Signature string `json:"signature"` LatestProtocolVersion int `json:"latest_protocol_version"` } `json:"header"` Chunks []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 int `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"` } `json:"chunks"` }
type CallFunctionResponse ¶
type CallFunctionResponse struct { QueryResponse Logs []string `json:"logs"` Result []byte `json:"result"` }
CallFunctionResponse holds information about the result of a function call.
type Client ¶
type Client struct { Endpoint string // contains filtered or unexported fields }
func (*Client) CallFunction ¶
func (c *Client) CallFunction( ctx context.Context, accountID string, methodName string, opts ...QueryOption, ) (CallFunctionResponse, error)
func (*Client) ProtocolConfig ¶
func (c *Client) ProtocolConfig(ctx context.Context) (ProtocolConfigResponse, error)
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, req QueryRequest, resp interface{}) error
func (*Client) Tx ¶
func (c *Client) Tx(ctx context.Context, params interface{}) (TxResponse, error)
func (*Client) Validators ¶
func (c *Client) Validators(ctx context.Context, params interface{}) (ValidatorsResponse, error)
type ProtocolConfigResponse ¶
type ProtocolConfigResponse struct { ProtocolVersion int `json:"protocol_version"` GenesisTime time.Time `json:"genesis_time"` ChainID string `json:"chain_id"` GenesisHeight int `json:"genesis_height"` NumBlockProducerSeats int `json:"num_block_producer_seats"` NumBlockProducerSeatsPerShard []int `json:"num_block_producer_seats_per_shard"` AvgHiddenValidatorSeatsPerShard []int `json:"avg_hidden_validator_seats_per_shard"` DynamicResharding bool `json:"dynamic_resharding"` ProtocolUpgradeStakeThreshold []int `json:"protocol_upgrade_stake_threshold"` EpochLength int `json:"epoch_length"` GasLimit int64 `json:"gas_limit"` MinGasPrice string `json:"min_gas_price"` MaxGasPrice string `json:"max_gas_price"` BlockProducerKickoutThreshold int `json:"block_producer_kickout_threshold"` ChunkProducerKickoutThreshold int `json:"chunk_producer_kickout_threshold"` OnlineMinThreshold []int `json:"online_min_threshold"` OnlineMaxThreshold []int `json:"online_max_threshold"` GasPriceAdjustmentRate []int `json:"gas_price_adjustment_rate"` RuntimeConfig struct { StorageAmountPerByte string `json:"storage_amount_per_byte"` TransactionCosts struct { ActionReceiptCreationConfig struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"action_receipt_creation_config"` DataReceiptCreationConfig struct { BaseCost struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"base_cost"` CostPerByte struct { SendSir int `json:"send_sir"` SendNotSir int `json:"send_not_sir"` Execution int `json:"execution"` } `json:"cost_per_byte"` } `json:"data_receipt_creation_config"` ActionCreationConfig struct { CreateAccountCost struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"create_account_cost"` DeployContractCost struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"deploy_contract_cost"` DeployContractCostPerByte struct { SendSir int `json:"send_sir"` SendNotSir int `json:"send_not_sir"` Execution int `json:"execution"` } `json:"deploy_contract_cost_per_byte"` FunctionCallCost struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"function_call_cost"` FunctionCallCostPerByte struct { SendSir int `json:"send_sir"` SendNotSir int `json:"send_not_sir"` Execution int `json:"execution"` } `json:"function_call_cost_per_byte"` TransferCost struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"transfer_cost"` StakeCost struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"stake_cost"` AddKeyCost struct { FullAccessCost struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"full_access_cost"` FunctionCallCost struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"function_call_cost"` FunctionCallCostPerByte struct { SendSir int `json:"send_sir"` SendNotSir int `json:"send_not_sir"` Execution int `json:"execution"` } `json:"function_call_cost_per_byte"` } `json:"add_key_cost"` DeleteKeyCost struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"delete_key_cost"` DeleteAccountCost struct { SendSir int64 `json:"send_sir"` SendNotSir int64 `json:"send_not_sir"` Execution int64 `json:"execution"` } `json:"delete_account_cost"` } `json:"action_creation_config"` StorageUsageConfig struct { NumBytesAccount int `json:"num_bytes_account"` NumExtraBytesRecord int `json:"num_extra_bytes_record"` } `json:"storage_usage_config"` BurntGasReward []int `json:"burnt_gas_reward"` PessimisticGasPriceInflationRatio []int `json:"pessimistic_gas_price_inflation_ratio"` } `json:"transaction_costs"` WasmConfig struct { ExtCosts struct { Base int `json:"base"` ContractCompileBase int `json:"contract_compile_base"` ContractCompileBytes int `json:"contract_compile_bytes"` ReadMemoryBase int64 `json:"read_memory_base"` ReadMemoryByte int `json:"read_memory_byte"` WriteMemoryBase int64 `json:"write_memory_base"` WriteMemoryByte int `json:"write_memory_byte"` ReadRegisterBase int64 `json:"read_register_base"` ReadRegisterByte int `json:"read_register_byte"` WriteRegisterBase int64 `json:"write_register_base"` WriteRegisterByte int `json:"write_register_byte"` Utf8DecodingBase int64 `json:"utf8_decoding_base"` Utf8DecodingByte int `json:"utf8_decoding_byte"` Utf16DecodingBase int64 `json:"utf16_decoding_base"` Utf16DecodingByte int `json:"utf16_decoding_byte"` Sha256Base int64 `json:"sha256_base"` Sha256Byte int `json:"sha256_byte"` Keccak256Base int64 `json:"keccak256_base"` Keccak256Byte int `json:"keccak256_byte"` Keccak512Base int64 `json:"keccak512_base"` Keccak512Byte int `json:"keccak512_byte"` Ripemd160Base int `json:"ripemd160_base"` Ripemd160Block int `json:"ripemd160_block"` EcrecoverBase int64 `json:"ecrecover_base"` LogBase int64 `json:"log_base"` LogByte int `json:"log_byte"` StorageWriteBase int64 `json:"storage_write_base"` StorageWriteKeyByte int `json:"storage_write_key_byte"` StorageWriteValueByte int `json:"storage_write_value_byte"` StorageWriteEvictedByte int `json:"storage_write_evicted_byte"` StorageReadBase int64 `json:"storage_read_base"` StorageReadKeyByte int `json:"storage_read_key_byte"` StorageReadValueByte int `json:"storage_read_value_byte"` StorageRemoveBase int64 `json:"storage_remove_base"` StorageRemoveKeyByte int `json:"storage_remove_key_byte"` StorageRemoveRetValueByte int `json:"storage_remove_ret_value_byte"` StorageHasKeyBase int64 `json:"storage_has_key_base"` StorageHasKeyByte int `json:"storage_has_key_byte"` StorageIterCreatePrefixBase int `json:"storage_iter_create_prefix_base"` StorageIterCreatePrefixByte int `json:"storage_iter_create_prefix_byte"` StorageIterCreateRangeBase int `json:"storage_iter_create_range_base"` StorageIterCreateFromByte int `json:"storage_iter_create_from_byte"` StorageIterCreateToByte int `json:"storage_iter_create_to_byte"` StorageIterNextBase int `json:"storage_iter_next_base"` StorageIterNextKeyByte int `json:"storage_iter_next_key_byte"` StorageIterNextValueByte int `json:"storage_iter_next_value_byte"` TouchingTrieNode int64 `json:"touching_trie_node"` PromiseAndBase int `json:"promise_and_base"` PromiseAndPerPromise int `json:"promise_and_per_promise"` PromiseReturn int `json:"promise_return"` ValidatorStakeBase int64 `json:"validator_stake_base"` ValidatorTotalStakeBase int64 `json:"validator_total_stake_base"` } `json:"ext_costs"` GrowMemCost int `json:"grow_mem_cost"` RegularOpCost int `json:"regular_op_cost"` LimitConfig struct { MaxGasBurnt int64 `json:"max_gas_burnt"` MaxStackHeight int `json:"max_stack_height"` StackLimiterVersion int `json:"stack_limiter_version"` InitialMemoryPages int `json:"initial_memory_pages"` MaxMemoryPages int `json:"max_memory_pages"` RegistersMemoryLimit int `json:"registers_memory_limit"` MaxRegisterSize int `json:"max_register_size"` MaxNumberRegisters int `json:"max_number_registers"` MaxNumberLogs int `json:"max_number_logs"` MaxTotalLogLength int `json:"max_total_log_length"` MaxTotalPrepaidGas int64 `json:"max_total_prepaid_gas"` MaxActionsPerReceipt int `json:"max_actions_per_receipt"` MaxNumberBytesMethodNames int `json:"max_number_bytes_method_names"` MaxLengthMethodName int `json:"max_length_method_name"` MaxArgumentsLength int `json:"max_arguments_length"` MaxLengthReturnedData int `json:"max_length_returned_data"` MaxContractSize int `json:"max_contract_size"` MaxTransactionSize int `json:"max_transaction_size"` MaxLengthStorageKey int `json:"max_length_storage_key"` MaxLengthStorageValue int `json:"max_length_storage_value"` MaxPromisesPerFunctionCallAction int `json:"max_promises_per_function_call_action"` MaxNumberInputDataDependencies int `json:"max_number_input_data_dependencies"` MaxFunctionsNumberPerContract int `json:"max_functions_number_per_contract"` } `json:"limit_config"` } `json:"wasm_config"` AccountCreationConfig struct { MinAllowedTopLevelAccountLength int `json:"min_allowed_top_level_account_length"` RegistrarAccountID string `json:"registrar_account_id"` } `json:"account_creation_config"` } `json:"runtime_config"` TransactionValidityPeriod int `json:"transaction_validity_period"` ProtocolRewardRate []int `json:"protocol_reward_rate"` MaxInflationRate []int `json:"max_inflation_rate"` NumBlocksPerYear int `json:"num_blocks_per_year"` ProtocolTreasuryAccount string `json:"protocol_treasury_account"` FishermenThreshold string `json:"fishermen_threshold"` MinimumStakeDivisor int `json:"minimum_stake_divisor"` }
type QueryOption ¶
type QueryOption func(*QueryRequest) error
QueryOption controls the behavior when calling CallFunction.
func QueryWithArgs ¶
func QueryWithArgs(args interface{}) QueryOption
QueryWithArgs specified the args to call the function with. Should be a JSON encodable object.
func QueryWithBlockHash ¶
func QueryWithBlockHash(blockHash string) QueryOption
QueryWithBlockHash specifies the block hash to call the function for.
func QueryWithBlockHeight ¶
func QueryWithBlockHeight(blockHeight int64) QueryOption
QueryWithBlockHeight specifies the block height to call the function for.
func QueryWithFinality ¶
func QueryWithFinality(finality string) QueryOption
QueryWithFinality specifies the finality to be used when calling the function.
type QueryRequest ¶
type QueryRequest struct { RequestType string `json:"request_type"` Finality string `json:"finality,omitempty"` BlockID interface{} `json:"block_id,omitempty"` AccountID string `json:"account_id,omitempty"` PrefixBase64 string `json:"prefix_base64"` MethodName string `json:"method_name,omitempty"` ArgsBase64 string `json:"args_base64"` PublicKey string `json:"public_key,omitempty"` }
QueryRequest is used for RPC query requests.
func NewQueryRequest ¶
func NewQueryRequest(requestType, accountID, methodName string, opts ...QueryOption) (QueryRequest, error)
type QueryResponse ¶
type QueryResponse struct { BlockHash string `json:"block_hash"` BlockHeight int `json:"block_height"` // TODO: this property is undocumented, but appears in some API responses. Is this the right place for it? Error string `json:"error"` }
QueryResponse is a base type used for responses to query requests.
type Response ¶
type Response struct { JsonRPC string `json:"jsonrpc"` Id string `json:"id"` Result json.RawMessage `json:"result"` Error struct { Name string `json:"name"` Code int `json:"code"` Message string `json:"message"` Data string `json:"data"` Cause struct { Info interface{} `json:"info"` Name string `json:"name"` } `json:"cause"` } `json:"error"` }
type StatusResponse ¶
type StatusResponse struct { ChainID string `json:"chain_id"` LatestProtocolVersion int `json:"latest_protocol_version"` ProtocolVersion int `json:"protocol_version"` RpcAddr string `json:"rpc_addr"` SyncInfo struct { EarliestBlockHash string `json:"earliest_block_hash"` EarliestBlockHeight uint64 `json:"earliest_block_height"` EarliestBlockTime string `json:"earliest_block_time"` LatestBlockHash string `json:"latest_block_hash"` LatestBlockHeight uint64 `json:"latest_block_height"` LatestStateRoot string `json:"latest_state_root"` LatestBlockTime string `json:"latest_block_time"` Syncing bool `json:"syncing"` } `json:"sync_info"` //Validators []string `json:"validators"` Version struct { Version string `json:"version"` Build string `json:"build"` } `json:"version"` }
type TxResponse ¶
type TxResponse struct { ReceiptsOutcome []struct { BlockHash string `json:"block_hash"` ID string `json:"id"` Outcome struct { ExecutorID string `json:"executor_id"` GasBurnt int64 `json:"gas_burnt"` Logs []string `json:"logs"` Metadata struct { GasProfile []struct { Cost string `json:"cost"` CostCategory string `json:"cost_category"` GasUsed string `json:"gas_used"` } `json:"gas_profile"` Version int `json:"version"` } `json:"metadata"` ReceiptIds []string `json:"receipt_ids"` Status struct { SuccessValue string `json:"SuccessValue"` } `json:"status"` TokensBurnt string `json:"tokens_burnt"` } `json:"outcome"` Proof []struct { Direction string `json:"direction"` Hash string `json:"hash"` } `json:"proof"` } `json:"receipts_outcome"` Status struct { SuccessValue string `json:"SuccessValue"` } `json:"status"` Transaction struct { Actions []struct { FunctionCall struct { Args string `json:"args"` Deposit string `json:"deposit"` Gas int64 `json:"gas"` MethodName string `json:"method_name"` } `json:"FunctionCall"` } `json:"actions"` Hash string `json:"hash"` Nonce int64 `json:"nonce"` PublicKey string `json:"public_key"` ReceiverID string `json:"receiver_id"` Signature string `json:"signature"` SignerID string `json:"signer_id"` } `json:"transaction"` TransactionOutcome struct { BlockHash string `json:"block_hash"` ID string `json:"id"` Outcome struct { ExecutorID string `json:"executor_id"` GasBurnt int64 `json:"gas_burnt"` Logs []interface{} `json:"logs"` Metadata struct { GasProfile interface{} `json:"gas_profile"` Version int `json:"version"` } `json:"metadata"` ReceiptIds []string `json:"receipt_ids"` Status struct { SuccessReceiptID string `json:"SuccessReceiptId"` } `json:"status"` TokensBurnt string `json:"tokens_burnt"` } `json:"outcome"` Proof []struct { Direction string `json:"direction"` Hash string `json:"hash"` } `json:"proof"` } `json:"transaction_outcome"` }
type ValidatorsResponse ¶
type ValidatorsResponse struct { CurrentValidators []struct { Validator IsSlashed bool `json:"is_slashed"` Shards []int `json:"shards"` NumProducedBlocks int64 `json:"num_produced_blocks"` NumExpectedBlocks int64 `json:"num_expected_blocks"` NumProducedChunks int64 `json:"num_produced_chunks"` NumExpectedChunks int64 `json:"num_expected_chunks"` } `json:"current_validators"` NextValidators []struct { Validator Shards []int `json:"shards"` } `json:"next_validators"` CurrentProposals []struct { Validator StakeStructVersion string `json:"validator_stake_struct_version"` } `json:"current_proposals"` EpochStartHeight int64 `json:"epoch_start_height"` EpochHeight int64 `json:"epoch_height"` PrevEpochKickOut []struct { AccountId string `json:"account_id"` Reason interface{} `json:"reason"` } `json:"prev_epoch_kickout"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.