Replace assetDataUtils with DevUtilsContract wherever possible (#2304)
* Replace assetDataUtils with DevUtilsContract wherever possible Does not replace from @0x/instant and some @0x/order-utils uses * Add revertIfInvalidAssetData to LibAssetData This is needed to replace `assetDataUtils.decodeAssetDataOrThrow`. Because it's used in packages and not only contracts, we should wait to deploy the updated contract so we can update `@0x/contract-artifacts`, `@0x/abi-gen-wrappers`, and `@0x/contract-wrappers` first. * remove usages of signatureUtils * fix test for optimised encoding * refactor @0x/contracts-integrations * update changelogs * Move @0x/contracts-dev-utils from devDependencies to dependencies It is exported as part of the package
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { constants, OrderFactory } from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
import { addressUtils, BigNumber } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
@@ -43,36 +42,62 @@ describe('ABI Decoding Calldata', () => {
|
||||
exchangeAddress,
|
||||
chainId,
|
||||
};
|
||||
|
||||
contractAddresses = await migrateOnceAsync();
|
||||
await blockchainLifecycle.startAsync();
|
||||
const config = {
|
||||
chainId: constants.TESTRPC_CHAIN_ID,
|
||||
contractAddresses,
|
||||
blockPollingIntervalMs: 10,
|
||||
};
|
||||
contractWrappers = new ContractWrappers(provider, config);
|
||||
|
||||
// Create orders to match.
|
||||
// Values are arbitrary, with the exception of maker addresses (generated above).
|
||||
orderLeft = {
|
||||
makerAddress: makerAddressLeft,
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync(
|
||||
defaultERC20MakerAssetAddress,
|
||||
),
|
||||
makerAssetAmount: new BigNumber(10),
|
||||
takerAddress: '0x0000000000000000000000000000000000000000',
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
takerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync(
|
||||
defaultERC20MakerAssetAddress,
|
||||
),
|
||||
takerAssetAmount: new BigNumber(1),
|
||||
feeRecipientAddress,
|
||||
makerFee: new BigNumber(0),
|
||||
takerFee: new BigNumber(0),
|
||||
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync(
|
||||
defaultERC20MakerAssetAddress,
|
||||
),
|
||||
takerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync(
|
||||
defaultERC20MakerAssetAddress,
|
||||
),
|
||||
senderAddress: '0x0000000000000000000000000000000000000000',
|
||||
expirationTimeSeconds: new BigNumber(1549498915),
|
||||
salt: new BigNumber(217),
|
||||
};
|
||||
orderRight = {
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync(
|
||||
defaultERC20MakerAssetAddress,
|
||||
),
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerAddress: '0x0000000000000000000000000000000000000000',
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
takerAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync(
|
||||
defaultERC20MakerAssetAddress,
|
||||
),
|
||||
takerAssetAmount: new BigNumber(8),
|
||||
feeRecipientAddress,
|
||||
makerFee: new BigNumber(0),
|
||||
takerFee: new BigNumber(0),
|
||||
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync(
|
||||
defaultERC20MakerAssetAddress,
|
||||
),
|
||||
takerFeeAssetData: await contractWrappers.devUtils.encodeERC20AssetData.callAsync(
|
||||
defaultERC20MakerAssetAddress,
|
||||
),
|
||||
senderAddress: '0x0000000000000000000000000000000000000000',
|
||||
expirationTimeSeconds: new BigNumber(1549498915),
|
||||
salt: new BigNumber(50010),
|
||||
@@ -82,14 +107,6 @@ describe('ABI Decoding Calldata', () => {
|
||||
const orderFactoryRight = new OrderFactory(privateKeyRight, orderRight);
|
||||
signedOrderRight = await orderFactoryRight.newSignedOrderAsync(domainInfo);
|
||||
// Encode match orders transaction
|
||||
contractAddresses = await migrateOnceAsync();
|
||||
await blockchainLifecycle.startAsync();
|
||||
const config = {
|
||||
chainId: constants.TESTRPC_CHAIN_ID,
|
||||
contractAddresses,
|
||||
blockPollingIntervalMs: 10,
|
||||
};
|
||||
contractWrappers = new ContractWrappers(provider, config);
|
||||
matchOrdersTxData = getAbiEncodedTransactionData(
|
||||
contractWrappers.exchange,
|
||||
'matchOrders',
|
||||
|
Reference in New Issue
Block a user