2018-04-09 08:18:22 +00:00
|
|
|
package sign
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/pborman/uuid"
|
|
|
|
"github.com/status-im/status-go/geth/account"
|
|
|
|
)
|
|
|
|
|
2018-04-10 10:02:54 +00:00
|
|
|
// CompleteFunc is a function that is called after the sign request is approved.
|
|
|
|
type CompleteFunc func(account *account.SelectedExtKey, password string) (Response, error)
|
2018-04-09 08:18:22 +00:00
|
|
|
|
|
|
|
// 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 Meta interface{}
|
|
|
|
|
|
|
|
// Request is a single signing request.
|
|
|
|
type Request struct {
|
|
|
|
ID string
|
2018-04-10 10:02:54 +00:00
|
|
|
Method string
|
2018-04-09 08:18:22 +00:00
|
|
|
Meta Meta
|
|
|
|
context context.Context
|
|
|
|
locked bool
|
2018-04-10 10:02:54 +00:00
|
|
|
completeFunc CompleteFunc
|
2018-04-09 08:18:22 +00:00
|
|
|
result chan Result
|
|
|
|
}
|
|
|
|
|
2018-04-10 10:02:54 +00:00
|
|
|
func newRequest(ctx context.Context, method string, meta Meta, completeFunc CompleteFunc) *Request {
|
2018-04-09 08:18:22 +00:00
|
|
|
return &Request{
|
|
|
|
ID: uuid.New(),
|
2018-04-10 10:02:54 +00:00
|
|
|
Method: method,
|
2018-04-09 08:18:22 +00:00
|
|
|
Meta: meta,
|
|
|
|
context: ctx,
|
|
|
|
locked: false,
|
|
|
|
completeFunc: completeFunc,
|
|
|
|
result: make(chan Result, 1),
|
|
|
|
}
|
|
|
|
}
|