diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-12-04 07:38:06 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-12-19 05:36:05 +0800 |
commit | bab7569ed9b0739a3d01c64dea17adb1bf5b82e1 (patch) | |
tree | a790258c6b817f6e96936f7e7ae66e87b5cebfe4 | |
parent | 16bd0ce7ec834029b5a6e8aa308c1d52ce6130ea (diff) | |
download | dexon-sol-tools-bab7569ed9b0739a3d01c64dea17adb1bf5b82e1.tar dexon-sol-tools-bab7569ed9b0739a3d01c64dea17adb1bf5b82e1.tar.gz dexon-sol-tools-bab7569ed9b0739a3d01c64dea17adb1bf5b82e1.tar.bz2 dexon-sol-tools-bab7569ed9b0739a3d01c64dea17adb1bf5b82e1.tar.lz dexon-sol-tools-bab7569ed9b0739a3d01c64dea17adb1bf5b82e1.tar.xz dexon-sol-tools-bab7569ed9b0739a3d01c64dea17adb1bf5b82e1.tar.zst dexon-sol-tools-bab7569ed9b0739a3d01c64dea17adb1bf5b82e1.zip |
Refactoring asm
-rw-r--r-- | packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol b/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol index b79d8db54..4ad9092bd 100644 --- a/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol +++ b/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol @@ -72,7 +72,42 @@ contract CompliantForwarder is ExchangeSelectors{ mstore(add(addressesToValidate_, offset), addressToValidate) } - function appendMakerAddressFromOrder(paramIndex) { + function toGlobalCalldataOffset(offset) -> globalOffset { + globalOffset := add(0x4, offset) + } + + function toExchangeCalldataOffset(offset, orderParamIndex) -> exchangeOffset { + // exchangeTxPtr at global level + // 0x20 for length offset into exchange TX + // 0x4 for function selector in exhcange TX + let exchangeTxPtr := calldataload(0x44) + exchangeOffset := add(0x4, add(exchangeTxPtr, add(0x24, offset))) + } + + function toOrderOffset(offset, orderParamIndex) -> orderOffset { + let exchangeOffset := calldataload( + toExchangeCalldataOffset( + offset, + orderParamIndex + ) + ) + orderOffset := toExchangeCalldataOffset(exchangeOffset, orderParamIndex) + } + + // 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*/)) + 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 @@ -80,6 +115,7 @@ contract CompliantForwarder is ExchangeSelectors{ let makerAddress := calldataload(orderPtr) addAddressToValidate(makerAddress) } +*/ // Extract addresses to validate @@ -88,11 +124,13 @@ contract CompliantForwarder is ExchangeSelectors{ switch selector case 0x097bb70b00000000000000000000000000000000000000000000000000000000 /* batchFillOrders */ { - + //appendMakerAddressFromOrderSet() } case 0x3c28d86100000000000000000000000000000000000000000000000000000000 /* matchOrders */ { - + // appendMakerAddressFromOrder(0) + //// appendMakerAddressFromOrder(1) + // addAddressToValidate(signerAddress) } case 0xb4be83d500000000000000000000000000000000000000000000000000000000 /* fillOrder */ { |