forked from cerc-io/laconicd-deprecated
ante: EIP712 support (#950)
* code migrated * signed_data ported to avoid conficting dependency * correct payload * eip712 working with evmos.me * use geth TypedData types * fix linter * minor refactor * test first try * fix test * fix tests * enforce fee delegated eip712 * verify signature refactor * SignedTypedData api refactor * add AnteHandler test for EIP712 * remove comment * code clean up * return more detailed error messages * fix linter * remove unnecesary global vars * Update app/ante/eip712.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * fix pr comments * remove hardcoded value * add more tests * add changelog * use sdk errors * add MsgDelegate test Co-authored-by: Freddy Caceres <freddy.caceres@crypto.com> Co-authored-by: Federico Kunze Küllmer <federico.kunze94@gmail.com> Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: crypto-facs <84574577+crypto-facs@users.noreply.github.com>
This commit is contained in:
co-authored by
Federico Kunze Küllmer
Freddy Caceres
Federico Kunze Küllmer
crypto-facs
parent
0d69a69625
commit
3bea3fa1ef
@@ -7,6 +7,8 @@ import (
|
||||
"math"
|
||||
"math/big"
|
||||
|
||||
"github.com/tharsis/ethermint/ethereum/eip712"
|
||||
|
||||
"github.com/ethereum/go-ethereum/signer/core/apitypes"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
@@ -446,18 +448,11 @@ func (e *PublicAPI) SignTypedData(address common.Address, typedData apitypes.Typ
|
||||
return nil, fmt.Errorf("%s; %s", keystore.ErrNoMatch, err.Error())
|
||||
}
|
||||
|
||||
domainSeparator, err := typedData.HashStruct("EIP712Domain", typedData.Domain.Map())
|
||||
sigHash, err := eip712.ComputeTypedDataHash(typedData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
typedDataHash, err := typedData.HashStruct(typedData.PrimaryType, typedData.Message)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rawData := []byte(fmt.Sprintf("\x19\x01%s%s", string(domainSeparator), string(typedDataHash)))
|
||||
sigHash := crypto.Keccak256(rawData)
|
||||
// Sign the requested hash with the wallet
|
||||
signature, _, err := e.clientCtx.Keyring.SignByAddress(from, sigHash)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user