aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio B <kandinsky454@protonmail.ch>2019-02-05 22:36:06 +0800
committerGitHub <noreply@github.com>2019-02-05 22:36:06 +0800
commit69c7c03fb34b3f21f65c40b73baa21184a296fb2 (patch)
tree467e38250825a25a4bc33b55ff4df32a67ac3033 /packages
parent7b583cecb29c24f561c8befa835ba9ef5a6918f6 (diff)
parent224a58bdf25127786a9b83f37c20015b16cbe3d5 (diff)
downloaddexon-0x-contracts-69c7c03fb34b3f21f65c40b73baa21184a296fb2.tar
dexon-0x-contracts-69c7c03fb34b3f21f65c40b73baa21184a296fb2.tar.gz
dexon-0x-contracts-69c7c03fb34b3f21f65c40b73baa21184a296fb2.tar.bz2
dexon-0x-contracts-69c7c03fb34b3f21f65c40b73baa21184a296fb2.tar.lz
dexon-0x-contracts-69c7c03fb34b3f21f65c40b73baa21184a296fb2.tar.xz
dexon-0x-contracts-69c7c03fb34b3f21f65c40b73baa21184a296fb2.tar.zst
dexon-0x-contracts-69c7c03fb34b3f21f65c40b73baa21184a296fb2.zip
Merge pull request #1580 from 0xProject/fix/preSignedSignatureBug
Fix preSigned signature bug in SignatureUtils
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/package.json2
-rw-r--r--packages/contract-wrappers/test/exchange_wrapper_test.ts19
-rw-r--r--packages/order-utils/CHANGELOG.json4
-rw-r--r--packages/order-utils/package.json1
-rw-r--r--packages/order-utils/src/signature_utils.ts10
-rw-r--r--packages/order-utils/test/signature_utils_test.ts11
6 files changed, 44 insertions, 3 deletions
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index 9c7adbbcd..58cd439fd 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -24,7 +24,7 @@
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"clean": "shx rm -rf _bundles lib test_temp src/generated_contract_wrappers generated_docs",
- "build:umd:prod": "NODE_ENV=production webpack",
+ "build:umd:prod": "NODE_ENV=production node --max_old_space_size=8192 ../../node_modules/.bin/webpack --mode production",
"build:commonjs": "tsc -b",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
diff --git a/packages/contract-wrappers/test/exchange_wrapper_test.ts b/packages/contract-wrappers/test/exchange_wrapper_test.ts
index a1d60dc6e..acd30495b 100644
--- a/packages/contract-wrappers/test/exchange_wrapper_test.ts
+++ b/packages/contract-wrappers/test/exchange_wrapper_test.ts
@@ -1,6 +1,6 @@
import { BlockchainLifecycle, callbackErrorReporter } from '@0x/dev-utils';
import { FillScenarios } from '@0x/fill-scenarios';
-import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
+import { assetDataUtils, orderHashUtils, signatureUtils } from '@0x/order-utils';
import { DoneCallback, RevertReason, SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
@@ -368,6 +368,23 @@ describe('ExchangeWrapper', () => {
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
isPreSigned = await contractWrappers.exchange.isPreSignedAsync(hash, signerAddress);
expect(isPreSigned).to.be.true();
+
+ const preSignedSignature = '0x06';
+ const isValidSignature = await contractWrappers.exchange.isValidSignatureAsync(
+ hash,
+ signerAddress,
+ preSignedSignature,
+ );
+ expect(isValidSignature).to.be.true();
+
+ // Test our TS implementation of signature validation
+ const isValidSignatureInTs = await signatureUtils.isValidSignatureAsync(
+ provider,
+ hash,
+ preSignedSignature,
+ signerAddress,
+ );
+ expect(isValidSignatureInTs).to.be.true();
});
});
describe('#getVersionAsync', () => {
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json
index 8a104c8ef..5169208c9 100644
--- a/packages/order-utils/CHANGELOG.json
+++ b/packages/order-utils/CHANGELOG.json
@@ -5,6 +5,10 @@
{
"note": "Upgrade the bignumber.js to v8.0.2",
"pr": 1517
+ },
+ {
+ "note": "Fix preSigned `isSignatureValidAsync` check",
+ "pr": 1580
}
],
"timestamp": 1549373905
diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json
index b4b33d6e6..8645581ab 100644
--- a/packages/order-utils/package.json
+++ b/packages/order-utils/package.json
@@ -57,6 +57,7 @@
"@0x/assert": "^2.0.0",
"@0x/base-contract": "^4.0.0",
"@0x/contract-artifacts": "^1.3.0",
+ "@0x/contract-addresses": "^2.2.1",
"@0x/json-schemas": "^3.0.0",
"@0x/types": "^2.0.0",
"@0x/typescript-typings": "^4.0.0",
diff --git a/packages/order-utils/src/signature_utils.ts b/packages/order-utils/src/signature_utils.ts
index 131144d48..efcc146bf 100644
--- a/packages/order-utils/src/signature_utils.ts
+++ b/packages/order-utils/src/signature_utils.ts
@@ -1,4 +1,5 @@
import { ExchangeContract, IValidatorContract, IWalletContract } from '@0x/abi-gen-wrappers';
+import { getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses';
import * as artifacts from '@0x/contract-artifacts';
import { schemas } from '@0x/json-schemas';
import { ECSignature, Order, SignatureType, SignedOrder, ValidatorSignature } from '@0x/types';
@@ -92,7 +93,14 @@ export const signatureUtils = {
assert.isWeb3Provider('provider', provider);
assert.isHexString('data', data);
assert.isETHAddressHex('signerAddress', signerAddress);
- const exchangeContract = new ExchangeContract(artifacts.Exchange.compilerOutput.abi, signerAddress, provider);
+ const web3Wrapper = new Web3Wrapper(provider);
+ const networkId = await web3Wrapper.getNetworkIdAsync();
+ const addresses = getContractAddressesForNetworkOrThrow(networkId);
+ const exchangeContract = new ExchangeContract(
+ artifacts.Exchange.compilerOutput.abi,
+ addresses.exchange,
+ provider,
+ );
const isValid = await exchangeContract.preSigned.callAsync(data, signerAddress);
return isValid;
},
diff --git a/packages/order-utils/test/signature_utils_test.ts b/packages/order-utils/test/signature_utils_test.ts
index 937382056..44aa729b3 100644
--- a/packages/order-utils/test/signature_utils_test.ts
+++ b/packages/order-utils/test/signature_utils_test.ts
@@ -99,6 +99,17 @@ describe('Signature utils', () => {
);
expect(isValidSignatureLocal).to.be.true();
});
+
+ it('should return false if entry not found in `preSigned` mapping', async () => {
+ const preSignedSignature = '0x06';
+ const isValidPreSignature = await signatureUtils.isValidSignatureAsync(
+ provider,
+ dataHex,
+ preSignedSignature,
+ address,
+ );
+ expect(isValidPreSignature).to.be.false();
+ });
});
describe('#isValidECSignature', () => {
const signature = {