From 16bd0ce7ec834029b5a6e8aa308c1d52ce6130ea Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Mon, 3 Dec 2018 14:48:10 -0800 Subject: generalized KYC extension passing all tests --- .../extensions/CompliantForwarder/CompliantForwarder.sol | 12 +++++++++++- packages/contracts/test/extensions/compliant_forwarder.ts | 8 ++++---- packages/types/src/index.ts | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'packages') diff --git a/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol b/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol index 27c578eae..b79d8db54 100644 --- a/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol +++ b/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol @@ -127,13 +127,23 @@ contract CompliantForwarder is ExchangeSelectors{ 0x20 // reserve space for return balance (0x20 bytes) ) if eq(success, 0) { + // Revert with `Error("BALANCE_CHECK_FAILED")` + mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000) + mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000) + mstore(64, 0x0000001453454e4445525f4e4f545f415554484f52495a454400000000000000) + mstore(96, 0) revert(0, 100) } // Revert if balance not held let addressBalance := mload(newMemFreePtr) if eq(addressBalance, 0) { - revert(0, 100) + // Revert with `Error("AT_LEAST_ONE_ADDRESS_HAS_ZERO_BALANCE")` + mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000) + mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000) + mstore(64, 0x0000002541545f4c454153545f4f4e455f414444524553535f4841535f5a4552) + mstore(96, 0x4f5f42414c414e43450000000000000000000000000000000000000000000000) + revert(0, 109) } } diff --git a/packages/contracts/test/extensions/compliant_forwarder.ts b/packages/contracts/test/extensions/compliant_forwarder.ts index 4eedffe05..639893798 100644 --- a/packages/contracts/test/extensions/compliant_forwarder.ts +++ b/packages/contracts/test/extensions/compliant_forwarder.ts @@ -210,7 +210,7 @@ describe.only(ContractName.CompliantForwarder, () => { beforeEach(async () => { erc20Balances = await erc20Wrapper.getBalancesAsync(); }); - it.only('should transfer the correct amounts when maker and taker are compliant', async () => { + it('should transfer the correct amounts when maker and taker are compliant', async () => { const txHash = await compliantForwarderInstance.executeTransaction.sendTransactionAsync( compliantSignedFillOrderTx.salt, compliantSignedFillOrderTx.signerAddress, @@ -302,10 +302,10 @@ describe.only(ContractName.CompliantForwarder, () => { compliantSignedFillOrderTx.data, compliantSignedFillOrderTx.signature, ), - RevertReason.TakerUnverified + RevertReason.AtLeastOneAddressHasZeroBalance ); }); - it.only('should revert if maker address is not compliant (does not hold a Yes Token)', async () => { + it('should revert if maker address is not compliant (does not hold a Yes Token)', async () => { // Create signed order with non-compliant maker address const signedOrderWithBadMakerAddress = await orderFactory.newSignedOrderAsync({ senderAddress: compliantForwarderInstance.address, @@ -330,7 +330,7 @@ describe.only(ContractName.CompliantForwarder, () => { signedFillOrderTx.data, signedFillOrderTx.signature, ), - RevertReason.MakerUnverified + RevertReason.AtLeastOneAddressHasZeroBalance ); }); }); diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 0c6fd7fd7..022b24e70 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -245,6 +245,7 @@ export enum RevertReason { InvalidAssetData = 'INVALID_ASSET_DATA', MakerUnverified = 'MAKER_UNVERIFED', TakerUnverified = 'TAKER_UNVERIFIED', + AtLeastOneAddressHasZeroBalance = 'AT_LEAST_ONE_ADDRESS_HAS_ZERO_BALANCE', } export enum StatusCodes { -- cgit v1.2.3