diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-12-04 09:18:34 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-12-19 05:36:05 +0800 |
commit | c040ad085063ec67abfd73c5cf61739f54d2a7a6 (patch) | |
tree | 61f7afacb3e54aaa8f5d53f998954894e632506d /packages | |
parent | 8007ef6c0b08ce7d2394323f000df7baeb254ebf (diff) | |
download | dexon-sol-tools-c040ad085063ec67abfd73c5cf61739f54d2a7a6.tar dexon-sol-tools-c040ad085063ec67abfd73c5cf61739f54d2a7a6.tar.gz dexon-sol-tools-c040ad085063ec67abfd73c5cf61739f54d2a7a6.tar.bz2 dexon-sol-tools-c040ad085063ec67abfd73c5cf61739f54d2a7a6.tar.lz dexon-sol-tools-c040ad085063ec67abfd73c5cf61739f54d2a7a6.tar.xz dexon-sol-tools-c040ad085063ec67abfd73c5cf61739f54d2a7a6.tar.zst dexon-sol-tools-c040ad085063ec67abfd73c5cf61739f54d2a7a6.zip |
cleaning
Diffstat (limited to 'packages')
-rw-r--r-- | packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol | 60 | ||||
-rw-r--r-- | packages/contracts/test/extensions/compliant_forwarder.ts | 15 |
2 files changed, 19 insertions, 56 deletions
diff --git a/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol b/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol index 0c596dfc2..2d06d69e6 100644 --- a/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol +++ b/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol @@ -84,76 +84,36 @@ contract CompliantForwarder is ExchangeSelectors{ exchangeOffset := add(0x4, add(exchangeTxPtr, add(0x24, offset))) } - function toOrderOffset(offset, orderParamIndex) -> orderOffset { - let exchangeOffset := calldataload( - toExchangeCalldataOffset( - offset, - orderParamIndex - ) - ) - orderOffset := toExchangeCalldataOffset(exchangeOffset, orderParamIndex) + function exchangeCalldataload(offset) -> value { + + value := calldataload(toExchangeCalldataOffset(offset, 0)) } - // function readMakerFieldFromOrder() - - /* - function readFieldFromOrder() - - function readMakerFieldFromOrder()*/ - function appendMakerAddressFromOrder(orderParamIndex) { - let makerAddress := calldataload(toOrderOffset(0 /* makerAddress is at 0'th field */, 0 /*order is 1st param*/)) + let orderPtr := exchangeCalldataload(0) + let makerAddress := exchangeCalldataload(orderPtr) addAddressToValidate(makerAddress) } function appendMakerAddressesFromOrderSet(orderSetParamIndex) -> one { - let orderSetPtr := calldataload(toExchangeCalldataOffset(0, 0)) - let orderSetPtrCalldata := toExchangeCalldataOffset(add(orderSetPtr, 0x20), 0) - let orderSetLength := calldataload(toExchangeCalldataOffset(orderSetPtr, 0)) - for {let orderPtrOffset := add(0x20, orderSetPtr)} lt(orderPtrOffset, add(0x20, add(orderSetPtr, mul(0x20, orderSetLength)))) {orderPtrOffset := add(0x20, orderPtrOffset)} { - let orderPtr := calldataload(toExchangeCalldataOffset(orderPtrOffset, 0)) - let makerAddress := calldataload(add(orderSetPtrCalldata, orderPtr)) - addAddressToValidate(makerAddress) - } - } - - function exchangeCalldataload(offset) -> value { - value := calldataload(toExchangeCalldataOffset(offset, 0)) - } - - - function appendMakerAddressesFromOrderSet2(orderSetParamIndex) -> one { let orderSetPtr := exchangeCalldataload(0) let orderSetLength := exchangeCalldataload(orderSetPtr) - - for {let orderPtrOffset := add(0x20, orderSetPtr)} lt(orderPtrOffset, add(0x20, add(orderSetPtr, mul(0x20, orderSetLength)))) {orderPtrOffset := add(0x20, orderPtrOffset)} { + let orderSetElementPtr := add(orderSetPtr, 0x20) + let orderSetElementEndPtr := add(orderSetElementPtr, mul(orderSetLength, 0x20)) + for {let orderPtrOffset := orderSetElementPtr} lt(orderPtrOffset, orderSetElementEndPtr) {orderPtrOffset := add(orderPtrOffset, 0x20)} { let orderPtr := exchangeCalldataload(orderPtrOffset) - let makerAddress := exchangeCalldataload(add(orderSetPtr, add(0x20, orderPtr))) + let makerAddress := exchangeCalldataload(add(orderPtr, orderSetElementPtr)) addAddressToValidate(makerAddress) } } -/* - function appendMakerAddressFromOrderSet(paramIndex) { - let exchangeTxPtr := calldataload(0x44) - // Add 0x20 for length offset and 0x04 for selector offset - let orderPtrRelativeToExchangeTx := calldataload(add(0x4, add(exchangeTxPtr, 0x24))) // 0x60 - let orderPtr := add(0x4,add(exchangeTxPtr, add(0x24, orderPtrRelativeToExchangeTx))) - let makerAddress := calldataload(orderPtr) - addAddressToValidate(makerAddress) - } -*/ - - - - // Extract addresses to validate let exchangeTxPtr1 := calldataload(0x44) let selector := and(calldataload(add(0x4, add(0x20, exchangeTxPtr1))), 0xffffffff00000000000000000000000000000000000000000000000000000000) switch selector case 0x297bb70b00000000000000000000000000000000000000000000000000000000 /* batchFillOrders */ { - one := appendMakerAddressesFromOrderSet2(0) + one := appendMakerAddressesFromOrderSet(0) } case 0x3c28d86100000000000000000000000000000000000000000000000000000000 /* matchOrders */ { diff --git a/packages/contracts/test/extensions/compliant_forwarder.ts b/packages/contracts/test/extensions/compliant_forwarder.ts index 846414685..e995e5435 100644 --- a/packages/contracts/test/extensions/compliant_forwarder.ts +++ b/packages/contracts/test/extensions/compliant_forwarder.ts @@ -206,11 +206,11 @@ describe.only(ContractName.CompliantForwarder, () => { afterEach(async () => { await blockchainLifecycle.revertAsync(); }); - describe('fillOrder', () => { + describe.only('fillOrder', () => { beforeEach(async () => { erc20Balances = await erc20Wrapper.getBalancesAsync(); }); - it('should transfer the correct amounts when maker and taker are compliant', async () => { + it.only('should transfer the correct amounts when maker and taker are compliant', async () => { const txHash = await compliantForwarderInstance.executeTransaction.sendTransactionAsync( compliantSignedFillOrderTx.salt, compliantSignedFillOrderTx.signerAddress, @@ -220,7 +220,10 @@ describe.only(ContractName.CompliantForwarder, () => { const decoder = new LogDecoder(web3Wrapper); const tx = await decoder.getTxWithDecodedLogsAsync(txHash); console.log(JSON.stringify(tx, null, 4)); - const newBalances = await erc20Wrapper.getBalancesAsync(); + console.log('****** MAKER ADDRESS = ', compliantSignedOrder.makerAddress); + + + /*const newBalances = await erc20Wrapper.getBalancesAsync(); const makerAssetFillAmount = takerAssetFillAmount .times(compliantSignedOrder.makerAssetAmount) .dividedToIntegerBy(compliantSignedOrder.takerAssetAmount); @@ -250,7 +253,7 @@ describe.only(ContractName.CompliantForwarder, () => { ); 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 fillOrder', async () => { // Create signed order without the fillOrder function selector @@ -335,11 +338,11 @@ describe.only(ContractName.CompliantForwarder, () => { }); }); - describe.only('batchFillOrders', () => { + describe('batchFillOrders', () => { 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 () => { let order2 = _.cloneDeep(compliantSignedOrder); order2.makerAddress = `0x${_.reverse(compliantSignedOrder.makerAddress.slice(2).split('')).join('')}`; const orders = [compliantSignedOrder, order2]; |