diff --git a/common/containers/Tabs/SignAndVerifyMessage/components/SignMessage/SignButton.tsx b/common/containers/Tabs/SignAndVerifyMessage/components/SignMessage/SignButton.tsx index 0513778e..5398679f 100644 --- a/common/containers/Tabs/SignAndVerifyMessage/components/SignMessage/SignButton.tsx +++ b/common/containers/Tabs/SignAndVerifyMessage/components/SignMessage/SignButton.tsx @@ -26,8 +26,8 @@ export default class SignMessageButton extends React.Component { try { const signedMessage: ISignedMessage = { address: await wallet.getAddressString(), - message, - signature: await wallet.signMessage(message), + msg: message, + sig: await wallet.signMessage(message), version: '2' }; diff --git a/common/containers/Tabs/SignAndVerifyMessage/components/VerifyMessage/index.tsx b/common/containers/Tabs/SignAndVerifyMessage/components/VerifyMessage/index.tsx index 72b30b68..fd931550 100644 --- a/common/containers/Tabs/SignAndVerifyMessage/components/VerifyMessage/index.tsx +++ b/common/containers/Tabs/SignAndVerifyMessage/components/VerifyMessage/index.tsx @@ -20,8 +20,13 @@ const initialState: State = { signature: '' }; -const signaturePlaceholder = - '{"address":"0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8","message":"asdfasdfasdf","signature":"0x4771d78f13ba8abf608457f12471f427ca8f2fb046c1acb3f5969eefdfe452a10c9154136449f595a654b44b3b0163e86dd099beaca83bfd52d64c21da2221bb1c","version":"2"}'; +const signatureExample: ISignedMessage = { + address: '0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8', + msg: 'asdfasdfasdf', + sig: '0x4771d78f13ba...', + version: '2' +}; +const signaturePlaceholder = JSON.stringify(signatureExample, null, 2); export class VerifyMessage extends Component { public state: State = initialState; @@ -82,10 +87,10 @@ export class VerifyMessage extends Component { throw Error(); } - const { address, message } = parsedSignature; + const { address, msg } = parsedSignature; this.setState({ verifiedAddress: address, - verifiedMessage: message + verifiedMessage: msg }); this.props.showNotification('success', translate('SUCCESS_7')); } catch (err) { diff --git a/common/containers/Tabs/SignAndVerifyMessage/index.tsx b/common/containers/Tabs/SignAndVerifyMessage/index.tsx index 12b2e682..0d387a46 100644 --- a/common/containers/Tabs/SignAndVerifyMessage/index.tsx +++ b/common/containers/Tabs/SignAndVerifyMessage/index.tsx @@ -26,11 +26,11 @@ export default class SignAndVerifyMessage extends Component { + const msgToSign = 'Testing your code is great!'; + const msgToVerify = { + address: '0x6980ba0ab378c2ed0efccd7ea6ab84d54615a2de', + msg: msgToSign, + sig: + '0xf08688e9dddbb5e4e0d1fb685ee9f693accb3c9aac84fdcf327423ca4a1c50463ef7aeb70be3221fe028bc752e210a4c377db8090bc4efa5ea7d391049c3a4771c', + version: '2' + }; + const msgWallet = getPrivKeyWallet( + '05fb863d5da01481d52a629b7d07ee0b50c394503567318f2801cbac1901113b', + '' + ); + + it('signMessageWithPrivKeyV2 properly signs a message', () => { + expect(signMessageWithPrivKeyV2(msgWallet.getPrivateKey(), msgToSign)).toEqual(msgToVerify.sig); + }); + + it('verifySignedMessage properly verifies a signed message', () => { + expect(verifySignedMessage(msgToVerify)).toBeTruthy(); + }); +});