responses

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InternalErrMsg = "internal system error"

InternalErrMsg is the common response returned to the user when an InternalError occurs

Functions

func DecodeResponse

func DecodeResponse[T any](encoded []byte) (*T, error)

DecodeResponse - Extracts the user response from a decrypted bytes field and returns the result or nil and optional error.

func ToInternalError

func ToInternalError(err error) error

ToInternalError - Converts an error to an InternalError

Types

type Balance

type Balance = EnclaveResponse // The response for an RPC getBalance request, as a JSON object encrypted with the viewing key of the user.

type BalanceType

type BalanceType = hexutil.Big

type Call

type Call = EnclaveResponse // As above, but for an RPC call request.

type CallType

type CallType = string

type EnclaveResponse

type EnclaveResponse struct {
	EncUserResponse EncryptedUserResponse
	Err             *string
}

EnclaveResponse - The response that the enclave returns for sensitive API calls The user response is encrypted while the error is in plaintext

func AsEmptyResponse

func AsEmptyResponse() *EnclaveResponse

AsEmptyResponse - Creates an empty enclave response. Useful for when no error encountered but also no result found.

func AsEncryptedEmptyResponse added in v0.22.0

func AsEncryptedEmptyResponse(encryptHandler Encryptor) *EnclaveResponse

AsEncryptedEmptyResponse - encrypts an empty message

func AsEncryptedError

func AsEncryptedError(err error, encrypt Encryptor) *EnclaveResponse

AsEncryptedError - Encodes and encrypts an error to be returned for a concrete user.

func AsEncryptedResponse

func AsEncryptedResponse[T any](data *T, encryptHandler Encryptor) *EnclaveResponse

AsEncryptedResponse - wraps the data passed into the proper format, serializes it and encrypts it. It is then encoded in a plaintext response.

func AsPlaintextError

func AsPlaintextError(err error) *EnclaveResponse

AsPlaintextError - generates a plaintext response containing a visible to the host error.

func AsPlaintextResponse

func AsPlaintextResponse(encResp EncryptedUserResponse) *EnclaveResponse

AsPlaintextResponse - creates the plaintext part of the enclave response It would be visible that there is an enclave response, but the bytes in it will still be encrypted todo - rename

func AsSystemErr

func AsSystemErr() *EnclaveResponse

AsSystemErr - generates a plaintext response containing a visible error.

func ToEnclaveResponse

func ToEnclaveResponse(encoded []byte) *EnclaveResponse

ToEnclaveResponse - Converts an encoded plaintext into an enclave response

func (*EnclaveResponse) Encode

func (er *EnclaveResponse) Encode() []byte

Encode - serializes the enclave response into a json

func (*EnclaveResponse) Error

func (er *EnclaveResponse) Error() error

type EncryptedUserResponse

type EncryptedUserResponse []byte

EncryptedUserResponse - This is the encoded & encrypted form of a UserResponse[Type]

type Encryptor added in v0.22.0

type Encryptor interface {
	Encrypt(bytes []byte) ([]byte, error)
}

type Gas

type Gas = EnclaveResponse // As above, but for an RPC estimateGas response.

type GasPriceType added in v0.21.0

type GasPriceType = hexutil.Big

type GasType

type GasType = hexutil.Uint64

type Logs

type Logs = EnclaveResponse

type LogsType

type LogsType = []*types.Log

type NonceType

type NonceType = string

type PrivateQueryResponse

type PrivateQueryResponse = EnclaveResponse

type RawTx

type RawTx = EnclaveResponse // As above, but for an RPC sendRawTransaction request.

type RawTxType

type RawTxType = common.Hash

type ReceiptType

type ReceiptType = types.Receipt

type Receipts

type Receipts = EnclaveResponse

type TxByHash

type TxByHash = EnclaveResponse // As above, but for an RPC getTransactionByHash request.

type TxCount

type TxCount = EnclaveResponse // As above, but for an RPC getTransactionCount request.

type TxReceipt

type TxReceipt = EnclaveResponse // As above, but for an RPC getTransactionReceipt request.

type TxType

type TxType = types.Transaction

type UserResponse

type UserResponse[T any] struct {
	Result *T
	ErrStr *string
}

UserResponse - The response struct that contains either data or result which will be decoded only on the client side.

func (*UserResponse[T]) Error

func (ur *UserResponse[T]) Error() error

Error - converts the encoded string in the response into a normal error and returns it.

type ViewingKeyEncryptor

type ViewingKeyEncryptor func([]byte) ([]byte, error)

Jump to

Keyboard shortcuts

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