Documentation
¶
Overview ¶
Package provider has the functions to do the RPC requests to a node in the protocol
Index ¶
- Constants
- Variables
- func IsErrorCode(code RelayErrorCode, err error) bool
- type AddressType
- type AllParams
- type App
- type DispatchOutput
- type DispatchRequestOptions
- type Fee
- type GetAccountOptions
- type GetAccountOutput
- type GetAccountTransactionsOptions
- type GetAccountTransactionsOutput
- type GetAccountsOptions
- type GetAccountsOutput
- type GetAllParamsOptions
- type GetAppOptions
- type GetAppOutput
- type GetAppsOptions
- type GetAppsOutput
- type GetBalanceOptions
- type GetBlockOutput
- type GetBlockTransactionsOptions
- type GetBlockTransactionsOutput
- type GetNodeOptions
- type GetNodeOutput
- type GetNodesOptions
- type GetNodesOutput
- type GetTransactionOptions
- type GetTransactionOutput
- type GetTypeOptions
- type JailedStatus
- type Node
- type Order
- type Param
- type ParamGroup
- type PocketAAT
- type Provider
- func (p *Provider) Dispatch(appPublicKey, chain string, options *DispatchRequestOptions) (*DispatchOutput, error)
- func (p *Provider) DispatchWithCtx(ctx context.Context, appPublicKey, chain string, ...) (*DispatchOutput, error)
- func (p *Provider) GetAccount(address string, options *GetAccountOptions) (*GetAccountOutput, error)
- func (p *Provider) GetAccountTransactions(address string, options *GetAccountTransactionsOptions) (*GetAccountTransactionsOutput, error)
- func (p *Provider) GetAccountTransactionsWithCtx(ctx context.Context, address string, options *GetAccountTransactionsOptions) (*GetAccountTransactionsOutput, error)
- func (p *Provider) GetAccountWithCtx(ctx context.Context, address string, options *GetAccountOptions) (*GetAccountOutput, error)
- func (p *Provider) GetAccounts(options *GetAccountsOptions) (*GetAccountsOutput, error)
- func (p *Provider) GetAccountsWithCtx(ctx context.Context, options *GetAccountsOptions) (*GetAccountsOutput, error)
- func (p *Provider) GetAllApps(ctx context.Context) ([]App, error)
- func (p *Provider) GetAllParams(options *GetAllParamsOptions) (*AllParams, error)
- func (p *Provider) GetAllParamsWithCtx(ctx context.Context, options *GetAllParamsOptions) (*AllParams, error)
- func (p *Provider) GetApp(address string, options *GetAppOptions) (*GetAppOutput, error)
- func (p *Provider) GetAppWithCtx(ctx context.Context, address string, options *GetAppOptions) (*GetAppOutput, error)
- func (p *Provider) GetApps(options *GetAppsOptions) (*GetAppsOutput, error)
- func (p *Provider) GetAppsWithCtx(ctx context.Context, options *GetAppsOptions) (*GetAppsOutput, error)
- func (p *Provider) GetBalance(address string, options *GetBalanceOptions) (*big.Int, error)
- func (p *Provider) GetBalanceWithCtx(ctx context.Context, address string, options *GetBalanceOptions) (*big.Int, error)
- func (p *Provider) GetBlock(blockNumber int) (*GetBlockOutput, error)
- func (p *Provider) GetBlockHeight() (int, error)
- func (p *Provider) GetBlockHeightWithCtx(ctx context.Context) (int, error)
- func (p *Provider) GetBlockTransactions(options *GetBlockTransactionsOptions) (*GetBlockTransactionsOutput, error)
- func (p *Provider) GetBlockTransactionsWithCtx(ctx context.Context, options *GetBlockTransactionsOptions) (*GetBlockTransactionsOutput, error)
- func (p *Provider) GetBlockWithCtx(ctx context.Context, blockNumber int) (*GetBlockOutput, error)
- func (p *Provider) GetNode(address string, options *GetNodeOptions) (*GetNodeOutput, error)
- func (p *Provider) GetNodeBlockHeight(ctx context.Context, url string) (int, error)
- func (p *Provider) GetNodeWithCtx(ctx context.Context, address string, options *GetNodeOptions) (*GetNodeOutput, error)
- func (p *Provider) GetNodes(options *GetNodesOptions) (*GetNodesOutput, error)
- func (p *Provider) GetNodesWithCtx(ctx context.Context, options *GetNodesOptions) (*GetNodesOutput, error)
- func (p *Provider) GetSession(ctx context.Context, chain, appPublicKey string) (Session, error)
- func (p *Provider) GetTransaction(transactionHash string, options *GetTransactionOptions) (*GetTransactionOutput, error)
- func (p *Provider) GetTransactionWithCtx(ctx context.Context, transactionHash string, options *GetTransactionOptions) (*GetTransactionOutput, error)
- func (p *Provider) GetType(address string, options *GetTypeOptions) (AddressType, error)
- func (p *Provider) GetTypeWithCtx(ctx context.Context, address string, options *GetTypeOptions) (AddressType, error)
- func (p *Provider) Relay(rpcURL string, input *RelayInput, options *RelayRequestOptions) (*RelayOutput, error)
- func (p *Provider) RelayWithCtx(ctx context.Context, rpcURL string, input *RelayInput, ...) (*RelayOutput, error)
- func (p *Provider) ResetRequestConfigToDefault()
- func (p *Provider) SendTransaction(input *SendTransactionInput) (*SendTransactionOutput, error)
- func (p *Provider) SendTransactionWithCtx(ctx context.Context, input *SendTransactionInput) (*SendTransactionOutput, error)
- func (p *Provider) UpdateRequestConfig(opts RequestConfigOpts)
- type RPCError
- type RelayError
- type RelayErrorCode
- type RelayErrorOutput
- type RelayHeaders
- type RelayInput
- type RelayMeta
- type RelayOutput
- type RelayPayload
- type RelayProof
- type RelayRequestOptions
- type RequestConfigOpts
- type SendTransactionInput
- type SendTransactionOutput
- type Session
- type SessionHeader
- type StakingStatus
- type StdTx
- type Transaction
- type TransactionProof
- type TxMsg
- type TxResult
- type TxSignature
- type V1RPCRoute
Constants ¶
const ( // DefaultStatusCode means the response was accepted but we don't know if it actually succeeded DefaultStatusCode = http.StatusAccepted )
Variables ¶
var ( // Err4xxOnConnection error when RPC responds with 4xx code Err4xxOnConnection = errors.New("rpc responded with 4xx") // Err5xxOnConnection error when RPC responds with 5xx code Err5xxOnConnection = errors.New("rpc responded with 5xx") // ErrUnexpectedCodeOnConnection error when RPC responds with unexpected code ErrUnexpectedCodeOnConnection = errors.New("rpc responded with unexpected code") // ErrNonJSONResponse error when provider does not respond with a JSON ErrNonJSONResponse = errors.New("non JSON response") )
Functions ¶
func IsErrorCode ¶
func IsErrorCode(code RelayErrorCode, err error) bool
IsErrorCode returns if error has the same relay error code as input
Types ¶
type AddressType ¶
type AddressType string
AddressType enum listing all address types
const ( // NodeType represents node type NodeType AddressType = "node" // AppType represents app type AppType AddressType = "app" // AccountType represents account type AccountType AddressType = "account" )
type AllParams ¶ added in v0.10.1
type AllParams struct {
AppParams ParamGroup `json:"app_params"`
AuthParams ParamGroup `json:"auth_params"`
GovParams ParamGroup `json:"gov_params"`
NodeParams ParamGroup `json:"node_params"`
PocketParams ParamGroup `json:"pocket_params"`
}
AllParams represents the output for AllParams request
type App ¶ added in v0.10.2
type App struct {
Address string `json:"address"`
PublicKey string `json:"public_key"`
Jailed bool `json:"jailed"`
Status int `json:"status"`
Chains []string `json:"chains"`
StakedTokens string `json:"staked_tokens"`
MaxRelays string `json:"max_relays"`
UnstakingTime time.Time `json:"unstaking_time"`
}
App represents app from RPC request
type DispatchOutput ¶
type DispatchOutput struct {
BlockHeight int `json:"block_height"`
Session *Session `json:"session"`
}
DispatchOutput represents output for Dispatch request
type DispatchRequestOptions ¶
type DispatchRequestOptions struct {
Height int
RejectSelfSignedCertificates bool
Headers http.Header
}
DispatchRequestOptions represents optional arguments for Dispatch request
type GetAccountOptions ¶
type GetAccountOptions struct {
Height int
}
GetAccountOptions represents optional arguments for GetAccount request
type GetAccountOutput ¶
type GetAccountOutput struct {
Address string `json:"address"`
Coins []struct {
Amount string `json:"amount"`
Denom string `json:"denom"`
} `json:"coins"`
PublicKey string `json:"public_key"`
}
GetAccountOutput represents output for GetAccount request
type GetAccountTransactionsOptions ¶
type GetAccountTransactionsOptions struct {
Page int
PerPage int
Prove bool
Received bool
Order Order
}
GetAccountTransactionsOptions represents optional arguments for GetAccountTransactions request
type GetAccountTransactionsOutput ¶
type GetAccountTransactionsOutput struct {
PageCount int `json:"page_count"`
TotalTxs int `json:"total_txs"`
Txs []*Transaction `json:"txs"`
}
GetAccountTransactionsOutput represents output for GetAccountTransactions request
type GetAccountsOptions ¶ added in v0.10.6
GetAccountsOptions represents optional arguments for GetAccounts request
type GetAccountsOutput ¶ added in v0.10.6
type GetAccountsOutput struct {
Result []*GetAccountOutput `json:"result"`
Page int `json:"page"`
TotalPages int `json:"total_pages"`
}
GetAccountsOutput represents output for GetAccounts request
type GetAllParamsOptions ¶ added in v0.10.1
type GetAllParamsOptions struct {
Height int
// URL specifies the URL of the node to which the request should be sent.
// If unspecified, the default URL (i.e. that of a dispatcher or a random node) will be used
URL string
}
GetAllParamsOptions represents optional arguments for GetAllParams request
type GetAppOptions ¶
type GetAppOptions struct {
Height int
}
GetAppOptions represents optional arguments for GetApp request
type GetAppOutput ¶
type GetAppOutput struct {
*App
}
GetAppOutput represents output for GetApp request
type GetAppsOptions ¶
type GetAppsOptions struct {
Height int
StakingStatus StakingStatus
Page int
PerPage int
BlockChain string
Headers http.Header
}
GetAppsOptions represents optional arguments for GetApps request
type GetAppsOutput ¶
type GetAppsOutput struct {
Result []*App `json:"result"`
Page int `json:"page"`
TotalPages int `json:"total_pages"`
}
GetAppsOutput represents output for GetApps request
type GetBalanceOptions ¶
type GetBalanceOptions struct {
Height int
}
GetBalanceOptions represents optional arguments for GetBalance request
type GetBlockOutput ¶
type GetBlockOutput struct {
Block struct {
Data struct {
Txs []string `json:"txs"`
} `json:"data"`
Evidence struct {
Evidence []any `json:"evidence"`
} `json:"evidence"`
Header struct {
AppHash string `json:"app_hash"`
ChainID string `json:"chain_id"`
ConsensusHash string `json:"consensus_hash"`
DataHash string `json:"data_hash"`
EvidenceHash string `json:"evidence_hash"`
Height string `json:"height"`
LastBlockID struct {
Hash string `json:"hash"`
Parts struct {
Hash string `json:"hash"`
Total string `json:"total"`
} `json:"parts"`
} `json:"last_block_id"`
LastCommitHash string `json:"last_commit_hash"`
LastResultsHash string `json:"last_results_hash"`
NextValidatorsHash string `json:"next_validators_hash"`
NumTxs string `json:"num_txs"`
ProposerAddress string `json:"proposer_address"`
Time time.Time `json:"time"`
TotalTxs string `json:"total_txs"`
ValidatorsHash string `json:"validators_hash"`
Version struct {
App string `json:"app"`
Block string `json:"block"`
} `json:"version"`
} `json:"header"`
LastCommit struct {
BlockID struct {
Hash string `json:"hash"`
Parts struct {
Hash string `json:"hash"`
Total string `json:"total"`
} `json:"parts"`
} `json:"block_id"`
Precommits []struct {
BlockID struct {
Hash string `json:"hash"`
Parts struct {
Hash string `json:"hash"`
Total string `json:"total"`
} `json:"parts"`
} `json:"block_id"`
Height string `json:"height"`
Round string `json:"round"`
Signature string `json:"signature"`
Timestamp time.Time `json:"timestamp"`
Type int `json:"type"`
ValidatorAddress string `json:"validator_address"`
ValidatorIndex string `json:"validator_index"`
} `json:"precommits"`
} `json:"last_commit"`
} `json:"block"`
BlockID struct {
Hash string `json:"hash"`
Parts struct {
Hash string `json:"hash"`
Total string `json:"total"`
} `json:"parts"`
} `json:"block_id"`
}
GetBlockOutput represents output for GetBlock request
type GetBlockTransactionsOptions ¶ added in v0.9.1
GetBlockTransactionsOptions represents optional arguments for GetBlockTransactions request
type GetBlockTransactionsOutput ¶ added in v0.9.1
type GetBlockTransactionsOutput struct {
PageCount int `json:"page_count"`
TotalTxs int `json:"total_txs"`
Txs []*Transaction `json:"txs"`
}
GetBlockTransactionsOutput represents output for GetBlockTransactions request
type GetNodeOptions ¶
type GetNodeOptions struct {
Height int
}
GetNodeOptions represents optional arguments for GetNode request
type GetNodeOutput ¶
type GetNodeOutput struct {
*Node
}
GetNodeOutput represents output for GetNode request
type GetNodesOptions ¶
type GetNodesOptions struct {
Height int
StakingStatus StakingStatus
Page int
PerPage int
BlockChain string
JailedStatus JailedStatus
}
GetNodesOptions represents optional arguments for GetNodes request
type GetNodesOutput ¶
type GetNodesOutput struct {
Result []*Node `json:"result"`
Page int `json:"page"`
TotalPages int `json:"total_pages"`
}
GetNodesOutput represents output for GetNodes request
type GetTransactionOptions ¶
type GetTransactionOptions struct {
Prove bool
}
GetTransactionOptions represents the optional arguments for a GetTransaction request
type GetTransactionOutput ¶
type GetTransactionOutput struct {
*Transaction
}
GetTransactionOutput represents output for GetTransaction request
type GetTypeOptions ¶
type GetTypeOptions struct {
Height int
}
GetTypeOptions represents optional arguments for GetType request
type JailedStatus ¶
type JailedStatus int
JailedStatus enum that represents jailed status
const ( // Jailed status is when a node has been jailed due to missing a determined amount of blocks and/or byzantine behavior and thus cannot serve relays nor participate in consensus Jailed JailedStatus = iota + 1 // Unjailed status is when a node is not jailed and thus can serve relays Unjailed )
type Node ¶
type Node struct {
Address string `json:"address"`
Chains []string `json:"chains"`
Jailed bool `json:"jailed"`
PublicKey string `json:"public_key"`
ServiceURL string `json:"service_url"`
Status int `json:"status"`
Tokens string `json:"tokens"`
UnstakingTime time.Time `json:"unstaking_time"`
OutputAddress string `json:"output_address"`
}
Node represents node output from RPC request
type Order ¶
type Order string
Order enum that represents the order which RPC requests should return their outputs
type ParamGroup ¶ added in v0.10.1
type ParamGroup []Param
ParamGroup is shorthand for a slice of Param
type PocketAAT ¶
type PocketAAT struct {
Version string `json:"version"`
AppPubKey string `json:"app_pub_key"`
ClientPubKey string `json:"client_pub_key"`
Signature string `json:"signature"`
}
PocketAAT represents a Pocket Application Authentication Token
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider struct handler por JSON RPC provider
func NewProvider ¶
NewProvider returns Provider instance from input
func (*Provider) Dispatch ¶
func (p *Provider) Dispatch(appPublicKey, chain string, options *DispatchRequestOptions) (*DispatchOutput, error)
TODO_TECHDEBT: Dispatch and DispatchWithCtx are deprecated and will be removed in the next major release: use GetSession instead. Dispatch sends a dispatch request to the network and gets the nodes that will be servicing the requests for the session.
func (*Provider) DispatchWithCtx ¶ added in v0.13.1
func (p *Provider) DispatchWithCtx(ctx context.Context, appPublicKey, chain string, options *DispatchRequestOptions) (*DispatchOutput, error)
DispatchWithCtx sends a dispatch request to the network and gets the nodes that will be servicing the requests for the session.
func (*Provider) GetAccount ¶
func (p *Provider) GetAccount(address string, options *GetAccountOptions) (*GetAccountOutput, error)
GetAccount returns account at the specified address
func (*Provider) GetAccountTransactions ¶
func (p *Provider) GetAccountTransactions(address string, options *GetAccountTransactionsOptions) (*GetAccountTransactionsOutput, error)
GetAccountTransactions returns transactions of given address' account
func (*Provider) GetAccountTransactionsWithCtx ¶ added in v0.13.1
func (p *Provider) GetAccountTransactionsWithCtx(ctx context.Context, address string, options *GetAccountTransactionsOptions) (*GetAccountTransactionsOutput, error)
GetAccountTransactionsWithCtx returns transactions of given address' account
func (*Provider) GetAccountWithCtx ¶ added in v0.13.1
func (p *Provider) GetAccountWithCtx(ctx context.Context, address string, options *GetAccountOptions) (*GetAccountOutput, error)
GetAccountWithCtx returns account at the specified address
func (*Provider) GetAccounts ¶ added in v0.10.6
func (p *Provider) GetAccounts(options *GetAccountsOptions) (*GetAccountsOutput, error)
GetAccounts returns a page of accounts known at the specified height and with options empty options returns all accounts on last height, page < 1 returns the first page, per_page < 1 returns 10000 elements per page
func (*Provider) GetAccountsWithCtx ¶ added in v0.13.1
func (p *Provider) GetAccountsWithCtx(ctx context.Context, options *GetAccountsOptions) (*GetAccountsOutput, error)
GetAccountsWithCtx returns a page of accounts known at the specified height and with options empty options returns all accounts on last height, page < 1 returns the first page, per_page < 1 returns 10000 elements per page
func (*Provider) GetAllApps ¶ added in v0.20.9
GetAllApps returns all on-chain applications by choosing correct values for options when sending an apps query to a full node. This is a convenience function to allow getting the list of all on-chain applications with no need for setting any options.
func (*Provider) GetAllParams ¶ added in v0.10.1
func (p *Provider) GetAllParams(options *GetAllParamsOptions) (*AllParams, error)
GetAllParams returns the params at the specified height
func (*Provider) GetAllParamsWithCtx ¶ added in v0.13.1
func (p *Provider) GetAllParamsWithCtx(ctx context.Context, options *GetAllParamsOptions) (*AllParams, error)
GetAllParamsWithCtx returns the params at the specified height
func (*Provider) GetApp ¶
func (p *Provider) GetApp(address string, options *GetAppOptions) (*GetAppOutput, error)
GetApp returns the app at the specified height, height = 0 is used as latest
func (*Provider) GetAppWithCtx ¶ added in v0.13.1
func (p *Provider) GetAppWithCtx(ctx context.Context, address string, options *GetAppOptions) (*GetAppOutput, error)
GetAppWithCtx returns the app at the specified height, height = 0 is used as latest
func (*Provider) GetApps ¶
func (p *Provider) GetApps(options *GetAppsOptions) (*GetAppsOutput, error)
GetApps returns a page of applications known at the specified height and staking status empty ("") staking_status returns all apps, page < 1 returns the first page, per_page < 1 returns 10000 elements per page
func (*Provider) GetAppsWithCtx ¶ added in v0.13.1
func (p *Provider) GetAppsWithCtx(ctx context.Context, options *GetAppsOptions) (*GetAppsOutput, error)
GetAppsWithCtx returns a page of applications known at the specified height and staking status empty ("") staking_status returns all apps, page < 1 returns the first page, per_page < 1 returns 10000 elements per page
func (*Provider) GetBalance ¶
GetBalance requests the balance of the specified address
func (*Provider) GetBalanceWithCtx ¶ added in v0.13.1
func (p *Provider) GetBalanceWithCtx(ctx context.Context, address string, options *GetBalanceOptions) (*big.Int, error)
GetBalanceWithCtx requests the balance of the specified address
func (*Provider) GetBlock ¶
func (p *Provider) GetBlock(blockNumber int) (*GetBlockOutput, error)
GetBlock returns the block structure at the specified height, height = 0 is used as latest
func (*Provider) GetBlockHeight ¶
GetBlockHeight returns the current height
func (*Provider) GetBlockHeightWithCtx ¶ added in v0.13.1
GetBlockHeightWithCtx returns the current height
func (*Provider) GetBlockTransactions ¶ added in v0.9.1
func (p *Provider) GetBlockTransactions(options *GetBlockTransactionsOptions) (*GetBlockTransactionsOutput, error)
GetBlockTransactions returns transactions of given block
func (*Provider) GetBlockTransactionsWithCtx ¶ added in v0.13.1
func (p *Provider) GetBlockTransactionsWithCtx(ctx context.Context, options *GetBlockTransactionsOptions) (*GetBlockTransactionsOutput, error)
GetBlockTransactionsWithCtx returns transactions of given block
func (*Provider) GetBlockWithCtx ¶ added in v0.13.1
GetBlockWithCtx returns the block structure at the specified height, height = 0 is used as latest
func (*Provider) GetNode ¶
func (p *Provider) GetNode(address string, options *GetNodeOptions) (*GetNodeOutput, error)
GetNode returns the node at the specified height, height = 0 is used as latest
func (*Provider) GetNodeBlockHeight ¶ added in v0.17.0
GetNodeBlockHeight returns the blockheight reported by a specific node
func (*Provider) GetNodeWithCtx ¶ added in v0.13.1
func (p *Provider) GetNodeWithCtx(ctx context.Context, address string, options *GetNodeOptions) (*GetNodeOutput, error)
GetNodeWithCtx returns the node at the specified height, height = 0 is used as latest
func (*Provider) GetNodes ¶
func (p *Provider) GetNodes(options *GetNodesOptions) (*GetNodesOutput, error)
GetNodes returns a page of nodes known at the specified height and with options empty options returns all validators, page < 1 returns the first page, per_page < 1 returns 10000 elements per page
func (*Provider) GetNodesWithCtx ¶ added in v0.13.1
func (p *Provider) GetNodesWithCtx(ctx context.Context, options *GetNodesOptions) (*GetNodesOutput, error)
GetNodesWithCtx returns a page of nodes known at the specified height and with options empty options returns all validators, page < 1 returns the first page, per_page < 1 returns 10000 elements per page
func (*Provider) GetSession ¶ added in v0.20.9
GetSession returns the session for the input application (identified by its public key) and chain.
func (*Provider) GetTransaction ¶
func (p *Provider) GetTransaction(transactionHash string, options *GetTransactionOptions) (*GetTransactionOutput, error)
GetTransaction returns the transaction by the given transaction hash
func (*Provider) GetTransactionWithCtx ¶ added in v0.13.1
func (p *Provider) GetTransactionWithCtx(ctx context.Context, transactionHash string, options *GetTransactionOptions) (*GetTransactionOutput, error)
GetTransactionWithCtx returns the transaction by the given transaction hash
func (*Provider) GetType ¶
func (p *Provider) GetType(address string, options *GetTypeOptions) (AddressType, error)
GetType returns type of given address
func (*Provider) GetTypeWithCtx ¶ added in v0.13.1
func (p *Provider) GetTypeWithCtx(ctx context.Context, address string, options *GetTypeOptions) (AddressType, error)
GetTypeWithCtx returns type of given address
func (*Provider) Relay ¶
func (p *Provider) Relay(rpcURL string, input *RelayInput, options *RelayRequestOptions) (*RelayOutput, error)
Relay does request to be relayed to a target blockchain Will always return with an output that includes the status code from the request
func (*Provider) RelayWithCtx ¶ added in v0.13.1
func (p *Provider) RelayWithCtx(ctx context.Context, rpcURL string, input *RelayInput, options *RelayRequestOptions) (*RelayOutput, error)
RelayWithCtx does request to be relayed to a target blockchain Will always return with an output that includes the status code from the request
func (*Provider) ResetRequestConfigToDefault ¶
func (p *Provider) ResetRequestConfigToDefault()
ResetRequestConfigToDefault resets request config to default
func (*Provider) SendTransaction ¶
func (p *Provider) SendTransaction(input *SendTransactionInput) (*SendTransactionOutput, error)
SendTransaction sends raw transaction to be relayed to a target address
func (*Provider) SendTransactionWithCtx ¶ added in v0.13.1
func (p *Provider) SendTransactionWithCtx(ctx context.Context, input *SendTransactionInput) (*SendTransactionOutput, error)
SendTransactionWithCtx sends raw transaction to be relayed to a target address
func (*Provider) UpdateRequestConfig ¶
func (p *Provider) UpdateRequestConfig(opts RequestConfigOpts)
UpdateRequestConfig updates the config used for RPC requests
type RelayError ¶
type RelayError struct {
Code RelayErrorCode
Codespace string
Message string
ServicerPubKey string
}
RelayError represents the thrown error of a relay request
func (*RelayError) Error ¶
func (e *RelayError) Error() string
Error returns string representation of error needed to implement error interface
type RelayErrorCode ¶
type RelayErrorCode int
RelayErrorCode is enum of possible relay error codes
const ( // AppNotFoundError error when app is not found AppNotFoundError RelayErrorCode = 45 // DuplicateProofError error when proof is used multiple times DuplicateProofError RelayErrorCode = 37 // EmptyPayloadDataError error when sent payload is empty EmptyPayloadDataError RelayErrorCode = 25 // EvidencedSealedError error when evidence is sealed, either max relays reached or claim already submitted EvidencedSealedError RelayErrorCode = 90 // HTTPExecutionError error when http request failed HTTPExecutionError RelayErrorCode = 28 // InvalidBlockHeightError error when sent block height is invalid InvalidBlockHeightError RelayErrorCode = 60 // InvalidSessionError error when session is invalid InvalidSessionError RelayErrorCode = 14 // OutOfSyncRequestError error when request is not on sync OutOfSyncRequestError RelayErrorCode = 75 // OverServiceError error when request exceeds service capacity OverServiceError RelayErrorCode = 71 // RequestHashError error when hash is not correct RequestHashError RelayErrorCode = 74 // UnsupportedBlockchainError error when sent blockchain is not supported yet UnsupportedBlockchainError RelayErrorCode = 76 )
type RelayErrorOutput ¶
type RelayErrorOutput struct {
Error struct {
Code RelayErrorCode `json:"code"`
Codespace string `json:"codespace"`
Message string `json:"message"`
} `json:"error"`
}
RelayErrorOutput represents error response of relay request
type RelayInput ¶
type RelayInput struct {
Payload *RelayPayload `json:"payload"`
Meta *RelayMeta `json:"meta"`
Proof *RelayProof `json:"proof"`
}
RelayInput represents input needed to do a Relay to Pocket
type RelayMeta ¶
type RelayMeta struct {
BlockHeight int `json:"block_height"`
}
RelayMeta represents metadata of a relay
type RelayOutput ¶
type RelayOutput struct {
Response string `json:"response"`
Signature string `json:"signature"`
StatusCode int `json:"statusCode"`
}
RelayOutput represents the Relay RPC output
type RelayPayload ¶
type RelayPayload struct {
Data string `json:"data"`
Method string `json:"method"`
Path string `json:"path"`
Headers RelayHeaders `json:"headers"`
}
RelayPayload represents payload of a relay
type RelayProof ¶
type RelayProof struct {
RequestHash string `json:"request_hash"`
Entropy int64 `json:"entropy"`
SessionBlockHeight int `json:"session_block_height"`
ServicerPubKey string `json:"servicer_pub_key"`
Blockchain string `json:"blockchain"`
AAT *PocketAAT `json:"aat"`
Signature string `json:"signature"`
}
RelayProof represents proof of a relay
type RelayRequestOptions ¶
type RelayRequestOptions struct {
RejectSelfSignedCertificates bool
}
RelayRequestOptions represents optional arguments for Relay request
type RequestConfigOpts ¶ added in v0.13.0
type RequestConfigOpts struct {
Retries int
Timeout time.Duration
Transport http.RoundTripper
}
RequestConfigOpts are the optional values for request config
type SendTransactionInput ¶
type SendTransactionInput struct {
Address string `json:"address"`
RawHexBytes string `json:"raw_hex_bytes"`
}
SendTransactionInput represents input needed for SendTransaction request
type SendTransactionOutput ¶
type SendTransactionOutput struct {
Height string `json:"height"`
Txhash string `json:"txhash"`
RawLog string `json:"raw_log"`
Logs []struct {
MsgIndex int `json:"msg_index"`
Success bool `json:"success"`
Log string `json:"log"`
Events []struct {
Type string `json:"type"`
Attributes []struct {
Key string `json:"key"`
Value string `json:"value"`
} `json:"attributes"`
} `json:"events"`
} `json:"logs"`
}
SendTransactionOutput represents output for SendTransaction request
type Session ¶
type Session struct {
Header SessionHeader `json:"header"`
Key string `json:"key"`
Nodes []Node `json:"nodes"`
}
Session represents session output from RPC request
type SessionHeader ¶
type SessionHeader struct {
AppPublicKey string `json:"app_public_key"`
Chain string `json:"chain"`
SessionHeight int `json:"session_height"`
}
SessionHeader represents the headers of a session output
type StakingStatus ¶
type StakingStatus int
StakingStatus enum that represents staking status
const ( // Unstaked represents unstaked status Unstaked StakingStatus = iota // Unstaking represents unstaking status Unstaking // Staked represents staked status Staked )
type StdTx ¶ added in v0.9.3
type StdTx struct {
Entropy int64 `json:"entropy"`
Fee []*Fee `json:"fee"`
Memo string `json:"memo"`
Msg *TxMsg `json:"msg"`
Signature *TxSignature `json:"signature"`
}
StdTx represents standard transaction fields
type Transaction ¶ added in v0.9.1
type Transaction struct {
Hash string `json:"hash"`
Height int `json:"height"`
Index int `json:"index"`
Proof *TransactionProof `json:"proof"`
StdTx *StdTx `json:"stdTx"`
Tx string `json:"tx"`
TxResult *TxResult `json:"tx_result"`
}
Transaction represents a transaction in Pocket
type TransactionProof ¶ added in v0.9.3
type TransactionProof struct {
Data string `json:"data"`
Proof struct {
Aunts []string `json:"aunts"`
Index int `json:"index"`
LeafHash string `json:"leaf_hash"`
Total int `json:"total"`
} `json:"proof"`
RootHash string `json:"root_hash"`
}
TransactionProof represents the proof of transaction
type TxResult ¶ added in v0.9.3
type TxResult struct {
Code int `json:"code"`
Codespace string `json:"codespace"`
Data string `json:"data"`
Events string `json:"events"`
Info string `json:"info"`
Log string `json:"log"`
MessageType string `json:"message_type"`
Recipient string `json:"recipient"`
Signer string `json:"signer"`
}
TxResult represents transaction result
type TxSignature ¶ added in v0.9.5
TxSignature represents values of transaction signature
type V1RPCRoute ¶
type V1RPCRoute string
V1RPCRoute enum listing all the routes in the V1 RPC interface
const ( // ClientChallengeRoute represents client challenge route ClientChallengeRoute V1RPCRoute = "/v1/client/challenge" // ClientDispatchRoute represents client dispatch route ClientDispatchRoute V1RPCRoute = "/v1/client/dispatch" // ClientRawTXRoute represents cliente raw TX route ClientRawTXRoute V1RPCRoute = "/v1/client/rawtx" // ClientRelayRoute represents client realy route ClientRelayRoute V1RPCRoute = "/v1/client/relay" // QueryAccountRoute represents query account route QueryAccountRoute V1RPCRoute = "/v1/query/account" // QueryAccountsRoute represents query accounts route QueryAccountsRoute V1RPCRoute = "/v1/query/accounts" // QueryAccountTXsRoute represents query account TXs route QueryAccountTXsRoute V1RPCRoute = "/v1/query/accounttxs" // QueryAllParamsRoute represents query all params route QueryAllParamsRoute V1RPCRoute = "/v1/query/allparams" // QueryAppRoute represents query app route QueryAppRoute V1RPCRoute = "/v1/query/app" // QueryAppParamsRoute represents query app params route QueryAppParamsRoute V1RPCRoute = "/v1/query/appparams" // QueryAppsRoute represents query apps route QueryAppsRoute V1RPCRoute = "/v1/query/apps" // QueryBalanceRoute represents query balance route QueryBalanceRoute V1RPCRoute = "/v1/query/balance" // QueryBlockRoute represents query block route QueryBlockRoute V1RPCRoute = "/v1/query/block" // QueryBlockTXsRoute represents query block TXs route QueryBlockTXsRoute V1RPCRoute = "/v1/query/blocktxs" // QueryHeightRoute represents query height route QueryHeightRoute V1RPCRoute = "/v1/query/height" // QueryNodeRoute represents query node route QueryNodeRoute V1RPCRoute = "/v1/query/node" // QueryNodeClaimRoute represents query node claim route QueryNodeClaimRoute V1RPCRoute = "/v1/query/nodeclaim" // QueryNodeClaimsRoute represents query node claims route QueryNodeClaimsRoute V1RPCRoute = "/v1/query/nodeclaims" // QueryNodeParamsRoute represents query node params route QueryNodeParamsRoute V1RPCRoute = "/v1/query/nodeparams" // QueryNodeReceiptRoute represents query node receipt route QueryNodeReceiptRoute V1RPCRoute = "/v1/query/nodereceipt" // QueryNodeReceiptsRoute represents query node receipts route QueryNodeReceiptsRoute V1RPCRoute = "/v1/query/nodereceipts" // QueryNodesRoute represents query nodes route QueryNodesRoute V1RPCRoute = "/v1/query/nodes" // QueryPocketParamsRoute represents query pocket params route QueryPocketParamsRoute V1RPCRoute = "/v1/query/pocketparams" // QuerySupplyRoute represents query supply route QuerySupplyRoute V1RPCRoute = "/v1/query/supply" // QuerySupportedChainsRoute represents query supported chains route QuerySupportedChainsRoute V1RPCRoute = "/v1/query/supportedchains" // QueryTXRoute represents query TX route QueryTXRoute V1RPCRoute = "/v1/query/tx" // QueryUpgradeRoute represents query upgrade route QueryUpgradeRoute V1RPCRoute = "/v1/query/upgrade" )