Documentation
¶
Index ¶
- Constants
- func EncodeTx(tx *entity.Tx) ([]byte, error)
- func SignTx(txSigner *entity.TxSigner, chainId string, nonceTime entity.Time, ...) *entity.Tx
- func UnmarshalApiResponse(apiResponse *entityApi.RawResponse, dest interface{}) error
- type Client
- type FastHttpClient
- func (c FastHttpClient) AddHeader(key string, value string)
- func (c FastHttpClient) Get(route string, headers map[string]string, queryValues map[string]string) (*api.RawResponse, error)
- func (c FastHttpClient) Post(route string, body []byte, headers map[string]string, ...) (*api.RawResponse, error)
- func (c FastHttpClient) RemoveHeader(key string)
- type Handler
- func (h *Handler) GetAndFormat(route string, queryParams map[string]string, instance interface{}) error
- func (h *Handler) RetrieveCertificate(fqId string) (entity.TxData, error)
- func (h *Handler) RetrieveCertificateTxs(fqId string, page int, txPerPage int) (*entityApi.TxResults, error)
- func (h *Handler) RetrieveCompanyKeys(companyBcId string, page int, txPerPage int) ([]*account.KeyV1, error)
- func (h *Handler) RetrieveKey(fqId string) (*account.KeyV1, error)
- func (h *Handler) RetrieveKeyTxs(fqId string, page int, txPerPage int) (*entityApi.TxResults, error)
- func (h *Handler) RetrieveLastCertificateTx(fqId string) (*entityApi.TxResult, error)
- func (h *Handler) RetrieveLastKeyTx(fqId string) (*entityApi.TxResult, error)
- func (h *Handler) RetrieveLastSecretTx(fqId string) (*entityApi.TxResult, error)
- func (h *Handler) RetrieveSecret(fqId string) (entity.TxData, error)
- func (h *Handler) RetrieveSecretTxs(fqId string, page int, txPerPage int) (*entityApi.TxResults, error)
- func (h *Handler) RetrieveTx(hash string) (*entityApi.TxResult, error)
- func (h *Handler) SafeGet(route string, queryParams map[string]string) (_ *entityApi.RawResponse, katenaError error)
- func (h *Handler) SafePost(route string, body []byte) (_ *entityApi.RawResponse, katenaError error)
- func (h *Handler) SendRawTx(txBytes []byte) (*entityApi.SendTxResult, error)
- func (h *Handler) SendTx(txData entity.TxData, txSigner *entity.TxSigner, chainId string) (status *entityApi.SendTxResult, err error)
Constants ¶
const ( LastPath = "/last" StatePath = "/state" TxsPath = "/txs" CertificatesPath = "/certificates" SecretsPath = "/secrets" CompaniesPath = "/companies" KeysPath = "/keys" )
Variables ¶
This section is empty.
Functions ¶
func EncodeTx ¶ added in v1.3.0
EncodeTx defines the way the tx is encoded (here with the json marshaller).
func SignTx ¶ added in v1.3.0
func SignTx(txSigner *entity.TxSigner, chainId string, nonceTime entity.Time, txData entity.TxData) *entity.Tx
SignTx creates a tx data state, signs it and returns a tx ready to be encoded and sent.
func UnmarshalApiResponse ¶ added in v1.3.0
func UnmarshalApiResponse(apiResponse *entityApi.RawResponse, dest interface{}) error
UnmarshalApiResponse tries to parse the api response body into the provided interface if the API returns a 200 or a 202 HTTP code. If not, it tries to parse it in a PublicError.
Types ¶
type Client ¶ added in v1.4.0
type Client interface { Get(route string, headers map[string]string, queryValues map[string]string) (*api.RawResponse, error) Post(route string, body []byte, headers map[string]string, queryValues map[string]string) (*api.RawResponse, error) AddHeader(key string, value string) RemoveHeader(key string) }
Client interface defines the methods a concrete client must implement.
type FastHttpClient ¶ added in v1.4.0
type FastHttpClient struct {
// contains filtered or unexported fields
}
FastHttpClient is a fasthttp.FastHttpClient wrapper to dialog with a JSON API.
func NewFastHttpClient ¶ added in v1.4.0
func NewFastHttpClient(apiUrl string) *FastHttpClient
FastHttpClient constructor.
func (FastHttpClient) AddHeader ¶ added in v1.4.0
func (c FastHttpClient) AddHeader(key string, value string)
AddHeader adds a persistent header that will be sent in every future doRequest calls.
func (FastHttpClient) Get ¶ added in v1.4.0
func (c FastHttpClient) Get( route string, headers map[string]string, queryValues map[string]string, ) (*api.RawResponse, error)
Get wraps the doRequest method to do a GET HTTP request.
func (FastHttpClient) Post ¶ added in v1.4.0
func (c FastHttpClient) Post( route string, body []byte, headers map[string]string, queryValues map[string]string, ) (*api.RawResponse, error)
Post wraps the doRequest method to do a POST HTTP request.
func (FastHttpClient) RemoveHeader ¶ added in v1.4.0
func (c FastHttpClient) RemoveHeader(key string)
RemoveHeader removes a persistent header.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler provides helper methods to send and retrieve txs without directly interacting with the HTTP Client.
func (*Handler) GetAndFormat ¶ added in v1.3.0
func (h *Handler) GetAndFormat(route string, queryParams map[string]string, instance interface{}) error
GetAndFormat fetches the API route and try to unmarshal the response in the provided instance.
func (*Handler) RetrieveCertificate ¶
RetrieveCertificate fetches the API and returns a certificate from the state.
func (*Handler) RetrieveCertificateTxs ¶ added in v1.3.0
func (h *Handler) RetrieveCertificateTxs(fqId string, page int, txPerPage int) (*entityApi.TxResults, error)
RetrieveCertificateTxs fetches the API to return all txs related to a certificate fqid.
func (*Handler) RetrieveCompanyKeys ¶ added in v1.1.0
func (h *Handler) RetrieveCompanyKeys(companyBcId string, page int, txPerPage int) ([]*account.KeyV1, error)
RetrieveCompanyKeys fetches the API and returns a list of keys for a company from the state.
func (*Handler) RetrieveKey ¶ added in v1.3.0
RetrieveKey fetches the API and returns a key from the state.
func (*Handler) RetrieveKeyTxs ¶ added in v1.3.0
func (h *Handler) RetrieveKeyTxs(fqId string, page int, txPerPage int) (*entityApi.TxResults, error)
RetrieveKeyTxs fetches the API to return all txs related to a key fqid.
func (*Handler) RetrieveLastCertificateTx ¶ added in v1.3.0
RetrieveLastCertificateTx fetches the API to return the last tx related to a certificate fqid.
func (*Handler) RetrieveLastKeyTx ¶ added in v1.3.0
RetrieveLastKeyTxs fetches the API to return the last txs related to a key fqid.
func (*Handler) RetrieveLastSecretTx ¶ added in v1.3.0
RetrieveLastSecretTxs fetches the API to return the last tx related to a secret fqid.
func (*Handler) RetrieveSecret ¶ added in v1.3.10
RetrieveSecret fetches the API and returns a secret from the state.
func (*Handler) RetrieveSecretTxs ¶ added in v1.3.0
func (h *Handler) RetrieveSecretTxs(fqId string, page int, txPerPage int) (*entityApi.TxResults, error)
RetrieveSecretTxs fetches the API to return all txs related to a secret fqid.
func (*Handler) RetrieveTx ¶ added in v1.1.0
RetrieveTx fetches the API to return any tx by its hash.
func (*Handler) SafeGet ¶ added in v1.1.0
func (h *Handler) SafeGet(route string, queryParams map[string]string) (_ *entityApi.RawResponse, katenaError error)
SafeGet calls the api handler get method and recover if it panics.
func (*Handler) SafePost ¶ added in v1.1.0
SafePost calls the api handler post method and recover if it panics.