@@ -412,7 +412,59 @@ def test_eth_sign_ens_names(
412412 assert is_bytes (signature )
413413 assert len (signature ) == 32 + 32 + 1
414414
415- def test_eth_signTypedData (
415+ def test_eth_sign_typed_data (
416+ self ,
417+ web3 : "Web3" ,
418+ unlocked_account_dual_type : ChecksumAddress ,
419+ skip_if_testrpc : Callable [["Web3" ], None ],
420+ ) -> None :
421+ validJSONMessage = '''
422+ {
423+ "types": {
424+ "EIP712Domain": [
425+ {"name": "name", "type": "string"},
426+ {"name": "version", "type": "string"},
427+ {"name": "chainId", "type": "uint256"},
428+ {"name": "verifyingContract", "type": "address"}
429+ ],
430+ "Person": [
431+ {"name": "name", "type": "string"},
432+ {"name": "wallet", "type": "address"}
433+ ],
434+ "Mail": [
435+ {"name": "from", "type": "Person"},
436+ {"name": "to", "type": "Person"},
437+ {"name": "contents", "type": "string"}
438+ ]
439+ },
440+ "primaryType": "Mail",
441+ "domain": {
442+ "name": "Ether Mail",
443+ "version": "1",
444+ "chainId": "0x01",
445+ "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
446+ },
447+ "message": {
448+ "from": {
449+ "name": "Cow",
450+ "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
451+ },
452+ "to": {
453+ "name": "Bob",
454+ "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
455+ },
456+ "contents": "Hello, Bob!"
457+ }
458+ }
459+ '''
460+ skip_if_testrpc (web3 )
461+ signature = HexBytes (web3 .eth .sign_typed_data (
462+ unlocked_account_dual_type ,
463+ json .loads (validJSONMessage )
464+ ))
465+ assert len (signature ) == 32 + 32 + 1
466+
467+ def test_eth_signTypedData_deprecated (
416468 self ,
417469 web3 : "Web3" ,
418470 unlocked_account_dual_type : ChecksumAddress ,
@@ -464,7 +516,7 @@ def test_eth_signTypedData(
464516 ))
465517 assert len (signature ) == 32 + 32 + 1
466518
467- def test_invalid_eth_signTypedData (
519+ def test_invalid_eth_sign_typed_data (
468520 self ,
469521 web3 : "Web3" ,
470522 unlocked_account_dual_type : ChecksumAddress ,
@@ -512,7 +564,7 @@ def test_invalid_eth_signTypedData(
512564 '''
513565 with pytest .raises (ValueError ,
514566 match = r".*Expected 2 items for array type Person\[2\], got 1 items.*" ):
515- web3 .eth .signTypedData (
567+ web3 .eth .sign_typed_data (
516568 unlocked_account_dual_type ,
517569 json .loads (invalid_typed_message )
518570 )
0 commit comments