From c03e24e10b23ce1c542d3dea10bc26ae9d86fea5 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 4 Feb 2019 16:03:25 +0000 Subject: Fix bug where passing in signerAddress instead of exchangeAddress --- packages/order-utils/package.json | 1 + packages/order-utils/src/signature_utils.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index 7a4d4aa84..4e31d4094 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -57,6 +57,7 @@ "@0x/assert": "^1.0.23", "@0x/base-contract": "^3.0.13", "@0x/contract-artifacts": "^1.3.0", + "@0x/contract-addresses": "^2.2.0", "@0x/json-schemas": "^2.1.7", "@0x/types": "^1.5.2", "@0x/typescript-typings": "^3.0.8", 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; }, -- cgit v1.2.3