accounts, signer: implement gnosis safe support (#21593)
* accounts, signer: implement gnosis safe support * common/math: add type for marshalling big to dec * accounts, signer: properly sign gnosis requests * signer, clef: implement account_signGnosisTx * signer: fix auditlog print, change rpc-name (signGnosisTx to signGnosisSafeTx) * signer: pass validation-messages/warnings to the UI for gnonsis-safe txs * signer/core: minor change to validationmessages of typed data
This commit is contained in:
committed by
GitHub
parent
6c8310ebb4
commit
dad26582b6
@ -18,6 +18,7 @@ package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
@ -61,13 +62,32 @@ func (l *AuditLogger) SignTransaction(ctx context.Context, args SendTxArgs, meth
|
||||
}
|
||||
|
||||
func (l *AuditLogger) SignData(ctx context.Context, contentType string, addr common.MixedcaseAddress, data interface{}) (hexutil.Bytes, error) {
|
||||
marshalledData, _ := json.Marshal(data) // can ignore error, marshalling what we just unmarshalled
|
||||
l.log.Info("SignData", "type", "request", "metadata", MetadataFromContext(ctx).String(),
|
||||
"addr", addr.String(), "data", data, "content-type", contentType)
|
||||
"addr", addr.String(), "data", marshalledData, "content-type", contentType)
|
||||
b, e := l.api.SignData(ctx, contentType, addr, data)
|
||||
l.log.Info("SignData", "type", "response", "data", common.Bytes2Hex(b), "error", e)
|
||||
return b, e
|
||||
}
|
||||
|
||||
func (l *AuditLogger) SignGnosisSafeTx(ctx context.Context, addr common.MixedcaseAddress, gnosisTx GnosisSafeTx, methodSelector *string) (*GnosisSafeTx, error) {
|
||||
sel := "<nil>"
|
||||
if methodSelector != nil {
|
||||
sel = *methodSelector
|
||||
}
|
||||
data, _ := json.Marshal(gnosisTx) // can ignore error, marshalling what we just unmarshalled
|
||||
l.log.Info("SignGnosisSafeTx", "type", "request", "metadata", MetadataFromContext(ctx).String(),
|
||||
"addr", addr.String(), "data", string(data), "selector", sel)
|
||||
res, e := l.api.SignGnosisSafeTx(ctx, addr, gnosisTx, methodSelector)
|
||||
if res != nil {
|
||||
data, _ := json.Marshal(res) // can ignore error, marshalling what we just unmarshalled
|
||||
l.log.Info("SignGnosisSafeTx", "type", "response", "data", string(data), "error", e)
|
||||
} else {
|
||||
l.log.Info("SignGnosisSafeTx", "type", "response", "data", res, "error", e)
|
||||
}
|
||||
return res, e
|
||||
}
|
||||
|
||||
func (l *AuditLogger) SignTypedData(ctx context.Context, addr common.MixedcaseAddress, data TypedData) (hexutil.Bytes, error) {
|
||||
l.log.Info("SignTypedData", "type", "request", "metadata", MetadataFromContext(ctx).String(),
|
||||
"addr", addr.String(), "data", data)
|
||||
|
Reference in New Issue
Block a user