aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/0x.js')
-rw-r--r--packages/0x.js/CHANGELOG.md14
-rw-r--r--packages/0x.js/package.json22
-rw-r--r--packages/0x.js/src/0x.ts20
-rw-r--r--packages/0x.js/src/artifacts/EtherToken.json3
-rw-r--r--packages/0x.js/src/artifacts/Exchange.json3
-rw-r--r--packages/0x.js/src/artifacts/TokenRegistry.json3
-rw-r--r--packages/0x.js/src/artifacts/TokenTransferProxy.json3
-rw-r--r--packages/0x.js/src/artifacts/ZRX.json3
-rw-r--r--packages/0x.js/src/utils/utils.ts6
-rw-r--r--packages/0x.js/test/0x.js_test.ts20
-rw-r--r--packages/0x.js/test/utils/order_factory.ts4
11 files changed, 70 insertions, 31 deletions
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index 7fc1d9bba..83c33ee1c 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -1,6 +1,18 @@
# CHANGELOG
-## v0.30.1 - _January 18, 2018_
+## v0.31.0 - _January 30, 2018_
+
+ * Add the `shouldAddPersonalMessagePrefix` parameter to `signOrderHashAsync` so that the
+ caller can decide on whether to add the personalMessage prefix before relaying the request
+ to the signer. Parity Signer, Ledger and TestRPC add the prefix themselves, Metamask expects
+ it to have already been added. (#349)
+
+## v0.30.2 - _January 29, 2018_
+
+ * Add Rinkeby testnet addresses to artifacts (#337)
+ * Move @0xproject/types to dependencies from devDependencies fixing missing type errors
+
+## v0.30.1 - _January 24, 2018_
* Fix a bug allowing negative fill values (#212)
* Fix a bug that made it impossible to pass a custom ZRX address (#341)
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index fb27f48de..2942e5001 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -1,6 +1,6 @@
{
"name": "0x.js",
- "version": "0.30.1",
+ "version": "0.31.0",
"description": "A javascript library for interacting with the 0x protocol",
"keywords": [
"0x.js",
@@ -41,10 +41,9 @@
"node": ">=6.0.0"
},
"devDependencies": {
- "@0xproject/abi-gen": "^0.1.3",
- "@0xproject/dev-utils": "^0.0.6",
- "@0xproject/tslint-config": "^0.4.3",
- "@0xproject/types": "^0.1.5",
+ "@0xproject/abi-gen": "^0.1.5",
+ "@0xproject/dev-utils": "^0.0.8",
+ "@0xproject/tslint-config": "^0.4.5",
"@types/bintrees": "^1.0.2",
"@types/jsonschema": "^1.1.1",
"@types/lodash": "^4.14.86",
@@ -55,7 +54,7 @@
"awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-as-promised-typescript-typings": "^0.0.5",
+ "chai-as-promised-typescript-typings": "^0.0.7",
"chai-bignumber": "^2.0.1",
"chai-typescript-typings": "^0.0.2",
"copyfiles": "^1.2.0",
@@ -76,14 +75,15 @@
"typedoc": "~0.8.0",
"typescript": "~2.6.1",
"web3-provider-engine": "^13.0.1",
- "web3-typescript-typings": "^0.9.5",
+ "web3-typescript-typings": "^0.9.7",
"webpack": "^3.1.0"
},
"dependencies": {
- "@0xproject/assert": "^0.0.12",
- "@0xproject/json-schemas": "^0.7.4",
- "@0xproject/utils": "^0.2.1",
- "@0xproject/web3-wrapper": "^0.1.6",
+ "@0xproject/assert": "^0.0.14",
+ "@0xproject/json-schemas": "^0.7.6",
+ "@0xproject/types": "^0.1.7",
+ "@0xproject/utils": "^0.2.3",
+ "@0xproject/web3-wrapper": "^0.1.8",
"bintrees": "^1.0.2",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts
index 503a937c4..f8a484c5d 100644
--- a/packages/0x.js/src/0x.ts
+++ b/packages/0x.js/src/0x.ts
@@ -240,20 +240,22 @@ export class ZeroEx {
* @param orderHash Hex encoded orderHash to sign.
* @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address
* must be available via the Web3.Provider supplied to 0x.js.
+ * @param shouldAddPersonalMessagePrefix Some signers add the personal message prefix `\x19Ethereum Signed Message`
+ * themselves (e.g Parity Signer, Ledger, TestRPC) and others expect it to already be done by the client
+ * (e.g Metamask). Depending on which signer this request is going to, decide on whether to add the prefix
+ * before sending the request.
* @return An object containing the Elliptic curve signature parameters generated by signing the orderHash.
*/
- public async signOrderHashAsync(orderHash: string, signerAddress: string): Promise<ECSignature> {
+ public async signOrderHashAsync(
+ orderHash: string,
+ signerAddress: string,
+ shouldAddPersonalMessagePrefix: boolean,
+ ): Promise<ECSignature> {
assert.isHexString('orderHash', orderHash);
await assert.isSenderAddressAsync('signerAddress', signerAddress, this._web3Wrapper);
- let msgHashHex;
- const nodeVersion = await this._web3Wrapper.getNodeVersionAsync();
- const isParityNode = utils.isParityNode(nodeVersion);
- const isTestRpc = utils.isTestRpc(nodeVersion);
- if (isParityNode || isTestRpc) {
- // Parity and TestRpc nodes add the personalMessage prefix itself
- msgHashHex = orderHash;
- } else {
+ let msgHashHex = orderHash;
+ if (shouldAddPersonalMessagePrefix) {
const orderHashBuff = ethUtil.toBuffer(orderHash);
const msgHashBuff = ethUtil.hashPersonalMessage(orderHashBuff);
msgHashHex = ethUtil.bufferToHex(msgHashBuff);
diff --git a/packages/0x.js/src/artifacts/EtherToken.json b/packages/0x.js/src/artifacts/EtherToken.json
index 91fba7f0a..26cca57cd 100644
--- a/packages/0x.js/src/artifacts/EtherToken.json
+++ b/packages/0x.js/src/artifacts/EtherToken.json
@@ -274,6 +274,9 @@
"3": {
"address": "0xc00fd9820cd2898cc4c054b7bf142de637ad129a"
},
+ "4": {
+ "address": "0xc778417e063141139fce010982780140aa0cd5ab"
+ },
"42": {
"address": "0x653e49e301e508a13237c0ddc98ae7d4cd2667a1"
},
diff --git a/packages/0x.js/src/artifacts/Exchange.json b/packages/0x.js/src/artifacts/Exchange.json
index 45e277c45..af8db7360 100644
--- a/packages/0x.js/src/artifacts/Exchange.json
+++ b/packages/0x.js/src/artifacts/Exchange.json
@@ -597,6 +597,9 @@
"3": {
"address": "0x479cc461fecd078f766ecc58533d6f69580cf3ac"
},
+ "4": {
+ "address": "0x1d16ef40fac01cec8adac2ac49427b9384192c05"
+ },
"42": {
"address": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364"
},
diff --git a/packages/0x.js/src/artifacts/TokenRegistry.json b/packages/0x.js/src/artifacts/TokenRegistry.json
index 81780074c..0f583628c 100644
--- a/packages/0x.js/src/artifacts/TokenRegistry.json
+++ b/packages/0x.js/src/artifacts/TokenRegistry.json
@@ -534,6 +534,9 @@
"3": {
"address": "0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed"
},
+ "4": {
+ "address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
+ },
"42": {
"address": "0xf18e504561f4347bea557f3d4558f559dddbae7f"
},
diff --git a/packages/0x.js/src/artifacts/TokenTransferProxy.json b/packages/0x.js/src/artifacts/TokenTransferProxy.json
index 9b6a6cdf9..8cf551ddb 100644
--- a/packages/0x.js/src/artifacts/TokenTransferProxy.json
+++ b/packages/0x.js/src/artifacts/TokenTransferProxy.json
@@ -174,6 +174,9 @@
"3": {
"address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
},
+ "4": {
+ "address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
+ },
"42": {
"address": "0x087eed4bc1ee3de49befbd66c662b434b15d49d4"
},
diff --git a/packages/0x.js/src/artifacts/ZRX.json b/packages/0x.js/src/artifacts/ZRX.json
index 1bd973178..e40b8f268 100644
--- a/packages/0x.js/src/artifacts/ZRX.json
+++ b/packages/0x.js/src/artifacts/ZRX.json
@@ -7,6 +7,9 @@
"3": {
"address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
},
+ "4": {
+ "address": "0x00f58d6d585f84b2d7267940cede30ce2fe6eae8"
+ },
"42": {
"address": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570"
},
diff --git a/packages/0x.js/src/utils/utils.ts b/packages/0x.js/src/utils/utils.ts
index e42a1a853..42cf5d956 100644
--- a/packages/0x.js/src/utils/utils.ts
+++ b/packages/0x.js/src/utils/utils.ts
@@ -20,12 +20,6 @@ export const utils = {
// tslint:disable-next-line: no-console
console.log(message);
},
- isParityNode(nodeVersion: string): boolean {
- return _.includes(nodeVersion, 'Parity');
- },
- isTestRpc(nodeVersion: string): boolean {
- return _.includes(nodeVersion, 'TestRPC');
- },
spawnSwitchErr(name: string, value: any): Error {
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
},
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index 5bc2c149c..927fe20be 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -16,6 +16,8 @@ const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
chaiSetup.configure();
const expect = chai.expect;
+const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
+
describe('ZeroEx library', () => {
const web3 = web3Factory.create();
const config = {
@@ -198,7 +200,11 @@ describe('ZeroEx library', () => {
r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
};
- const ecSignature = await zeroEx.signOrderHashAsync(orderHash, makerAddress);
+ const ecSignature = await zeroEx.signOrderHashAsync(
+ orderHash,
+ makerAddress,
+ SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
+ );
expect(ecSignature).to.deep.equal(expectedECSignature);
});
it('should return the correct ECSignature for signatureHex concatenated as R + S + V', async () => {
@@ -215,7 +221,11 @@ describe('ZeroEx library', () => {
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
];
- const ecSignature = await zeroEx.signOrderHashAsync(orderHash, makerAddress);
+ const ecSignature = await zeroEx.signOrderHashAsync(
+ orderHash,
+ makerAddress,
+ SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
+ );
expect(ecSignature).to.deep.equal(expectedECSignature);
});
it('should return the correct ECSignature for signatureHex concatenated as V + R + S', async () => {
@@ -232,7 +242,11 @@ describe('ZeroEx library', () => {
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
];
- const ecSignature = await zeroEx.signOrderHashAsync(orderHash, makerAddress);
+ const ecSignature = await zeroEx.signOrderHashAsync(
+ orderHash,
+ makerAddress,
+ SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
+ );
expect(ecSignature).to.deep.equal(expectedECSignature);
});
});
diff --git a/packages/0x.js/test/utils/order_factory.ts b/packages/0x.js/test/utils/order_factory.ts
index 60a7c5fb2..08f2081a4 100644
--- a/packages/0x.js/test/utils/order_factory.ts
+++ b/packages/0x.js/test/utils/order_factory.ts
@@ -3,6 +3,8 @@ import * as _ from 'lodash';
import { SignedOrder, ZeroEx } from '../../src';
+const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
+
export const orderFactory = {
async createSignedOrderAsync(
zeroEx: ZeroEx,
@@ -37,7 +39,7 @@ export const orderFactory = {
expirationUnixTimestampSec,
};
const orderHash = ZeroEx.getOrderHashHex(order);
- const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker);
+ const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker, SHOULD_ADD_PERSONAL_MESSAGE_PREFIX);
const signedOrder: SignedOrder = _.assign(order, { ecSignature });
return signedOrder;
},