mirror of
https://github.com/status-im/status-go.git
synced 2025-01-15 01:05:06 +00:00
a9eb5a7d2b
We need to be able to sign more than just transactions to make DApps work properly. This change separates signing requests from the transactions and make it more general to prepare to intoduce different types of signing requests. This change is designed to preserve status APIs, so it is backward-comparible with the current API bindings.
37 lines
879 B
Go
37 lines
879 B
Go
package sign
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/pborman/uuid"
|
|
"github.com/status-im/status-go/geth/account"
|
|
)
|
|
|
|
type completeFunc func(*account.SelectedExtKey) (common.Hash, error)
|
|
|
|
// 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
|
|
Meta Meta
|
|
context context.Context
|
|
locked bool
|
|
completeFunc completeFunc
|
|
result chan Result
|
|
}
|
|
|
|
func newRequest(ctx context.Context, meta Meta, completeFunc completeFunc) *Request {
|
|
return &Request{
|
|
ID: uuid.New(),
|
|
Meta: meta,
|
|
context: ctx,
|
|
locked: false,
|
|
completeFunc: completeFunc,
|
|
result: make(chan Result, 1),
|
|
}
|
|
}
|