Update version numbers.

Add source for Metamask future fix.
Consolidate switch statement to one return
This commit is contained in:
Jacob Evans
2018-08-14 08:32:16 +10:00
parent ca4905c343
commit a351757493
5 changed files with 12 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
[ [
{ {
"version": "pending", "version": "1.0.1-rc.4",
"changes": [ "changes": [
{ {
"pr": 914, "pr": 914,

View File

@@ -237,7 +237,7 @@ export class ZeroEx {
* @param orderHash Hex encoded orderHash to sign. * @param orderHash Hex encoded orderHash to sign.
* @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address * @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address
* must be available via the Provider supplied to 0x.js. * must be available via the Provider supplied to 0x.js.
* @param signerType the type signer that will perform the `eth_sign` operation. E.g Default, Metamask, Ledger or Trezor. * @param signerType the signer type that will perform the `eth_sign` operation. E.g Default, Metamask, Ledger or Trezor.
* Some implementations exhibit different behaviour. Default will assume a spec compliant eth_sign implementation. * Some implementations exhibit different behaviour. Default will assume a spec compliant eth_sign implementation.
* This parameter is defaulted to `SignerType.Default`. * This parameter is defaulted to `SignerType.Default`.
* @return A hex encoded string of the Elliptic curve signature parameters generated by signing the orderHash and signature type. * @return A hex encoded string of the Elliptic curve signature parameters generated by signing the orderHash and signature type.

View File

@@ -1,6 +1,6 @@
[ [
{ {
"version": "pending", "version": "1.0.1-rc.4",
"changes": [ "changes": [
{ {
"pr": 914, "pr": 914,

View File

@@ -216,6 +216,7 @@ export async function ecSignOrderHashAsync(
let msgHashHex = orderHash; let msgHashHex = orderHash;
const prefixedMsgHashHex = addSignedMessagePrefix(orderHash, signerType); const prefixedMsgHashHex = addSignedMessagePrefix(orderHash, signerType);
// Metamask incorrectly implements eth_sign and does not prefix the message as per the spec // Metamask incorrectly implements eth_sign and does not prefix the message as per the spec
// Source: https://github.com/MetaMask/metamask-extension/commit/a9d36860bec424dcee8db043d3e7da6a5ff5672e
if (signerType === SignerType.Metamask) { if (signerType === SignerType.Metamask) {
msgHashHex = prefixedMsgHashHex; msgHashHex = prefixedMsgHashHex;
} }
@@ -260,22 +261,23 @@ export function convertECSignatureToSignatureHex(ecSignature: ECSignature, signe
ethUtil.toBuffer(ecSignature.s), ethUtil.toBuffer(ecSignature.s),
]); ]);
const signatureHex = `0x${signatureBuffer.toString('hex')}`; const signatureHex = `0x${signatureBuffer.toString('hex')}`;
let signatureType;
switch (signerType) { switch (signerType) {
case SignerType.Metamask: case SignerType.Metamask:
case SignerType.Ledger: case SignerType.Ledger:
case SignerType.Default: { case SignerType.Default: {
const signatureType = SignatureType.EthSign; signatureType = SignatureType.EthSign;
const signatureWithType = convertToSignatureWithType(signatureHex, signatureType); break;
return signatureWithType;
} }
case SignerType.Trezor: { case SignerType.Trezor: {
const signatureType = SignatureType.Trezor; signatureType = SignatureType.Trezor;
const signatureWithType = convertToSignatureWithType(signatureHex, signatureType); break;
return signatureWithType;
} }
default: default:
throw new Error(`Unrecognized SignerType: ${signerType}`); throw new Error(`Unrecognized SignerType: ${signerType}`);
} }
const signatureWithType = convertToSignatureWithType(signatureHex, signatureType);
return signatureWithType;
} }
/** /**
* Combines the signature proof and the Signature Type. * Combines the signature proof and the Signature Type.

View File

@@ -1,6 +1,6 @@
[ [
{ {
"version": "pending", "version": "1.0.1-rc.4",
"changes": [ "changes": [
{ {
"pr": 914, "pr": 914,