aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-12-04 09:35:45 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-12-19 05:36:05 +0800
commit5863a29a913e6418c5ae9cbec146ad30c3eee6cc (patch)
treedf78c08d5180568abc0095ba8226068c84cc0ce9 /packages
parentdf0de071841e2953f6843a86bbce4ecb3ad7b04f (diff)
downloaddexon-sol-tools-5863a29a913e6418c5ae9cbec146ad30c3eee6cc.tar
dexon-sol-tools-5863a29a913e6418c5ae9cbec146ad30c3eee6cc.tar.gz
dexon-sol-tools-5863a29a913e6418c5ae9cbec146ad30c3eee6cc.tar.bz2
dexon-sol-tools-5863a29a913e6418c5ae9cbec146ad30c3eee6cc.tar.lz
dexon-sol-tools-5863a29a913e6418c5ae9cbec146ad30c3eee6cc.tar.xz
dexon-sol-tools-5863a29a913e6418c5ae9cbec146ad30c3eee6cc.tar.zst
dexon-sol-tools-5863a29a913e6418c5ae9cbec146ad30c3eee6cc.zip
cleaning
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol58
-rw-r--r--packages/contracts/test/extensions/compliant_forwarder.ts6
2 files changed, 30 insertions, 34 deletions
diff --git a/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol b/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol
index b5290dc10..55100cae1 100644
--- a/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol
+++ b/packages/contracts/contracts/extensions/CompliantForwarder/CompliantForwarder.sol
@@ -32,8 +32,6 @@ contract CompliantForwarder is ExchangeSelectors{
IERC721Token internal COMPLIANCE_TOKEN;
event ValidatedAddresses (
- bytes32 selector,
- bytes32 one,
address[] addresses
);
@@ -52,11 +50,29 @@ contract CompliantForwarder is ExchangeSelectors{
)
external
{
- // Validate `signedFillOrderTransaction`
+ // Addresses that are validated below.
address[] memory validatedAddresses;
- bytes32 selectorS;
- bytes32 one;
+
+ /**
+ * Do not add variables after this point.
+ * The assembly block may overwrite their values.
+ */
+
+ // Validate addresses
assembly {
+ function exchangeCalldataload(offset) -> value {
+ // exchangeTxPtr at global level
+ // 0x20 for length offset into exchange TX
+ // 0x4 for function selector in exhcange TX
+ let exchangeTxPtr := calldataload(0x44)
+ let exchangeOffset := add(exchangeTxPtr, add(0x24, offset))
+ value := calldataload(exchangeOffset)
+ }
+
+ function loadExchangeData(offset) -> value {
+ value := exchangeCalldataload(add(offset, 0x4))
+ }
+
// Adds address to validate
function addAddressToValidate(addressToValidate) {
// Compute `addressesToValidate` memory location
@@ -72,30 +88,13 @@ contract CompliantForwarder is ExchangeSelectors{
mstore(add(addressesToValidate_, offset), addressToValidate)
}
- function validateAddress(addressToValidate) {
-
- }
-
- function exchangeCalldataload(offset) -> value {
- // exchangeTxPtr at global level
- // 0x20 for length offset into exchange TX
- // 0x4 for function selector in exhcange TX
- let exchangeTxPtr := calldataload(0x44)
- let exchangeOffset := add(exchangeTxPtr, add(0x24, offset))
- value := calldataload(exchangeOffset)
- }
-
- function loadExchangeData(offset) -> value {
- value := exchangeCalldataload(add(offset, 0x4))
- }
-
function appendMakerAddressFromOrder(orderParamIndex) {
let orderPtr := loadExchangeData(0)
let makerAddress := loadExchangeData(orderPtr)
addAddressToValidate(makerAddress)
}
- function appendMakerAddressesFromOrderSet(orderSetParamIndex) -> one {
+ function appendMakerAddressesFromOrderSet(orderSetParamIndex) {
let orderSetPtr := loadExchangeData(0)
let orderSetLength := loadExchangeData(orderSetPtr)
let orderSetElementPtr := add(orderSetPtr, 0x20)
@@ -115,7 +114,7 @@ contract CompliantForwarder is ExchangeSelectors{
switch selector
case 0x297bb70b00000000000000000000000000000000000000000000000000000000 /* batchFillOrders */
{
- one := appendMakerAddressesFromOrderSet(0)
+ appendMakerAddressesFromOrderSet(0)
}
case 0x3c28d86100000000000000000000000000000000000000000000000000000000 /* matchOrders */
{
@@ -133,12 +132,12 @@ contract CompliantForwarder is ExchangeSelectors{
revert(0, 100)
}
+ //
let addressesToValidate := mload(0x40)
let nAddressesToValidate := mload(addressesToValidate)
let newMemFreePtr := add(addressesToValidate, add(0x20, mul(mload(addressesToValidate), 0x20)))
mstore(0x40, newMemFreePtr)
- /*
// Validate addresses
let complianceTokenAddress := sload(COMPLIANCE_TOKEN_slot)
for {let i := add(0x20, addressesToValidate)} lt(i, add(addressesToValidate, add(32, mul(nAddressesToValidate, 32)))) {i := add(i, 32)} {
@@ -175,21 +174,20 @@ contract CompliantForwarder is ExchangeSelectors{
mstore(96, 0x4f5f42414c414e43450000000000000000000000000000000000000000000000)
revert(0, 109)
}
- }*/
+ }
+ // Record validated addresses
validatedAddresses := addressesToValidate
- selectorS := selector
}
- emit ValidatedAddresses(selectorS, one, validatedAddresses);
+ emit ValidatedAddresses(validatedAddresses);
// All entities are verified. Execute fillOrder.
- /*
EXCHANGE.executeTransaction(
salt,
signerAddress,
signedExchangeTransaction,
signature
- );*/
+ );
}
} \ No newline at end of file
diff --git a/packages/contracts/test/extensions/compliant_forwarder.ts b/packages/contracts/test/extensions/compliant_forwarder.ts
index e995e5435..cc05f9981 100644
--- a/packages/contracts/test/extensions/compliant_forwarder.ts
+++ b/packages/contracts/test/extensions/compliant_forwarder.ts
@@ -221,9 +221,7 @@ describe.only(ContractName.CompliantForwarder, () => {
const tx = await decoder.getTxWithDecodedLogsAsync(txHash);
console.log(JSON.stringify(tx, null, 4));
console.log('****** MAKER ADDRESS = ', compliantSignedOrder.makerAddress);
-
-
- /*const newBalances = await erc20Wrapper.getBalancesAsync();
+ const newBalances = await erc20Wrapper.getBalancesAsync();
const makerAssetFillAmount = takerAssetFillAmount
.times(compliantSignedOrder.makerAssetAmount)
.dividedToIntegerBy(compliantSignedOrder.takerAssetAmount);
@@ -253,7 +251,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