cleaning
This commit is contained in:
parent
df0de07184
commit
5863a29a91
@ -32,8 +32,6 @@ contract CompliantForwarder is ExchangeSelectors{
|
|||||||
IERC721Token internal COMPLIANCE_TOKEN;
|
IERC721Token internal COMPLIANCE_TOKEN;
|
||||||
|
|
||||||
event ValidatedAddresses (
|
event ValidatedAddresses (
|
||||||
bytes32 selector,
|
|
||||||
bytes32 one,
|
|
||||||
address[] addresses
|
address[] addresses
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -52,11 +50,29 @@ contract CompliantForwarder is ExchangeSelectors{
|
|||||||
)
|
)
|
||||||
external
|
external
|
||||||
{
|
{
|
||||||
// Validate `signedFillOrderTransaction`
|
// Addresses that are validated below.
|
||||||
address[] memory validatedAddresses;
|
address[] memory validatedAddresses;
|
||||||
bytes32 selectorS;
|
|
||||||
bytes32 one;
|
/**
|
||||||
|
* Do not add variables after this point.
|
||||||
|
* The assembly block may overwrite their values.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Validate addresses
|
||||||
assembly {
|
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
|
// Adds address to validate
|
||||||
function addAddressToValidate(addressToValidate) {
|
function addAddressToValidate(addressToValidate) {
|
||||||
// Compute `addressesToValidate` memory location
|
// Compute `addressesToValidate` memory location
|
||||||
@ -72,30 +88,13 @@ contract CompliantForwarder is ExchangeSelectors{
|
|||||||
mstore(add(addressesToValidate_, offset), addressToValidate)
|
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) {
|
function appendMakerAddressFromOrder(orderParamIndex) {
|
||||||
let orderPtr := loadExchangeData(0)
|
let orderPtr := loadExchangeData(0)
|
||||||
let makerAddress := loadExchangeData(orderPtr)
|
let makerAddress := loadExchangeData(orderPtr)
|
||||||
addAddressToValidate(makerAddress)
|
addAddressToValidate(makerAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendMakerAddressesFromOrderSet(orderSetParamIndex) -> one {
|
function appendMakerAddressesFromOrderSet(orderSetParamIndex) {
|
||||||
let orderSetPtr := loadExchangeData(0)
|
let orderSetPtr := loadExchangeData(0)
|
||||||
let orderSetLength := loadExchangeData(orderSetPtr)
|
let orderSetLength := loadExchangeData(orderSetPtr)
|
||||||
let orderSetElementPtr := add(orderSetPtr, 0x20)
|
let orderSetElementPtr := add(orderSetPtr, 0x20)
|
||||||
@ -115,7 +114,7 @@ contract CompliantForwarder is ExchangeSelectors{
|
|||||||
switch selector
|
switch selector
|
||||||
case 0x297bb70b00000000000000000000000000000000000000000000000000000000 /* batchFillOrders */
|
case 0x297bb70b00000000000000000000000000000000000000000000000000000000 /* batchFillOrders */
|
||||||
{
|
{
|
||||||
one := appendMakerAddressesFromOrderSet(0)
|
appendMakerAddressesFromOrderSet(0)
|
||||||
}
|
}
|
||||||
case 0x3c28d86100000000000000000000000000000000000000000000000000000000 /* matchOrders */
|
case 0x3c28d86100000000000000000000000000000000000000000000000000000000 /* matchOrders */
|
||||||
{
|
{
|
||||||
@ -133,12 +132,12 @@ contract CompliantForwarder is ExchangeSelectors{
|
|||||||
revert(0, 100)
|
revert(0, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
let addressesToValidate := mload(0x40)
|
let addressesToValidate := mload(0x40)
|
||||||
let nAddressesToValidate := mload(addressesToValidate)
|
let nAddressesToValidate := mload(addressesToValidate)
|
||||||
let newMemFreePtr := add(addressesToValidate, add(0x20, mul(mload(addressesToValidate), 0x20)))
|
let newMemFreePtr := add(addressesToValidate, add(0x20, mul(mload(addressesToValidate), 0x20)))
|
||||||
mstore(0x40, newMemFreePtr)
|
mstore(0x40, newMemFreePtr)
|
||||||
|
|
||||||
/*
|
|
||||||
// Validate addresses
|
// Validate addresses
|
||||||
let complianceTokenAddress := sload(COMPLIANCE_TOKEN_slot)
|
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)} {
|
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)
|
mstore(96, 0x4f5f42414c414e43450000000000000000000000000000000000000000000000)
|
||||||
revert(0, 109)
|
revert(0, 109)
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
// Record validated addresses
|
||||||
validatedAddresses := addressesToValidate
|
validatedAddresses := addressesToValidate
|
||||||
selectorS := selector
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit ValidatedAddresses(selectorS, one, validatedAddresses);
|
emit ValidatedAddresses(validatedAddresses);
|
||||||
|
|
||||||
// All entities are verified. Execute fillOrder.
|
// All entities are verified. Execute fillOrder.
|
||||||
/*
|
|
||||||
EXCHANGE.executeTransaction(
|
EXCHANGE.executeTransaction(
|
||||||
salt,
|
salt,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signedExchangeTransaction,
|
signedExchangeTransaction,
|
||||||
signature
|
signature
|
||||||
);*/
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -221,9 +221,7 @@ describe.only(ContractName.CompliantForwarder, () => {
|
|||||||
const tx = await decoder.getTxWithDecodedLogsAsync(txHash);
|
const tx = await decoder.getTxWithDecodedLogsAsync(txHash);
|
||||||
console.log(JSON.stringify(tx, null, 4));
|
console.log(JSON.stringify(tx, null, 4));
|
||||||
console.log('****** MAKER ADDRESS = ', compliantSignedOrder.makerAddress);
|
console.log('****** MAKER ADDRESS = ', compliantSignedOrder.makerAddress);
|
||||||
|
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||||
|
|
||||||
/*const newBalances = await erc20Wrapper.getBalancesAsync();
|
|
||||||
const makerAssetFillAmount = takerAssetFillAmount
|
const makerAssetFillAmount = takerAssetFillAmount
|
||||||
.times(compliantSignedOrder.makerAssetAmount)
|
.times(compliantSignedOrder.makerAssetAmount)
|
||||||
.dividedToIntegerBy(compliantSignedOrder.takerAssetAmount);
|
.dividedToIntegerBy(compliantSignedOrder.takerAssetAmount);
|
||||||
@ -253,7 +251,7 @@ describe.only(ContractName.CompliantForwarder, () => {
|
|||||||
);
|
);
|
||||||
expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
|
expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
|
||||||
erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)),
|
erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)),
|
||||||
);*/
|
);
|
||||||
});
|
});
|
||||||
it('should revert if the signed transaction is not intended for fillOrder', async () => {
|
it('should revert if the signed transaction is not intended for fillOrder', async () => {
|
||||||
// Create signed order without the fillOrder function selector
|
// Create signed order without the fillOrder function selector
|
||||||
|
Loading…
x
Reference in New Issue
Block a user