signer/core: move EIP-712 types to package apitypes (#24029)

Fixes #23972
This commit is contained in:
Martin Holst Swende
2021-12-05 14:31:41 +01:00
committed by GitHub
parent 93f196c4b0
commit 619a3e7085
9 changed files with 776 additions and 771 deletions

View File

@ -34,15 +34,15 @@ type GnosisSafeTx struct {
}
// ToTypedData converts the tx to a EIP-712 Typed Data structure for signing
func (tx *GnosisSafeTx) ToTypedData() TypedData {
func (tx *GnosisSafeTx) ToTypedData() apitypes.TypedData {
var data hexutil.Bytes
if tx.Data != nil {
data = *tx.Data
}
gnosisTypedData := TypedData{
Types: Types{
"EIP712Domain": []Type{{Name: "verifyingContract", Type: "address"}},
"SafeTx": []Type{
gnosisTypedData := apitypes.TypedData{
Types: apitypes.Types{
"EIP712Domain": []apitypes.Type{{Name: "verifyingContract", Type: "address"}},
"SafeTx": []apitypes.Type{
{Name: "to", Type: "address"},
{Name: "value", Type: "uint256"},
{Name: "data", Type: "bytes"},
@ -55,11 +55,11 @@ func (tx *GnosisSafeTx) ToTypedData() TypedData {
{Name: "nonce", Type: "uint256"},
},
},
Domain: TypedDataDomain{
Domain: apitypes.TypedDataDomain{
VerifyingContract: tx.Safe.Address().Hex(),
},
PrimaryType: "SafeTx",
Message: TypedDataMessage{
Message: apitypes.TypedDataMessage{
"to": tx.To.Address().Hex(),
"value": tx.Value.String(),
"data": data,