Migrate all contract-related tooling and tests to accept a chain ID in domain separators.
This commit is contained in:
committed by
Amir Bandeali
parent
92fe720ac3
commit
2d28fde24d
@@ -11,7 +11,7 @@ import {
|
||||
OrderValidationUtils,
|
||||
} from '@0x/order-utils';
|
||||
import { AssetProxyId, Order, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { BigNumber, providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { BlockParamLiteral, ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
@@ -1239,7 +1239,6 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
const orderValidationUtils = new OrderValidationUtils(filledCancelledFetcher, this._web3Wrapper.getProvider());
|
||||
await orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeSimulator,
|
||||
this._web3Wrapper.getProvider(),
|
||||
signedOrder,
|
||||
fillTakerAssetAmount,
|
||||
takerAddress,
|
||||
@@ -1260,8 +1259,9 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* @return TransactionEncoder
|
||||
*/
|
||||
public async transactionEncoderAsync(): Promise<TransactionEncoder> {
|
||||
const chainId = await providerUtils.getChainIdAsync(this._web3Wrapper.getProvider());
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const encoder = new TransactionEncoder(exchangeInstance);
|
||||
const encoder = new TransactionEncoder(exchangeInstance, chainId);
|
||||
return encoder;
|
||||
}
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
@@ -15,8 +15,11 @@ import { assert } from './assert';
|
||||
*/
|
||||
export class TransactionEncoder {
|
||||
private readonly _exchangeInstance: ExchangeContract;
|
||||
constructor(exchangeInstance: ExchangeContract) {
|
||||
private readonly _chainId: number;
|
||||
|
||||
constructor(exchangeInstance: ExchangeContract, chainId: number) {
|
||||
this._exchangeInstance = exchangeInstance;
|
||||
this._chainId = chainId;
|
||||
}
|
||||
/**
|
||||
* Hashes the transaction data for use with the Exchange contract.
|
||||
@@ -29,6 +32,7 @@ export class TransactionEncoder {
|
||||
const exchangeAddress = this._getExchangeContract().address;
|
||||
const transaction = {
|
||||
verifyingContractAddress: exchangeAddress,
|
||||
chainId: this._chainId,
|
||||
salt,
|
||||
signerAddress,
|
||||
data,
|
||||
|
||||
@@ -14,8 +14,9 @@ const expect = chai.expect;
|
||||
// utility for generating a set of order objects with mostly NULL values
|
||||
// except for a specified makerAssetData and takerAssetData
|
||||
const FAKE_ORDERS_COUNT = 5;
|
||||
const CHAIN_ID = 1337;
|
||||
const generateFakeOrders = (makerAssetData: string, takerAssetData: string) =>
|
||||
_.map(_.range(FAKE_ORDERS_COUNT), index => {
|
||||
_.map(_.range(FAKE_ORDERS_COUNT), () => {
|
||||
const order = orderFactory.createOrder(
|
||||
constants.NULL_ADDRESS,
|
||||
constants.ZERO_AMOUNT,
|
||||
@@ -23,6 +24,7 @@ const generateFakeOrders = (makerAssetData: string, takerAssetData: string) =>
|
||||
constants.ZERO_AMOUNT,
|
||||
takerAssetData,
|
||||
constants.NULL_ADDRESS,
|
||||
CHAIN_ID,
|
||||
);
|
||||
return {
|
||||
...order,
|
||||
|
||||
Reference in New Issue
Block a user