aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorRemco Bloemen <remco@wicked.ventures>2018-02-27 07:09:14 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:16 +0800
commita4f294c090af77c15081fef03401bd34c120041e (patch)
tree7f9f0507faf7c284739edebd3e1bd40b241e6e25 /packages
parent58c5e800d0e6ec581e2050d115c4556f495f358b (diff)
downloaddexon-sol-tools-a4f294c090af77c15081fef03401bd34c120041e.tar.gz
dexon-sol-tools-a4f294c090af77c15081fef03401bd34c120041e.tar.zst
dexon-sol-tools-a4f294c090af77c15081fef03401bd34c120041e.zip
Add offset to signature
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol24
1 files changed, 13 insertions, 11 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
index db8a4bfad..a2a168656 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
@@ -63,7 +63,7 @@ contract MixinWrapperFunctions is
{
// We need to call MExchangeCore.fillOrder using a delegatecall in
// assembly so that we can intercept a call that throws. For this, we
- // need the input encoded in memory in the Ethereum ABI format [1].
+ // need the input encoded in memory in the Ethereum ABIv2 format [1].
//
// | Offset | Length | Contents |
// |--------|--------|------------------------------|
@@ -71,22 +71,23 @@ contract MixinWrapperFunctions is
// | 4 | 160 | address[5] orderAddresses |
// | 164 | 192 | uint256[6] orderValues |
// | 356 | 32 | uint256 takerTokenFillAmount |
- // | 388 | 32 | len(signature) |
- // | 420 | (1) | signature |
+ // | 388 | 32 | offset to signature (416) |
+ // | 420 | 32 | len(signature) |
+ // | 452 | (1) | signature |
// | (2) | (3) | padding (zero) |
// | (4) | | end of input |
//
// (1): len(signature)
- // (2): 420 + len(signature)
+ // (2): 452 + len(signature)
// (3): (32 - len(signature)) mod 32
- // (4): 420 + len(signature) + (32 - len(signature)) mod 32
+ // (4): 452 + len(signature) + (32 - len(signature)) mod 32
//
// [1]: https://solidity.readthedocs.io/en/develop/abi-spec.html
// Allocate memory for input
uint256 signatureLength = signature.length;
uint256 paddingLength = (32 - signatureLength) % 32
- uint256 inputSize = 420 + signatureLength + paddingLength;
+ uint256 inputSize = 452 + signatureLength + paddingLength;
bytes memory input = new bytes(inputSize);
// The in memory layout of `bytes memory input` starts with
@@ -108,8 +109,8 @@ contract MixinWrapperFunctions is
mstore(start, FILL_ORDER_FUNCTION_SIGNATURE);
}
- // Write orderAddresses, orderValues, takerTokenFillAmount
- // and len(signature)
+ // Write orderAddresses, orderValues, takerTokenFillAmount,
+ // offset to signature and len(signature)
// It is done in assembly so we can write 32 bytes at a time. In
// solidity we would have to copy one byte at a time.
// Fixed size arrays do not have the `uint256 length` prefix that
@@ -126,15 +127,16 @@ contract MixinWrapperFunctions is
mstore(add(start, 260), add(orderValues, 96)) // takerFee
mstore(add(start, 292), add(orderValues, 128)) // expiration
mstore(add(start, 356), takerTokenFillAmount)
- mstore(add(start, 388), signatureLength)
+ mstore(add(start, 388), 416)
+ mstore(add(start, 420), signatureLength)
}
// Write signature contents and padding one byte at a time
for (uint256 i = 0; i < signatureLength; i++) {
- input[420 + i] = signature[i];
+ input[452 + i] = signature[i];
}
for (uint256 i = 0; i < paddingLength; i++) {
- input[420 + signatureLength + i] = 0x00;
+ input[452 + signatureLength + i] = 0x00;
}
// Call the function