Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get prop for signed typed data from domain instead of message #7402

Merged
merged 1 commit into from
Nov 13, 2019

Conversation

danjm
Copy link
Contributor

@danjm danjm commented Nov 13, 2019

Fixes #7395

We were mistakenly looking for the user readable name of the message sender within the wrong property of the message data. The name is optionally available within the domain property, as detailed here: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#definition-of-domainseparator

This updates the UI code to reflect that.

Ideally we should test this with a few use cases.

@danjm
Copy link
Contributor Author

danjm commented Nov 13, 2019

Tested with both the example data from the EIP and the data shared in this comment: #7395 (comment)

Tested both with v3 and v4 signing methods

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me!

@metamaskbot
Copy link
Collaborator

Builds ready [ef039d2]

@danjm
Copy link
Contributor Author

danjm commented Nov 13, 2019

Also tested with the below example:

const types = [
  'address', // makerAddress
  'uint256', // makerAmount
  'address', // makerToken
  'address', // takerAddress
  'uint256', // takerAmount
  'address', // takertoken
  'uint256', // expiration
  'uint256', // nonce
]
const orderHash = ethers.utils.solidityKeccak256(
  types,
  [
    '0x3C393072dDefa188282449dF78c585847a17E589',
    1,
    '0xB22c1C159d12461EA124b0deb4b5b93020E6Ad16',
    '0x145f71b7a87a0EB88d1391f3D56D5ea92A26dF26',
    1,
    '0xb1690C08E213a35Ed9bAb7B318DE14420FB57d8C',
    1573653901352,
    10
  ]
)
const testOrderHash = "0x323a0630961846b7e0e9d1a453cc87caa5ca909cc890ac735a63b8d5ccbe7e21"
const domainData = {
  verifyingContract: "0xbcd24b757c08843010b94cda1f8d03b90b167301",
}
const order = [
  { name: "orderHash", type: "bytes32" },
]
const msg = {
  orderHash: testOrderHash
}
const data = {
  types: {
    Order: order,
    EIP712Domain: [
      { name: "verifyingContract", type: "bytes32"  },
    ],
  },
  domain: domainData,
  primaryType: "Order",
  message: msg,
}
const typedMessageJSON = JSON.stringify(data)
var params = [ethereum.selectedAddress, typedMessageJSON]
var method = 'eth_signTypedData_v3'

web3.currentProvider.sendAsync({
  method,
  params,
  from: ethereum.selectedAddress,
}, function(err, result) {
  if (err) return console.error(err)
  console.log(result)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Signature Request UI completely Freezes Metamask
4 participants