Documentation ¶
Index ¶
- Constants
- Variables
- func SendSignRequestAdded(request *Request)
- func SendSignRequestFailed(request *Request, err error)
- type CompleteFunc
- type Meta
- type PendingRequests
- func (rs *PendingRequests) Add(ctx context.Context, method string, meta Meta, completeFunc CompleteFunc) (*Request, error)
- func (rs *PendingRequests) Approve(id string, password string, args *TxArgs, verify verifyFunc) Result
- func (rs *PendingRequests) Count() int
- func (rs *PendingRequests) Discard(id string) error
- func (rs *PendingRequests) First() *Request
- func (rs *PendingRequests) Get(id string) (*Request, error)
- func (rs *PendingRequests) Has(id string) bool
- func (rs *PendingRequests) Wait(id string, timeout time.Duration) Result
- type Request
- type Response
- type Result
- type TransientError
- type TxArgs
Constants ¶
const ( // SignRequestNoErrorCode is sent when no error occurred. SignRequestNoErrorCode = iota // SignRequestDefaultErrorCode is every case when there is no special tx return code. SignRequestDefaultErrorCode // SignRequestPasswordErrorCode is sent when account failed verification. SignRequestPasswordErrorCode // SignRequestTimeoutErrorCode is sent when tx is timed out. SignRequestTimeoutErrorCode // SignRequestDiscardedErrorCode is sent when tx was discarded. SignRequestDiscardedErrorCode )
const ( // MessageIDKey is a key for message ID // This ID is required to track from which chat a given send transaction request is coming. MessageIDKey = contextKey("message_id") )
Variables ¶
var ( //ErrSignReqNotFound - error sign request hash not found ErrSignReqNotFound = errors.New("sign request not found") //ErrSignReqInProgress - error sign request is in progress ErrSignReqInProgress = errors.New("sign request is in progress") //ErrSignReqTimedOut - error sign request sending timed out ErrSignReqTimedOut = errors.New("sign request sending timed out") //ErrSignReqDiscarded - error sign request discarded ErrSignReqDiscarded = errors.New("sign request has been discarded") )
var EmptyResponse = Response([]byte{})
EmptyResponse is returned when an error occures
Functions ¶
func SendSignRequestAdded ¶
func SendSignRequestAdded(request *Request)
SendSignRequestAdded sends a signal when a sign request is added.
func SendSignRequestFailed ¶
SendSignRequestFailed sends a signal only if error had happened
Types ¶
type CompleteFunc ¶
type CompleteFunc func(account *account.SelectedExtKey, password string, completeArgs *TxArgs) (Response, error)
CompleteFunc is a function that is called after the sign request is approved.
type Meta ¶
type Meta interface{}
Meta represents any metadata that could be attached to a signing request. It will be JSON-serialized and used in notifications to the API consumer.
type PendingRequests ¶
type PendingRequests struct {
// contains filtered or unexported fields
}
PendingRequests is a capped container that holds pending signing requests.
func NewPendingRequests ¶
func NewPendingRequests() *PendingRequests
NewPendingRequests creates a new requests list
func (*PendingRequests) Add ¶
func (rs *PendingRequests) Add(ctx context.Context, method string, meta Meta, completeFunc CompleteFunc) (*Request, error)
Add a new signing request.
func (*PendingRequests) Approve ¶
func (rs *PendingRequests) Approve(id string, password string, args *TxArgs, verify verifyFunc) Result
Approve a signing request by it's ID. Requires a valid password and a verification function.
func (*PendingRequests) Count ¶
func (rs *PendingRequests) Count() int
Count returns number of currently pending requests
func (*PendingRequests) Discard ¶
func (rs *PendingRequests) Discard(id string) error
Discard remove a signing request from the list of pending requests.
func (*PendingRequests) First ¶
func (rs *PendingRequests) First() *Request
First returns a first signing request (if exists, nil otherwise).
func (*PendingRequests) Get ¶
func (rs *PendingRequests) Get(id string) (*Request, error)
Get returns a signing request by it's ID.
func (*PendingRequests) Has ¶
func (rs *PendingRequests) Has(id string) bool
Has checks whether a pending request with a given identifier exists in the list
type Response ¶
type Response []byte
Response is a byte payload returned by the signed function
type TransientError ¶
type TransientError struct {
Reason error
}
TransientError means that the sign request won't be removed from the list of pending if it happens. There are a few built-in transient errors, and this struct can be used to wrap any error to be transient.
func NewTransientError ¶
func NewTransientError(reason error) TransientError
NewTransientError wraps an error into a TransientError structure.
func (TransientError) Error ¶
func (e TransientError) Error() string
Error returns the string representation of the underlying error.