-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add support to sign message #341
Conversation
48bb110
to
9e82522
Compare
7501afc
to
3162c8e
Compare
if eip712_message_path: | ||
try: | ||
message = json.load(open(eip712_message_path, "r")) | ||
message_bytes = b"".join(eip712_encode(message)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I sign the hash of EIP712 or the string hash following EIP191? I'm asking because is the way that the transaction service accepts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not understanding. You need to sign self.safe.get_message_hash(message_bytes)
3162c8e
to
7c6c8f2
Compare
This PR cannot be merged because have dependencies with:
|
if eip712_message_path: | ||
try: | ||
message = json.load(open(eip712_message_path, "r")) | ||
message_bytes = b"".join(eip712_encode(message)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not understanding. You need to sign self.safe.get_message_hash(message_bytes)
safe_cli/operators/safe_operator.py
Outdated
safe_tx = self.hw_wallet_manager.sign_eip712( | ||
safe_tx, selected_ledger_accounts | ||
) | ||
if len(hw_wallets_signers) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if len(hw_wallets_signers) > 0: | |
if len(hw_wallets_signers): |
+ signatures[65 * signer_pos :] | ||
) | ||
|
||
if len(hw_wallet_signers) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if len(hw_wallet_signers) > 0: | |
if len(hw_wallet_signers): |
signature_dict["v"], signature_dict["r"], signature_dict["s"] | ||
) | ||
signers.append(eoa_signer.address) | ||
signer_pos = sorted(signers, key=lambda x: int(x, 16)).index( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can build SafeSignature
objects and then use the new method export_signatures
on safe-eth-py
@@ -368,6 +372,13 @@ def remove_delegate(args): | |||
parser_approve_hash.add_argument("sender", type=check_ethereum_address) | |||
parser_approve_hash.set_defaults(func=approve_hash) | |||
|
|||
# Sign message | |||
parser_sign_message = subparsers.add_parser("sign_message") | |||
group = parser_sign_message.add_mutually_exclusive_group(required=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
b"".join(eip712_encode(message)) | ||
) | ||
safe_operator.sign_message(eip712_message_path=eip712_path) | ||
self.assertTrue(safe_operator.safe.retrieve_is_message_signed(message_hash)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify this is False
before signing the message
Close #280
Description
This PR adds support to sign message on-chain and off -chain with Safe Transaction Service.