Test for ERC20 balance threshold

This commit is contained in:
Greg Hysen
2018-12-10 18:25:19 -08:00
parent 6d673ac942
commit 8799f9bb90

View File

@@ -1,6 +1,6 @@
import { BlockchainLifecycle } from '@0x/dev-utils'; import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils'; import { assetDataUtils } from '@0x/order-utils';
import { RevertReason, SignedOrder } from '@0x/types'; import { RevertReason, SignedOrder, Order } from '@0x/types';
import { BigNumber } from '@0x/utils'; import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper'; import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai'; import * as chai from 'chai';
@@ -64,9 +64,10 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
let nonCompliantOrderFactory: OrderFactory; let nonCompliantOrderFactory: OrderFactory;
let erc20Wrapper: ERC20Wrapper; let erc20Wrapper: ERC20Wrapper;
let erc20Balances: ERC20BalancesByOwner; let erc20Balances: ERC20BalancesByOwner;
let takerBalanceThresholdWrapper: BalanceThresholdWrapper; let erc20TakerBalanceThresholdWrapper: BalanceThresholdWrapper;
let makerBalanceThresholdWrapper: BalanceThresholdWrapper; let erc721TakerBalanceThresholdWrapper: BalanceThresholdWrapper;
let nonCompliantBalanceThresholdWrapper: BalanceThresholdWrapper; let erc721MakerBalanceThresholdWrapper: BalanceThresholdWrapper;
let erc721NonCompliantBalanceThresholdWrapper: BalanceThresholdWrapper;
let takerTransactionFactory: TransactionFactory; let takerTransactionFactory: TransactionFactory;
let makerTransactionFactory: TransactionFactory; let makerTransactionFactory: TransactionFactory;
@@ -77,11 +78,14 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
let logDecoder: LogDecoder; let logDecoder: LogDecoder;
let exchangeInternals: TestExchangeInternalsContract; let exchangeInternals: TestExchangeInternalsContract;
let defaultOrderParams: Partial<Order>;
const takerAssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(500), DECIMALS_DEFAULT); const takerAssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(500), DECIMALS_DEFAULT);
const makerAssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), DECIMALS_DEFAULT); const makerAssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), DECIMALS_DEFAULT);
const takerAssetFillAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(250), DECIMALS_DEFAULT); const takerAssetFillAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(250), DECIMALS_DEFAULT);
let compliantForwarderInstance: BalanceThresholdFilterContract; let erc721CompliantForwarderInstance: BalanceThresholdFilterContract;
let erc20CompliantForwarderInstance: BalanceThresholdFilterContract;
const assertValidatedAddressesLog = async (txReceipt: TransactionReceiptWithDecodedLogs, expectedValidatedAddresses: string[]) => { const assertValidatedAddressesLog = async (txReceipt: TransactionReceiptWithDecodedLogs, expectedValidatedAddresses: string[]) => {
expect(txReceipt.logs.length).to.be.gte(1); expect(txReceipt.logs.length).to.be.gte(1);
@@ -117,10 +121,11 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
}); });
const erc721Wrapper = new ERC721Wrapper(provider, compliantAddresses, owner); const erc721Wrapper = new ERC721Wrapper(provider, compliantAddresses, owner);
// Deploy ERC20 tokens // Deploy ERC20 tokens
const numDummyErc20ToDeploy = 3; const numDummyErc20ToDeploy = 4;
let erc20TokenA: DummyERC20TokenContract; let erc20TokenA: DummyERC20TokenContract;
let erc20TokenB: DummyERC20TokenContract; let erc20TokenB: DummyERC20TokenContract;
[erc20TokenA, erc20TokenB, zrxToken] = await erc20Wrapper.deployDummyTokensAsync( let erc20BalanceThresholdAsset: DummyERC20TokenContract;
[erc20TokenA, erc20TokenB, zrxToken, erc20BalanceThresholdAsset] = await erc20Wrapper.deployDummyTokensAsync(
numDummyErc20ToDeploy, numDummyErc20ToDeploy,
constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_DECIMALS,
); );
@@ -144,21 +149,30 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
from: owner, from: owner,
}); });
// Deploy Compliant Forwarder // Deploy Compliant Forwarder
const balanceThreshold = new BigNumber(1); const erc721alanceThreshold = new BigNumber(1);
await erc721Wrapper.deployProxyAsync(); await erc721Wrapper.deployProxyAsync();
const [balanceThresholdAsset] = await erc721Wrapper.deployDummyTokensAsync(); const [erc721BalanceThresholdAsset] = await erc721Wrapper.deployDummyTokensAsync();
await erc721Wrapper.setBalancesAndAllowancesAsync(); await erc721Wrapper.setBalancesAndAllowancesAsync();
const balance = await balanceThresholdAsset.balanceOf.callAsync(compliantTakerAddress); erc721CompliantForwarderInstance = await BalanceThresholdFilterContract.deployFrom0xArtifactAsync(
compliantForwarderInstance = await BalanceThresholdFilterContract.deployFrom0xArtifactAsync(
artifacts.BalanceThresholdFilter, artifacts.BalanceThresholdFilter,
provider, provider,
txDefaults, txDefaults,
exchangeInstance.address, exchangeInstance.address,
balanceThresholdAsset.address, erc721BalanceThresholdAsset.address,
balanceThreshold erc721alanceThreshold
); );
const erc20BalanceThreshold = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 10);
erc20CompliantForwarderInstance = await BalanceThresholdFilterContract.deployFrom0xArtifactAsync(
artifacts.BalanceThresholdFilter,
provider,
txDefaults,
exchangeInstance.address,
erc20BalanceThresholdAsset.address,
erc20BalanceThreshold
);
// Default order parameters // Default order parameters
const defaultOrderParams = { defaultOrderParams = {
exchangeAddress: exchangeInstance.address, exchangeAddress: exchangeInstance.address,
feeRecipientAddress, feeRecipientAddress,
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress), makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
@@ -167,7 +181,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
takerAssetAmount, takerAssetAmount,
makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), DECIMALS_DEFAULT), makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), DECIMALS_DEFAULT),
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(150), DECIMALS_DEFAULT), takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(150), DECIMALS_DEFAULT),
senderAddress: compliantForwarderInstance.address, senderAddress: erc721CompliantForwarderInstance.address,
}; };
const defaultOrderParams1 = { const defaultOrderParams1 = {
makerAddress: compliantMakerAddress, makerAddress: compliantMakerAddress,
@@ -192,20 +206,11 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
defaultOrderParams, defaultOrderParams,
}; };
nonCompliantOrderFactory = new OrderFactory(nonCompliantPrivateKey, defaultNonCompliantOrderParams); nonCompliantOrderFactory = new OrderFactory(nonCompliantPrivateKey, defaultNonCompliantOrderParams);
/*
const compliantForwarderContract = new BalanceThresholdFilterContract(
compliantForwarderInstance.abi,
compliantForwarderInstance.address,
provider,
);
forwarderWrapper = new ForwarderWrapper(compliantForwarderContract, provider);
*/
// Create Valid/Invalid orders // Create Valid/Invalid orders
const takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(compliantTakerAddress)]; const takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(compliantTakerAddress)];
takerTransactionFactory = new TransactionFactory(takerPrivateKey, exchangeInstance.address); takerTransactionFactory = new TransactionFactory(takerPrivateKey, exchangeInstance.address);
compliantSignedOrder = await orderFactory.newSignedOrderAsync({ compliantSignedOrder = await orderFactory.newSignedOrderAsync({
senderAddress: compliantForwarderInstance.address, senderAddress: erc721CompliantForwarderInstance.address,
}); });
const compliantSignedOrderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress( const compliantSignedOrderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(
compliantSignedOrder, compliantSignedOrder,
@@ -219,34 +224,11 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
compliantSignedOrderWithoutExchangeAddressData, compliantSignedOrderWithoutExchangeAddressData,
); );
/*
_.each(exchangeInstance.abi, (abiDefinition: AbiDefinition) => {
try {
const method = new Method(abiDefinition as MethodAbi);
console.log(method.getSignature());
if (!method.getSignature().startsWith('matchOrders')) {
return;
}
console.log(`FOUND IT`);
const signedOrderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(
compliantSignedOrder,
);
const args = [signedOrderWithoutExchangeAddress, signedOrderWithoutExchangeAddress, compliantSignedOrder.signature, compliantSignedOrder.signature];
console.log(method.encode(args, {annotate: true}));
//console.log('\n', `// ${method.getDataItem().name}`);
//console.log(`bytes4 constant ${method.getDataItem().name}Selector = ${method.getSelector()};`);
//console.log(`bytes4 constant ${method.getDataItem().name}SelectorGenerator = byes4(keccak256('${method.getSignature()}'));`);
} catch(e) {
console.log(`encoding failed: ${e}`);
}
});
throw new Error(`w`);*/
logDecoder = new LogDecoder(web3Wrapper); logDecoder = new LogDecoder(web3Wrapper);
takerBalanceThresholdWrapper = new BalanceThresholdWrapper(compliantForwarderInstance, exchangeInstance, new TransactionFactory(takerPrivateKey, exchangeInstance.address), provider); erc20TakerBalanceThresholdWrapper = new BalanceThresholdWrapper(erc20CompliantForwarderInstance, exchangeInstance, new TransactionFactory(takerPrivateKey, exchangeInstance.address), provider);
makerBalanceThresholdWrapper = new BalanceThresholdWrapper(compliantForwarderInstance, exchangeInstance, new TransactionFactory(makerPrivateKey, exchangeInstance.address), provider); erc721TakerBalanceThresholdWrapper = new BalanceThresholdWrapper(erc721CompliantForwarderInstance, exchangeInstance, new TransactionFactory(takerPrivateKey, exchangeInstance.address), provider);
erc721MakerBalanceThresholdWrapper = new BalanceThresholdWrapper(erc721CompliantForwarderInstance, exchangeInstance, new TransactionFactory(makerPrivateKey, exchangeInstance.address), provider);
nonCompliantBalanceThresholdWrapper = new BalanceThresholdWrapper(compliantForwarderInstance, exchangeInstance, new TransactionFactory(nonCompliantPrivateKey, exchangeInstance.address), provider); erc721NonCompliantBalanceThresholdWrapper = new BalanceThresholdWrapper(erc721CompliantForwarderInstance, exchangeInstance, new TransactionFactory(nonCompliantPrivateKey, exchangeInstance.address), provider);
// Instantiate internal exchange contract // Instantiate internal exchange contract
exchangeInternals = await TestExchangeInternalsContract.deployFrom0xArtifactAsync( exchangeInternals = await TestExchangeInternalsContract.deployFrom0xArtifactAsync(
@@ -262,7 +244,57 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
await blockchainLifecycle.revertAsync(); await blockchainLifecycle.revertAsync();
}); });
describe('General Sanity Checks', () => { describe.only('General Sanity Checks', () => {
beforeEach(async () => {
erc20Balances = await erc20Wrapper.getBalancesAsync();
compliantSignedOrder = await orderFactory.newSignedOrderAsync();
compliantSignedOrder2 = await orderFactory2.newSignedOrderAsync();
});
it.only('should transfer the correct amounts and validate both maker/taker when both maker and taker exceed the balance threshold of an ERC20 token', async () => {
const compliantSignedOrderERC20Sender = await orderFactory.newSignedOrderAsync({
...
defaultOrderParams,
makerAddress: compliantMakerAddress,
senderAddress: erc20TakerBalanceThresholdWrapper.getBalanceThresholdAddress(),
});
// Execute a valid fill
const txReceipt = await erc20TakerBalanceThresholdWrapper.fillOrderAsync(compliantSignedOrderERC20Sender, compliantTakerAddress, {takerAssetFillAmount});
// Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
// Check balances
const newBalances = await erc20Wrapper.getBalancesAsync();
const makerAssetFillAmount = takerAssetFillAmount
.times(compliantSignedOrder.makerAssetAmount)
.dividedToIntegerBy(compliantSignedOrder.takerAssetAmount);
const makerFeePaid = compliantSignedOrder.makerFee
.times(makerAssetFillAmount)
.dividedToIntegerBy(compliantSignedOrder.makerAssetAmount);
const takerFeePaid = compliantSignedOrder.takerFee
.times(makerAssetFillAmount)
.dividedToIntegerBy(compliantSignedOrder.makerAssetAmount);
expect(newBalances[compliantMakerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[compliantMakerAddress][defaultMakerAssetAddress].minus(makerAssetFillAmount),
);
expect(newBalances[compliantMakerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[compliantMakerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount),
);
expect(newBalances[compliantMakerAddress][zrxToken.address]).to.be.bignumber.equal(
erc20Balances[compliantMakerAddress][zrxToken.address].minus(makerFeePaid),
);
expect(newBalances[compliantTakerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[compliantTakerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount),
);
expect(newBalances[compliantTakerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[compliantTakerAddress][defaultMakerAssetAddress].add(makerAssetFillAmount),
);
expect(newBalances[compliantTakerAddress][zrxToken.address]).to.be.bignumber.equal(
erc20Balances[compliantTakerAddress][zrxToken.address].minus(takerFeePaid),
);
expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)),
);
});
it('should revert if the signed transaction is not intended for supported', async () => { it('should revert if the signed transaction is not intended for supported', async () => {
// Create signed order without the fillOrder function selector // Create signed order without the fillOrder function selector
const txDataBuf = ethUtil.toBuffer(compliantSignedFillOrderTx.data); const txDataBuf = ethUtil.toBuffer(compliantSignedFillOrderTx.data);
@@ -273,7 +305,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const txDataBufWithBadSelector = Buffer.concat([badSelectorBuf, txDataBufMinusSelector]); const txDataBufWithBadSelector = Buffer.concat([badSelectorBuf, txDataBufMinusSelector]);
const txDataBufWithBadSelectorHex = ethUtil.bufferToHex(txDataBufWithBadSelector); const txDataBufWithBadSelectorHex = ethUtil.bufferToHex(txDataBufWithBadSelector);
// Call compliant forwarder // Call compliant forwarder
return expectTransactionFailedWithoutReasonAsync(compliantForwarderInstance.executeTransaction.sendTransactionAsync( return expectTransactionFailedWithoutReasonAsync(erc721CompliantForwarderInstance.executeTransaction.sendTransactionAsync(
compliantSignedFillOrderTx.salt, compliantSignedFillOrderTx.salt,
compliantSignedFillOrderTx.signerAddress, compliantSignedFillOrderTx.signerAddress,
txDataBufWithBadSelectorHex, txDataBufWithBadSelectorHex,
@@ -298,7 +330,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
signedOrderWithoutExchangeAddressData, signedOrderWithoutExchangeAddressData,
); );
// Call compliant forwarder // Call compliant forwarder
return expectTransactionFailedWithoutReasonAsync(compliantForwarderInstance.executeTransaction.sendTransactionAsync( return expectTransactionFailedWithoutReasonAsync(erc721CompliantForwarderInstance.executeTransaction.sendTransactionAsync(
signedFillOrderTx.salt, signedFillOrderTx.salt,
signedFillOrderTx.signerAddress, signedFillOrderTx.signerAddress,
signedFillOrderTx.data, signedFillOrderTx.data,
@@ -318,7 +350,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
// Execute a valid fill // Execute a valid fill
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount]; const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
const txReceipt = await takerBalanceThresholdWrapper.batchFillOrdersAsync(orders, compliantTakerAddress, {takerAssetFillAmounts}); const txReceipt = await erc721TakerBalanceThresholdWrapper.batchFillOrdersAsync(orders, compliantTakerAddress, {takerAssetFillAmounts});
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress]; const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -380,7 +412,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, signedOrderWithBadMakerAddress]; const orders = [compliantSignedOrder, signedOrderWithBadMakerAddress];
// Execute transaction // Execute transaction
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.batchFillOrdersAsync( erc721TakerBalanceThresholdWrapper.batchFillOrdersAsync(
orders, orders,
compliantTakerAddress, compliantTakerAddress,
{takerAssetFillAmounts} {takerAssetFillAmounts}
@@ -392,7 +424,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount]; const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.batchFillOrdersAsync( erc721NonCompliantBalanceThresholdWrapper.batchFillOrdersAsync(
orders, orders,
nonCompliantAddress, nonCompliantAddress,
{takerAssetFillAmounts} {takerAssetFillAmounts}
@@ -412,7 +444,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
// Execute a valid fill // Execute a valid fill
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount]; const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
const txReceipt = await takerBalanceThresholdWrapper.batchFillOrdersNoThrowAsync(orders, compliantTakerAddress, {takerAssetFillAmounts}); const txReceipt = await erc721TakerBalanceThresholdWrapper.batchFillOrdersNoThrowAsync(orders, compliantTakerAddress, {takerAssetFillAmounts});
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress]; const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -474,7 +506,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, signedOrderWithBadMakerAddress]; const orders = [compliantSignedOrder, signedOrderWithBadMakerAddress];
// Execute transaction // Execute transaction
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.batchFillOrdersNoThrowAsync( erc721TakerBalanceThresholdWrapper.batchFillOrdersNoThrowAsync(
orders, orders,
compliantTakerAddress, compliantTakerAddress,
{takerAssetFillAmounts} {takerAssetFillAmounts}
@@ -486,7 +518,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount]; const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.batchFillOrdersNoThrowAsync( erc721NonCompliantBalanceThresholdWrapper.batchFillOrdersNoThrowAsync(
orders, orders,
nonCompliantAddress, nonCompliantAddress,
{takerAssetFillAmounts} {takerAssetFillAmounts}
@@ -506,7 +538,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
// Execute a valid fill // Execute a valid fill
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount]; const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
const txReceipt = await takerBalanceThresholdWrapper.batchFillOrKillOrdersAsync(orders, compliantTakerAddress, {takerAssetFillAmounts}); const txReceipt = await erc721TakerBalanceThresholdWrapper.batchFillOrKillOrdersAsync(orders, compliantTakerAddress, {takerAssetFillAmounts});
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress]; const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -568,7 +600,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, signedOrderWithBadMakerAddress]; const orders = [compliantSignedOrder, signedOrderWithBadMakerAddress];
// Execute transaction // Execute transaction
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.batchFillOrKillOrdersAsync( erc721TakerBalanceThresholdWrapper.batchFillOrKillOrdersAsync(
orders, orders,
compliantTakerAddress, compliantTakerAddress,
{takerAssetFillAmounts} {takerAssetFillAmounts}
@@ -580,7 +612,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount]; const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.batchFillOrKillOrdersAsync( erc721NonCompliantBalanceThresholdWrapper.batchFillOrKillOrdersAsync(
orders, orders,
nonCompliantAddress, nonCompliantAddress,
{takerAssetFillAmounts} {takerAssetFillAmounts}
@@ -593,7 +625,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const takerAssetFillAmounts = [takerAssetFillAmount, tooBigTakerAssetFillAmount]; const takerAssetFillAmounts = [takerAssetFillAmount, tooBigTakerAssetFillAmount];
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.batchFillOrKillOrdersAsync( erc721TakerBalanceThresholdWrapper.batchFillOrKillOrdersAsync(
orders, orders,
compliantTakerAddress, compliantTakerAddress,
{takerAssetFillAmounts} {takerAssetFillAmounts}
@@ -610,7 +642,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
}); });
it('should transfer the correct amounts and validate both maker/taker when both maker and taker meet the balance threshold', async () => { it('should transfer the correct amounts and validate both maker/taker when both maker and taker meet the balance threshold', async () => {
// Execute a valid fill // Execute a valid fill
const txReceipt = await takerBalanceThresholdWrapper.fillOrderAsync(compliantSignedOrder, compliantTakerAddress, {takerAssetFillAmount}); const txReceipt = await erc721TakerBalanceThresholdWrapper.fillOrderAsync(compliantSignedOrder, compliantTakerAddress, {takerAssetFillAmount});
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedFillOrderTx.signerAddress]; const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -650,12 +682,12 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
it('should revert if maker does not meet the balance threshold', async () => { it('should revert if maker does not meet the balance threshold', async () => {
// Create signed order with non-compliant maker address // Create signed order with non-compliant maker address
const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({ const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({
senderAddress: compliantForwarderInstance.address, senderAddress: erc721CompliantForwarderInstance.address,
makerAddress: nonCompliantAddress makerAddress: nonCompliantAddress
}); });
// Execute transaction // Execute transaction
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.fillOrderAsync( erc721TakerBalanceThresholdWrapper.fillOrderAsync(
signedOrderWithBadMakerAddress, signedOrderWithBadMakerAddress,
compliantTakerAddress, compliantTakerAddress,
{takerAssetFillAmount} {takerAssetFillAmount}
@@ -665,7 +697,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
}); });
it('should revert if taker does not meet the balance threshold', async () => { it('should revert if taker does not meet the balance threshold', async () => {
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.fillOrderAsync( erc721NonCompliantBalanceThresholdWrapper.fillOrderAsync(
compliantSignedOrder, compliantSignedOrder,
nonCompliantAddress, nonCompliantAddress,
{takerAssetFillAmount} {takerAssetFillAmount}
@@ -682,7 +714,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
}); });
it('should transfer the correct amounts and validate both maker/taker when both maker and taker meet the balance threshold', async () => { it('should transfer the correct amounts and validate both maker/taker when both maker and taker meet the balance threshold', async () => {
// Execute a valid fill // Execute a valid fill
const txReceipt = await takerBalanceThresholdWrapper.fillOrderNoThrowAsync(compliantSignedOrder, compliantTakerAddress, {takerAssetFillAmount}); const txReceipt = await erc721TakerBalanceThresholdWrapper.fillOrderNoThrowAsync(compliantSignedOrder, compliantTakerAddress, {takerAssetFillAmount});
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedFillOrderTx.signerAddress]; const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -722,12 +754,12 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
it('should revert if maker does not meet the balance threshold', async () => { it('should revert if maker does not meet the balance threshold', async () => {
// Create signed order with non-compliant maker address // Create signed order with non-compliant maker address
const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({ const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({
senderAddress: compliantForwarderInstance.address, senderAddress: erc721CompliantForwarderInstance.address,
makerAddress: nonCompliantAddress makerAddress: nonCompliantAddress
}); });
// Execute transaction // Execute transaction
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.fillOrderNoThrowAsync( erc721TakerBalanceThresholdWrapper.fillOrderNoThrowAsync(
signedOrderWithBadMakerAddress, signedOrderWithBadMakerAddress,
compliantTakerAddress, compliantTakerAddress,
{takerAssetFillAmount} {takerAssetFillAmount}
@@ -737,7 +769,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
}); });
it('should revert if taker does not meet the balance threshold', async () => { it('should revert if taker does not meet the balance threshold', async () => {
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.fillOrderNoThrowAsync( erc721NonCompliantBalanceThresholdWrapper.fillOrderNoThrowAsync(
compliantSignedOrder, compliantSignedOrder,
nonCompliantAddress, nonCompliantAddress,
{takerAssetFillAmount} {takerAssetFillAmount}
@@ -755,7 +787,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
it('should transfer the correct amounts and validate both maker/taker when both maker and taker meet the balance threshold', async () => { it('should transfer the correct amounts and validate both maker/taker when both maker and taker meet the balance threshold', async () => {
// Execute a valid fill // Execute a valid fill
const takerAssetFillAmount_ = compliantSignedOrder.takerAssetAmount; const takerAssetFillAmount_ = compliantSignedOrder.takerAssetAmount;
const txReceipt = await takerBalanceThresholdWrapper.fillOrKillOrderAsync(compliantSignedOrder, compliantTakerAddress, {takerAssetFillAmount: takerAssetFillAmount_}); const txReceipt = await erc721TakerBalanceThresholdWrapper.fillOrKillOrderAsync(compliantSignedOrder, compliantTakerAddress, {takerAssetFillAmount: takerAssetFillAmount_});
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedFillOrderTx.signerAddress]; const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -795,12 +827,12 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
it('should revert if maker does not meet the balance threshold', async () => { it('should revert if maker does not meet the balance threshold', async () => {
// Create signed order with non-compliant maker address // Create signed order with non-compliant maker address
const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({ const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({
senderAddress: compliantForwarderInstance.address, senderAddress: erc721CompliantForwarderInstance.address,
makerAddress: nonCompliantAddress makerAddress: nonCompliantAddress
}); });
// Execute transaction // Execute transaction
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.fillOrKillOrderAsync( erc721TakerBalanceThresholdWrapper.fillOrKillOrderAsync(
signedOrderWithBadMakerAddress, signedOrderWithBadMakerAddress,
compliantTakerAddress, compliantTakerAddress,
{takerAssetFillAmount} {takerAssetFillAmount}
@@ -810,7 +842,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
}); });
it('should revert if taker does not meet the balance threshold', async () => { it('should revert if taker does not meet the balance threshold', async () => {
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.fillOrKillOrderAsync( erc721NonCompliantBalanceThresholdWrapper.fillOrKillOrderAsync(
compliantSignedOrder, compliantSignedOrder,
nonCompliantAddress, nonCompliantAddress,
{takerAssetFillAmount} {takerAssetFillAmount}
@@ -821,7 +853,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
it('should revert if takerAssetFillAmount is not fully filled', async () => { it('should revert if takerAssetFillAmount is not fully filled', async () => {
const tooBigTakerAssetFillAmount = compliantSignedOrder.takerAssetAmount.times(2); const tooBigTakerAssetFillAmount = compliantSignedOrder.takerAssetAmount.times(2);
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.fillOrKillOrderAsync( erc721TakerBalanceThresholdWrapper.fillOrKillOrderAsync(
compliantSignedOrder, compliantSignedOrder,
compliantTakerAddress, compliantTakerAddress,
{takerAssetFillAmount: tooBigTakerAssetFillAmount} {takerAssetFillAmount: tooBigTakerAssetFillAmount}
@@ -841,7 +873,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
// Execute a valid fill // Execute a valid fill
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const cumulativeTakerAssetFillAmount = compliantSignedOrder.takerAssetAmount.plus(takerAssetFillAmount); const cumulativeTakerAssetFillAmount = compliantSignedOrder.takerAssetAmount.plus(takerAssetFillAmount);
const txReceipt = await takerBalanceThresholdWrapper.marketSellOrdersAsync(orders, compliantTakerAddress, {takerAssetFillAmount: cumulativeTakerAssetFillAmount}); const txReceipt = await erc721TakerBalanceThresholdWrapper.marketSellOrdersAsync(orders, compliantTakerAddress, {takerAssetFillAmount: cumulativeTakerAssetFillAmount});
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress]; const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -901,7 +933,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, signedOrderWithBadMakerAddress]; const orders = [compliantSignedOrder, signedOrderWithBadMakerAddress];
// Execute transaction // Execute transaction
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.marketSellOrdersAsync( erc721TakerBalanceThresholdWrapper.marketSellOrdersAsync(
orders, orders,
compliantTakerAddress, compliantTakerAddress,
{takerAssetFillAmount} {takerAssetFillAmount}
@@ -912,7 +944,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
it('should revert if taker does not meet the balance threshold', async () => { it('should revert if taker does not meet the balance threshold', async () => {
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.marketSellOrdersAsync( erc721NonCompliantBalanceThresholdWrapper.marketSellOrdersAsync(
orders, orders,
nonCompliantAddress, nonCompliantAddress,
{takerAssetFillAmount} {takerAssetFillAmount}
@@ -932,7 +964,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
// Execute a valid fill // Execute a valid fill
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const cumulativeTakerAssetFillAmount = compliantSignedOrder.takerAssetAmount.plus(takerAssetFillAmount); const cumulativeTakerAssetFillAmount = compliantSignedOrder.takerAssetAmount.plus(takerAssetFillAmount);
const txReceipt = await takerBalanceThresholdWrapper.marketSellOrdersNoThrowAsync(orders, compliantTakerAddress, {takerAssetFillAmount: cumulativeTakerAssetFillAmount}); const txReceipt = await erc721TakerBalanceThresholdWrapper.marketSellOrdersNoThrowAsync(orders, compliantTakerAddress, {takerAssetFillAmount: cumulativeTakerAssetFillAmount});
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress]; const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -992,7 +1024,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, signedOrderWithBadMakerAddress]; const orders = [compliantSignedOrder, signedOrderWithBadMakerAddress];
// Execute transaction // Execute transaction
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.marketSellOrdersNoThrowAsync( erc721TakerBalanceThresholdWrapper.marketSellOrdersNoThrowAsync(
orders, orders,
compliantTakerAddress, compliantTakerAddress,
{takerAssetFillAmount} {takerAssetFillAmount}
@@ -1003,7 +1035,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
it('should revert if taker does not meet the balance threshold', async () => { it('should revert if taker does not meet the balance threshold', async () => {
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.marketSellOrdersNoThrowAsync( erc721NonCompliantBalanceThresholdWrapper.marketSellOrdersNoThrowAsync(
orders, orders,
nonCompliantAddress, nonCompliantAddress,
{takerAssetFillAmount} {takerAssetFillAmount}
@@ -1027,7 +1059,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
.times(compliantSignedOrder.makerAssetAmount) .times(compliantSignedOrder.makerAssetAmount)
.dividedToIntegerBy(compliantSignedOrder.takerAssetAmount); .dividedToIntegerBy(compliantSignedOrder.takerAssetAmount);
const cumulativeMakerAssetFillAmount = compliantSignedOrder.makerAssetAmount.plus(makerAssetFillAmount2); const cumulativeMakerAssetFillAmount = compliantSignedOrder.makerAssetAmount.plus(makerAssetFillAmount2);
const txReceipt = await takerBalanceThresholdWrapper.marketBuyOrdersAsync(orders, compliantTakerAddress, {makerAssetFillAmount: cumulativeMakerAssetFillAmount}); const txReceipt = await erc721TakerBalanceThresholdWrapper.marketBuyOrdersAsync(orders, compliantTakerAddress, {makerAssetFillAmount: cumulativeMakerAssetFillAmount});
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress]; const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -1084,7 +1116,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
// Execute transaction // Execute transaction
const dummyMakerAssetFillAmount = new BigNumber(0); const dummyMakerAssetFillAmount = new BigNumber(0);
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.marketBuyOrdersAsync( erc721TakerBalanceThresholdWrapper.marketBuyOrdersAsync(
orders, orders,
compliantTakerAddress, compliantTakerAddress,
{makerAssetFillAmount: dummyMakerAssetFillAmount} {makerAssetFillAmount: dummyMakerAssetFillAmount}
@@ -1096,7 +1128,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const dummyMakerAssetFillAmount = new BigNumber(0); const dummyMakerAssetFillAmount = new BigNumber(0);
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.marketBuyOrdersAsync( erc721NonCompliantBalanceThresholdWrapper.marketBuyOrdersAsync(
orders, orders,
nonCompliantAddress, nonCompliantAddress,
{makerAssetFillAmount: dummyMakerAssetFillAmount} {makerAssetFillAmount: dummyMakerAssetFillAmount}
@@ -1120,7 +1152,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
.times(compliantSignedOrder.makerAssetAmount) .times(compliantSignedOrder.makerAssetAmount)
.dividedToIntegerBy(compliantSignedOrder.takerAssetAmount); .dividedToIntegerBy(compliantSignedOrder.takerAssetAmount);
const cumulativeMakerAssetFillAmount = compliantSignedOrder.makerAssetAmount.plus(makerAssetFillAmount2); const cumulativeMakerAssetFillAmount = compliantSignedOrder.makerAssetAmount.plus(makerAssetFillAmount2);
const txReceipt = await takerBalanceThresholdWrapper.marketBuyOrdersNoThrowAsync(orders, compliantTakerAddress, {makerAssetFillAmount: cumulativeMakerAssetFillAmount}); const txReceipt = await erc721TakerBalanceThresholdWrapper.marketBuyOrdersNoThrowAsync(orders, compliantTakerAddress, {makerAssetFillAmount: cumulativeMakerAssetFillAmount});
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress]; const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedOrder2.makerAddress, compliantSignedFillOrderTx.signerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -1177,7 +1209,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
// Execute transaction // Execute transaction
const dummyMakerAssetFillAmount = new BigNumber(0); const dummyMakerAssetFillAmount = new BigNumber(0);
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.marketBuyOrdersNoThrowAsync( erc721TakerBalanceThresholdWrapper.marketBuyOrdersNoThrowAsync(
orders, orders,
compliantTakerAddress, compliantTakerAddress,
{makerAssetFillAmount: dummyMakerAssetFillAmount} {makerAssetFillAmount: dummyMakerAssetFillAmount}
@@ -1189,7 +1221,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
const orders = [compliantSignedOrder, compliantSignedOrder2]; const orders = [compliantSignedOrder, compliantSignedOrder2];
const dummyMakerAssetFillAmount = new BigNumber(0); const dummyMakerAssetFillAmount = new BigNumber(0);
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.marketBuyOrdersNoThrowAsync( erc721NonCompliantBalanceThresholdWrapper.marketBuyOrdersNoThrowAsync(
orders, orders,
nonCompliantAddress, nonCompliantAddress,
{makerAssetFillAmount: dummyMakerAssetFillAmount} {makerAssetFillAmount: dummyMakerAssetFillAmount}
@@ -1240,7 +1272,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
feePaidByTakerLeft: Web3Wrapper.toBaseUnitAmount(new BigNumber('76.5306122448979591'), 16), // 76.53% feePaidByTakerLeft: Web3Wrapper.toBaseUnitAmount(new BigNumber('76.5306122448979591'), 16), // 76.53%
feePaidByTakerRight: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 16), // 100% feePaidByTakerRight: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 16), // 100%
}; };
const txReceipt = await takerBalanceThresholdWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, compliantTakerAddress); const txReceipt = await erc721TakerBalanceThresholdWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, compliantTakerAddress);
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses = [signedOrderLeft.makerAddress, signedOrderRight.makerAddress, compliantTakerAddress]; const expectedValidatedAddresseses = [signedOrderLeft.makerAddress, signedOrderRight.makerAddress, compliantTakerAddress];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
@@ -1292,12 +1324,12 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
it('should revert if left maker does not meet the balance threshold', async () => { it('should revert if left maker does not meet the balance threshold', async () => {
// Create signed order with non-compliant maker address // Create signed order with non-compliant maker address
const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({ const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({
senderAddress: compliantForwarderInstance.address, senderAddress: erc721CompliantForwarderInstance.address,
makerAddress: nonCompliantAddress makerAddress: nonCompliantAddress
}); });
// Execute transaction // Execute transaction
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.matchOrdersAsync( erc721TakerBalanceThresholdWrapper.matchOrdersAsync(
compliantSignedOrder, compliantSignedOrder,
signedOrderWithBadMakerAddress, signedOrderWithBadMakerAddress,
compliantTakerAddress, compliantTakerAddress,
@@ -1308,12 +1340,12 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
it('should revert if right maker does not meet the balance threshold', async () => { it('should revert if right maker does not meet the balance threshold', async () => {
// Create signed order with non-compliant maker address // Create signed order with non-compliant maker address
const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({ const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({
senderAddress: compliantForwarderInstance.address, senderAddress: erc721CompliantForwarderInstance.address,
makerAddress: nonCompliantAddress makerAddress: nonCompliantAddress
}); });
// Execute transaction // Execute transaction
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
takerBalanceThresholdWrapper.matchOrdersAsync( erc721TakerBalanceThresholdWrapper.matchOrdersAsync(
signedOrderWithBadMakerAddress, signedOrderWithBadMakerAddress,
compliantSignedOrder, compliantSignedOrder,
compliantTakerAddress, compliantTakerAddress,
@@ -1323,7 +1355,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
}); });
it('should revert if taker does not meet the balance threshold', async () => { it('should revert if taker does not meet the balance threshold', async () => {
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
nonCompliantBalanceThresholdWrapper.matchOrdersAsync( erc721NonCompliantBalanceThresholdWrapper.matchOrdersAsync(
compliantSignedOrder, compliantSignedOrder,
compliantSignedOrder, compliantSignedOrder,
nonCompliantAddress, nonCompliantAddress,
@@ -1341,30 +1373,30 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
}); });
it('Should successfully cancel order if maker meets balance threshold', async () => { it('Should successfully cancel order if maker meets balance threshold', async () => {
// Verify order is not cancelled // Verify order is not cancelled
const orderInfoBeforeCancelling = await makerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder) const orderInfoBeforeCancelling = await erc721MakerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder)
expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE); expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE);
// Cancel // Cancel
const txReceipt = await makerBalanceThresholdWrapper.cancelOrderAsync(compliantSignedOrder, compliantSignedOrder.makerAddress); const txReceipt = await erc721MakerBalanceThresholdWrapper.cancelOrderAsync(compliantSignedOrder, compliantSignedOrder.makerAddress);
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses: string[] = []; const expectedValidatedAddresseses: string[] = [];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
// Check that order was cancelled // Check that order was cancelled
const orderInfoAfterCancelling = await makerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder) const orderInfoAfterCancelling = await erc721MakerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder)
expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED); expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED);
}); });
it('Should successfully cancel order if maker does not meet balance threshold', async () => { it('Should successfully cancel order if maker does not meet balance threshold', async () => {
// Create order where maker does not meet balance threshold // Create order where maker does not meet balance threshold
const signedOrderWithBadMakerAddress = await nonCompliantOrderFactory.newSignedOrderAsync({}); const signedOrderWithBadMakerAddress = await nonCompliantOrderFactory.newSignedOrderAsync({});
// Verify order is not cancelled // Verify order is not cancelled
const orderInfoBeforeCancelling = await nonCompliantBalanceThresholdWrapper.getOrderInfoAsync(signedOrderWithBadMakerAddress) const orderInfoBeforeCancelling = await erc721NonCompliantBalanceThresholdWrapper.getOrderInfoAsync(signedOrderWithBadMakerAddress)
expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE); expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE);
// Cancel // Cancel
const txReceipt = await nonCompliantBalanceThresholdWrapper.cancelOrderAsync(signedOrderWithBadMakerAddress, signedOrderWithBadMakerAddress.makerAddress); const txReceipt = await erc721NonCompliantBalanceThresholdWrapper.cancelOrderAsync(signedOrderWithBadMakerAddress, signedOrderWithBadMakerAddress.makerAddress);
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses: string[] = []; const expectedValidatedAddresseses: string[] = [];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
// Check that order was cancelled // Check that order was cancelled
const orderInfoAfterCancelling = await makerBalanceThresholdWrapper.getOrderInfoAsync(signedOrderWithBadMakerAddress) const orderInfoAfterCancelling = await erc721MakerBalanceThresholdWrapper.getOrderInfoAsync(signedOrderWithBadMakerAddress)
expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED); expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED);
}); });
}); });
@@ -1382,17 +1414,17 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
]; ];
// Verify orders are not cancelled // Verify orders are not cancelled
await _.each(compliantSignedOrders, async (compliantSignedOrder) => { await _.each(compliantSignedOrders, async (compliantSignedOrder) => {
const orderInfoBeforeCancelling = await makerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder) const orderInfoBeforeCancelling = await erc721MakerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder)
return expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE); return expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE);
}); });
// Cancel // Cancel
const txReceipt = await makerBalanceThresholdWrapper.batchCancelOrdersAsync(compliantSignedOrders, compliantSignedOrder.makerAddress); const txReceipt = await erc721MakerBalanceThresholdWrapper.batchCancelOrdersAsync(compliantSignedOrders, compliantSignedOrder.makerAddress);
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses: string[] = []; const expectedValidatedAddresseses: string[] = [];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
// Check that order was cancelled // Check that order was cancelled
await _.each(compliantSignedOrders, async (compliantSignedOrder) => { await _.each(compliantSignedOrders, async (compliantSignedOrder) => {
const orderInfoAfterCancelling = await makerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder) const orderInfoAfterCancelling = await erc721MakerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder)
return expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED); return expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED);
}); });
}); });
@@ -1405,17 +1437,17 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
]; ];
// Verify orders are not cancelled // Verify orders are not cancelled
await _.each(nonCompliantSignedOrders, async (nonCompliantSignedOrder) => { await _.each(nonCompliantSignedOrders, async (nonCompliantSignedOrder) => {
const orderInfoBeforeCancelling = await nonCompliantBalanceThresholdWrapper.getOrderInfoAsync(nonCompliantSignedOrder) const orderInfoBeforeCancelling = await erc721NonCompliantBalanceThresholdWrapper.getOrderInfoAsync(nonCompliantSignedOrder)
return expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE); return expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE);
}); });
// Cancel // Cancel
const txReceipt = await nonCompliantBalanceThresholdWrapper.batchCancelOrdersAsync(nonCompliantSignedOrders, nonCompliantAddress); const txReceipt = await erc721NonCompliantBalanceThresholdWrapper.batchCancelOrdersAsync(nonCompliantSignedOrders, nonCompliantAddress);
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses: string[] = []; const expectedValidatedAddresseses: string[] = [];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
// Check that order was cancelled // Check that order was cancelled
await _.each(nonCompliantSignedOrders, async (nonCompliantSignedOrder) => { await _.each(nonCompliantSignedOrders, async (nonCompliantSignedOrder) => {
const orderInfoAfterCancelling = await nonCompliantBalanceThresholdWrapper.getOrderInfoAsync(nonCompliantSignedOrder) const orderInfoAfterCancelling = await erc721NonCompliantBalanceThresholdWrapper.getOrderInfoAsync(nonCompliantSignedOrder)
return expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED); return expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED);
}); });
}); });
@@ -1434,18 +1466,18 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
]; ];
// Verify orders are not cancelled // Verify orders are not cancelled
await _.each(compliantSignedOrders, async (compliantSignedOrder) => { await _.each(compliantSignedOrders, async (compliantSignedOrder) => {
const orderInfoBeforeCancelling = await makerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder) const orderInfoBeforeCancelling = await erc721MakerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder)
return expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE); return expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE);
}); });
// Cancel // Cancel
const cancelOrdersUpToThisSalt = new BigNumber(1); const cancelOrdersUpToThisSalt = new BigNumber(1);
const txReceipt = await makerBalanceThresholdWrapper.cancelOrdersUpToAsync(cancelOrdersUpToThisSalt, compliantSignedOrder.makerAddress); const txReceipt = await erc721MakerBalanceThresholdWrapper.cancelOrdersUpToAsync(cancelOrdersUpToThisSalt, compliantSignedOrder.makerAddress);
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses: string[] = []; const expectedValidatedAddresseses: string[] = [];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
// Check that order was cancelled // Check that order was cancelled
await _.each(compliantSignedOrders, async (compliantSignedOrder, salt: number) => { await _.each(compliantSignedOrders, async (compliantSignedOrder, salt: number) => {
const orderInfoAfterCancelling = await makerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder) const orderInfoAfterCancelling = await erc721MakerBalanceThresholdWrapper.getOrderInfoAsync(compliantSignedOrder)
const saltAsBigNumber = new BigNumber(salt); const saltAsBigNumber = new BigNumber(salt);
if (saltAsBigNumber.lessThanOrEqualTo(cancelOrdersUpToThisSalt)) { if (saltAsBigNumber.lessThanOrEqualTo(cancelOrdersUpToThisSalt)) {
return expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED); return expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED);
@@ -1463,18 +1495,18 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
]; ];
// Verify orders are not cancelled // Verify orders are not cancelled
await _.each(nonCompliantSignedOrders, async (nonCompliantSignedOrder) => { await _.each(nonCompliantSignedOrders, async (nonCompliantSignedOrder) => {
const orderInfoBeforeCancelling = await nonCompliantBalanceThresholdWrapper.getOrderInfoAsync(nonCompliantSignedOrder) const orderInfoBeforeCancelling = await erc721NonCompliantBalanceThresholdWrapper.getOrderInfoAsync(nonCompliantSignedOrder)
return expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE); return expect(orderInfoBeforeCancelling.orderStatus).to.be.equal(OrderStatus.FILLABLE);
}); });
// Cancel // Cancel
const cancelOrdersUpToThisSalt = new BigNumber(1); const cancelOrdersUpToThisSalt = new BigNumber(1);
const txReceipt = await nonCompliantBalanceThresholdWrapper.cancelOrdersUpToAsync(cancelOrdersUpToThisSalt, nonCompliantAddress); const txReceipt = await erc721NonCompliantBalanceThresholdWrapper.cancelOrdersUpToAsync(cancelOrdersUpToThisSalt, nonCompliantAddress);
// Assert validated addresses // Assert validated addresses
const expectedValidatedAddresseses: string[] = []; const expectedValidatedAddresseses: string[] = [];
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses); assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
// Check that order was cancelled // Check that order was cancelled
await _.each(nonCompliantSignedOrders, async (nonCompliantSignedOrder, salt: number) => { await _.each(nonCompliantSignedOrders, async (nonCompliantSignedOrder, salt: number) => {
const orderInfoAfterCancelling = await nonCompliantBalanceThresholdWrapper.getOrderInfoAsync(nonCompliantSignedOrder) const orderInfoAfterCancelling = await erc721NonCompliantBalanceThresholdWrapper.getOrderInfoAsync(nonCompliantSignedOrder)
const saltAsBigNumber = new BigNumber(salt); const saltAsBigNumber = new BigNumber(salt);
if (saltAsBigNumber.lessThanOrEqualTo(cancelOrdersUpToThisSalt)) { if (saltAsBigNumber.lessThanOrEqualTo(cancelOrdersUpToThisSalt)) {
return expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED); return expect(orderInfoAfterCancelling.orderStatus).to.be.equal(OrderStatus.CANCELLED);