Export SignTypedData in mobile bindings (#1403)

This commit is contained in:
Dmitry Shulyak 2019-03-04 15:45:27 +02:00 committed by Igor Mandrigin
parent b3e2cb2965
commit ea19896623
1 changed files with 17 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/status-im/status-go/params"
"github.com/status-im/status-go/profiling"
"github.com/status-im/status-go/services/personal"
"github.com/status-im/status-go/services/typeddata"
"github.com/status-im/status-go/signal"
"github.com/status-im/status-go/transactions"
validator "gopkg.in/go-playground/validator.v9"
@ -350,6 +351,22 @@ func SignMessage(rpcParams string) string {
return prepareJSONResponse(result.String(), err)
}
// SignTypedData unmarshall data into TypedData, validate it and signs with selected account,
// if password matches selected account.
//export SignTypedData
func SignTypedData(data, password string) string {
var typed typeddata.TypedData
err := json.Unmarshal([]byte(data), &typed)
if err != nil {
return prepareJSONResponseWithCode(nil, err, codeFailedParseParams)
}
if err := typed.Validate(); err != nil {
return prepareJSONResponseWithCode(nil, err, codeFailedParseParams)
}
result, err := statusBackend.SignTypedData(typed, password)
return prepareJSONResponse(result.String(), err)
}
// Recover unmarshals rpc params {signDataString, signedData} and passes
// them onto backend.
func Recover(rpcParams string) string {