Skip to content

Commit 619a3e7

Browse files
authored
signer/core: move EIP-712 types to package apitypes (ethereum#24029)
Fixes ethereum#23972
1 parent 93f196c commit 619a3e7

9 files changed

+776
-771
lines changed

cmd/clef/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ func testExternalUI(api *core.SignerAPI) {
898898
addr, _ := common.NewMixedcaseAddressFromString("0x0011223344556677889900112233445566778899")
899899
data := `{"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"test","type":"uint8"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":"1","verifyingContract":"0xCCCcccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","test":"3","wallet":"0xcD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB","test":"2"},"contents":"Hello, Bob!"}}`
900900
//_, err := api.SignData(ctx, accounts.MimetypeTypedData, *addr, hexutil.Encode([]byte(data)))
901-
var typedData core.TypedData
901+
var typedData apitypes.TypedData
902902
json.Unmarshal([]byte(data), &typedData)
903903
_, err := api.SignTypedData(ctx, *addr, typedData)
904904
expectApprove("sign 712 typed data", err)
@@ -1025,7 +1025,7 @@ func GenDoc(ctx *cli.Context) {
10251025
"of the work in canonicalizing and making sense of the data, and it's up to the UI to present" +
10261026
"the user with the contents of the `message`"
10271027
sighash, msg := accounts.TextAndHash([]byte("hello world"))
1028-
messages := []*core.NameValueType{{Name: "message", Value: msg, Typ: accounts.MimetypeTextPlain}}
1028+
messages := []*apitypes.NameValueType{{Name: "message", Value: msg, Typ: accounts.MimetypeTextPlain}}
10291029

10301030
add("SignDataRequest", desc, &core.SignDataRequest{
10311031
Address: common.NewMixedcaseAddress(a),

signer/core/api.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type ExternalAPI interface {
5757
// SignData - request to sign the given data (plus prefix)
5858
SignData(ctx context.Context, contentType string, addr common.MixedcaseAddress, data interface{}) (hexutil.Bytes, error)
5959
// SignTypedData - request to sign the given structured data (plus prefix)
60-
SignTypedData(ctx context.Context, addr common.MixedcaseAddress, data TypedData) (hexutil.Bytes, error)
60+
SignTypedData(ctx context.Context, addr common.MixedcaseAddress, data apitypes.TypedData) (hexutil.Bytes, error)
6161
// EcRecover - recover public key from given message and signature
6262
EcRecover(ctx context.Context, data hexutil.Bytes, sig hexutil.Bytes) (common.Address, error)
6363
// Version info about the APIs
@@ -235,7 +235,7 @@ type (
235235
ContentType string `json:"content_type"`
236236
Address common.MixedcaseAddress `json:"address"`
237237
Rawdata []byte `json:"raw_data"`
238-
Messages []*NameValueType `json:"messages"`
238+
Messages []*apitypes.NameValueType `json:"messages"`
239239
Callinfo []apitypes.ValidationInfo `json:"call_info"`
240240
Hash hexutil.Bytes `json:"hash"`
241241
Meta Metadata `json:"meta"`

signer/core/signed_data_internal_test.go signer/core/apitypes/signed_data_internal_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package core
17+
package apitypes
1818

1919
import (
2020
"bytes"

0 commit comments

Comments
 (0)