Skip to content

Conversation

estebanmino
Copy link
Contributor

@estebanmino estebanmino commented Dec 4, 2018

This PR is mostly a migration to ts of this to have both eth_signTypedData and eth_signTypedData_v3 as proposed by EIP712

It also exposes signing methods from eth-sig-util

@codecov-io
Copy link

codecov-io commented Dec 4, 2018

Codecov Report

Merging #36 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #36   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          18     20    +2     
  Lines         932    998   +66     
  Branches      103    114   +11     
=====================================
+ Hits          932    998   +66
Impacted Files Coverage Δ
src/MessageManager.ts 100% <100%> (ø)
src/TypedMessageManager.ts 100% <100%> (ø)
src/util.ts 100% <100%> (ø) ⬆️
src/PersonalMessageManager.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db942b2...9a96a15. Read the comment docs.

Copy link
Contributor

@brunobar79 brunobar79 left a comment

Choose a reason for hiding this comment

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

Looks great. Just a couple of questions (non blockers)!

switch (version) {
case 'V1':
return sigUtil.signTypedDataLegacy(privateKeyBuffer, { data: messageParams.data });
case 'V3':
Copy link
Contributor

Choose a reason for hiding this comment

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

should we make version optional and default to v3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea, what do you think @bitpshr ? This was the way it is here

type: 'uint32',
value: '1337'
}
];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth to add a test for a message with data that has >= 2 levels deep ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I could have put any compatible data there, would we want to change it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just making sure that works for complex objects

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way I understand it, these managers only have the responsibility to handle messages flow and not the data itself, that would be a responsibility for eth-sig-util in this case. But I can be wrong and we could add more complex data structures extending from object[]. For that reason there are also tests for eth_signTypedData_v3 with typed messages validation according to the EIP712.

Copy link
Contributor

@bitpshr bitpshr 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 good so far. I think PersonalMessageManager and TypedMessageManager should extend from a common base class since so much functionality is identical. Right now, we're duplicating a lot of underlying code.

Copy link
Contributor

@bitpshr bitpshr left a comment

Choose a reason for hiding this comment

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

Really great refactoring. This is definitely good to merge.

@estebanmino estebanmino merged commit 86e4ff5 into master Dec 6, 2018
@estebanmino estebanmino deleted the eth-sign-typed-data branch December 6, 2018 17:32
mcmire pushed a commit to mcmire/core that referenced this pull request Jul 17, 2023
* Bump Yarn to v3 and patch jest-worker

* Fix lint issues

* Fix CI config
kanthesha pushed a commit that referenced this pull request Oct 11, 2023
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
* TypedMessageManager with signTypedMessageV3 data type validation missing

* add signTypedMessageV3 data validation tests

* rename util methods for sign typed data

* update doc

* add signTypedMessage

* const naming changes

* update test

* signTypedData working as expected

* use data object to signTypedData V3

* throw error when signTypedData fails

* improve doc

* reuse const typedMessage on typedMessageManager tests

* refactor PersonalMessageManager using base MessageManager

* refactor TypedMessageManager using base MessageManager

* add MessageManager tests

* fiz util import

* fix TypedMessageParams on keyring controller

* update docs
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
* TypedMessageManager with signTypedMessageV3 data type validation missing

* add signTypedMessageV3 data validation tests

* rename util methods for sign typed data

* update doc

* add signTypedMessage

* const naming changes

* update test

* signTypedData working as expected

* use data object to signTypedData V3

* throw error when signTypedData fails

* improve doc

* reuse const typedMessage on typedMessageManager tests

* refactor PersonalMessageManager using base MessageManager

* refactor TypedMessageManager using base MessageManager

* add MessageManager tests

* fiz util import

* fix TypedMessageParams on keyring controller

* update docs
Mrtenz pushed a commit that referenced this pull request Oct 16, 2025
* Add files field to package.json

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
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.

4 participants