Updated the structure of the archive directory

This commit is contained in:
Alex Towle 2019-08-03 16:33:28 -07:00
parent 9a35e2db77
commit 5ba0e0dc54
10 changed files with 35 additions and 43 deletions

View File

@ -24,10 +24,10 @@
} }
}, },
"contracts": [ "contracts": [
"archive/MixinAuthorizable.sol",
"src/ERC1155Proxy.sol", "src/ERC1155Proxy.sol",
"src/ERC20Proxy.sol", "src/ERC20Proxy.sol",
"src/ERC721Proxy.sol", "src/ERC721Proxy.sol",
"src/MixinAuthorizable.sol",
"src/MultiAssetProxy.sol", "src/MultiAssetProxy.sol",
"src/StaticCallProxy.sol", "src/StaticCallProxy.sol",
"src/interfaces/IAssetData.sol", "src/interfaces/IAssetData.sol",

View File

@ -19,8 +19,8 @@
pragma solidity ^0.5.9; pragma solidity ^0.5.9;
import "../archive/Ownable.sol"; import "../archive/Ownable.sol";
import "./interfaces/IAssetProxy.sol"; import "../src/interfaces/IAssetProxy.sol";
import "./interfaces/IAssetProxyDispatcher.sol"; import "../src/interfaces/IAssetProxyDispatcher.sol";
contract MixinAssetProxyDispatcher is contract MixinAssetProxyDispatcher is

View File

@ -19,7 +19,7 @@
pragma solidity ^0.5.9; pragma solidity ^0.5.9;
import "../archive/Ownable.sol"; import "../archive/Ownable.sol";
import "./interfaces/IAuthorizable.sol"; import "../src/interfaces/IAuthorizable.sol";
contract MixinAuthorizable is contract MixinAuthorizable is

View File

@ -1,6 +1,6 @@
pragma solidity ^0.5.9; pragma solidity ^0.5.9;
import "./interfaces/IOwnable.sol"; import "@0x/contracts-utils/contracts/src/interfaces/IOwnable.sol";
contract Ownable is contract Ownable is

View File

@ -1,8 +0,0 @@
pragma solidity ^0.5.9;
contract IOwnable {
function transferOwnership(address newOwner)
public;
}

View File

@ -21,7 +21,7 @@ pragma solidity ^0.5.9;
import "@0x/contracts-utils/contracts/src/LibBytes.sol"; import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/SafeMath.sol"; import "@0x/contracts-utils/contracts/src/SafeMath.sol";
import "@0x/contracts-erc1155/contracts/src/interfaces/IERC1155.sol"; import "@0x/contracts-erc1155/contracts/src/interfaces/IERC1155.sol";
import "./MixinAuthorizable.sol"; import "../archive/MixinAuthorizable.sol";
import "./interfaces/IAssetProxy.sol"; import "./interfaces/IAssetProxy.sol";
@ -69,7 +69,7 @@ contract ERC1155Proxy is
for (uint256 i = 0; i != length; i++) { for (uint256 i = 0; i != length; i++) {
// We write the scaled values to an unused location in memory in order // We write the scaled values to an unused location in memory in order
// to avoid copying over `ids` or `data`. This is possible if they are // to avoid copying over `ids` or `data`. This is possible if they are
// identical to `values` and the offsets for each are pointing to the // identical to `values` and the offsets for each are pointing to the
// same location in the ABI encoded calldata. // same location in the ABI encoded calldata.
scaledValues[i] = _safeMul(values[i], amount); scaledValues[i] = _safeMul(values[i], amount);
} }

View File

@ -18,7 +18,7 @@
pragma solidity ^0.5.9; pragma solidity ^0.5.9;
import "./MixinAuthorizable.sol"; import "../archive/MixinAuthorizable.sol";
contract ERC20Proxy is contract ERC20Proxy is
@ -26,9 +26,9 @@ contract ERC20Proxy is
{ {
// Id of this proxy. // Id of this proxy.
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC20Token(address)")); bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC20Token(address)"));
// solhint-disable-next-line payable-fallback // solhint-disable-next-line payable-fallback
function () function ()
external external
{ {
assembly { assembly {
@ -117,13 +117,13 @@ contract ERC20Proxy is
// * The "token address" is offset 32+4=36 bytes into "assetData" (tables 1 & 2). // * The "token address" is offset 32+4=36 bytes into "assetData" (tables 1 & 2).
// [tokenOffset = assetDataOffsetFromHeader + 36 = calldataload(4) + 4 + 36] // [tokenOffset = assetDataOffsetFromHeader + 36 = calldataload(4) + 4 + 36]
let token := calldataload(add(calldataload(4), 40)) let token := calldataload(add(calldataload(4), 40))
/////// Setup Header Area /////// /////// Setup Header Area ///////
// This area holds the 4-byte `transferFrom` selector. // This area holds the 4-byte `transferFrom` selector.
// Any trailing data in transferFromSelector will be // Any trailing data in transferFromSelector will be
// overwritten in the next `mstore` call. // overwritten in the next `mstore` call.
mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
/////// Setup Params Area /////// /////// Setup Params Area ///////
// We copy the fields `from`, `to` and `amount` in bulk // We copy the fields `from`, `to` and `amount` in bulk
// from our own calldata to the new calldata. // from our own calldata to the new calldata.
@ -147,7 +147,7 @@ contract ERC20Proxy is
// If the token does return data, we require that it is a single // If the token does return data, we require that it is a single
// nonzero 32 bytes value. // nonzero 32 bytes value.
// So the transfer succeeded if the call succeeded and either // So the transfer succeeded if the call succeeded and either
// returned nothing, or returned a non-zero 32 byte value. // returned nothing, or returned a non-zero 32 byte value.
success := and(success, or( success := and(success, or(
iszero(returndatasize), iszero(returndatasize),
and( and(
@ -158,7 +158,7 @@ contract ERC20Proxy is
if success { if success {
return(0, 0) return(0, 0)
} }
// Revert with `Error("TRANSFER_FAILED")` // Revert with `Error("TRANSFER_FAILED")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000) mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000) mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)

View File

@ -18,7 +18,7 @@
pragma solidity ^0.5.9; pragma solidity ^0.5.9;
import "./MixinAuthorizable.sol"; import "../archive/MixinAuthorizable.sol";
contract ERC721Proxy is contract ERC721Proxy is
@ -28,7 +28,7 @@ contract ERC721Proxy is
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC721Token(address,uint256)")); bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC721Token(address,uint256)"));
// solhint-disable-next-line payable-fallback // solhint-disable-next-line payable-fallback
function () function ()
external external
{ {
assembly { assembly {
@ -93,10 +93,10 @@ contract ERC721Proxy is
// | Params | | 2 * 32 | function parameters: | // | Params | | 2 * 32 | function parameters: |
// | | 4 | 12 + 20 | 1. token address | // | | 4 | 12 + 20 | 1. token address |
// | | 36 | | 2. tokenId | // | | 36 | | 2. tokenId |
// We construct calldata for the `token.transferFrom` ABI. // We construct calldata for the `token.transferFrom` ABI.
// The layout of this calldata is in the table below. // The layout of this calldata is in the table below.
// //
// | Area | Offset | Length | Contents | // | Area | Offset | Length | Contents |
// |----------|--------|---------|-------------------------------------| // |----------|--------|---------|-------------------------------------|
// | Header | 0 | 4 | function selector | // | Header | 0 | 4 | function selector |
@ -121,7 +121,7 @@ contract ERC721Proxy is
// Any trailing data in transferFromSelector will be // Any trailing data in transferFromSelector will be
// overwritten in the next `mstore` call. // overwritten in the next `mstore` call.
mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
/////// Setup Params Area /////// /////// Setup Params Area ///////
// We copy the fields `from` and `to` in bulk // We copy the fields `from` and `to` in bulk
// from our own calldata to the new calldata. // from our own calldata to the new calldata.
@ -145,7 +145,7 @@ contract ERC721Proxy is
if success { if success {
return(0, 0) return(0, 0)
} }
// Revert with `Error("TRANSFER_FAILED")` // Revert with `Error("TRANSFER_FAILED")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000) mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000) mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)

View File

@ -18,8 +18,8 @@
pragma solidity ^0.5.9; pragma solidity ^0.5.9;
import "./MixinAssetProxyDispatcher.sol"; import "../archive/MixinAssetProxyDispatcher.sol";
import "./MixinAuthorizable.sol"; import "../archive/MixinAuthorizable.sol";
contract MultiAssetProxy is contract MultiAssetProxy is
@ -105,7 +105,7 @@ contract MultiAssetProxy is
// | | 36 | | 2. offset to nestedAssetData (*) | // | | 36 | | 2. offset to nestedAssetData (*) |
// | Data | | | amounts: | // | Data | | | amounts: |
// | | 68 | 32 | amounts Length | // | | 68 | 32 | amounts Length |
// | | 100 | a | amounts Contents | // | | 100 | a | amounts Contents |
// | | | | nestedAssetData: | // | | | | nestedAssetData: |
// | | 100 + a | 32 | nestedAssetData Length | // | | 100 + a | 32 | nestedAssetData Length |
// | | 132 + a | b | nestedAssetData Contents (offsets) | // | | 132 + a | b | nestedAssetData Contents (offsets) |
@ -149,8 +149,8 @@ contract MultiAssetProxy is
// + 32 (amounts offset) // + 32 (amounts offset)
let nestedAssetDataOffset := calldataload(add(assetDataOffset, 68)) let nestedAssetDataOffset := calldataload(add(assetDataOffset, 68))
// In order to find the start of the `amounts` contents, we must add: // In order to find the start of the `amounts` contents, we must add:
// assetDataOffset // assetDataOffset
// + 32 (assetData len) // + 32 (assetData len)
// + 4 (assetProxyId) // + 4 (assetProxyId)
// + amountsOffset // + amountsOffset
@ -160,8 +160,8 @@ contract MultiAssetProxy is
// Load number of elements in `amounts` // Load number of elements in `amounts`
let amountsLen := calldataload(sub(amountsContentsStart, 32)) let amountsLen := calldataload(sub(amountsContentsStart, 32))
// In order to find the start of the `nestedAssetData` contents, we must add: // In order to find the start of the `nestedAssetData` contents, we must add:
// assetDataOffset // assetDataOffset
// + 32 (assetData len) // + 32 (assetData len)
// + 4 (assetProxyId) // + 4 (assetProxyId)
// + nestedAssetDataOffset // + nestedAssetDataOffset
@ -190,10 +190,10 @@ contract MultiAssetProxy is
// Overwrite existing offset to `assetData` with our own // Overwrite existing offset to `assetData` with our own
mstore(4, 128) mstore(4, 128)
// Load `amount` // Load `amount`
let amount := calldataload(100) let amount := calldataload(100)
// Calculate number of bytes in `amounts` contents // Calculate number of bytes in `amounts` contents
let amountsByteLen := mul(amountsLen, 32) let amountsByteLen := mul(amountsLen, 32)
@ -208,7 +208,7 @@ contract MultiAssetProxy is
let amountsElement := calldataload(add(amountsContentsStart, i)) let amountsElement := calldataload(add(amountsContentsStart, i))
let totalAmount := mul(amountsElement, amount) let totalAmount := mul(amountsElement, amount)
// Revert if `amount` != 0 and multiplication resulted in an overflow // Revert if `amount` != 0 and multiplication resulted in an overflow
if iszero(or( if iszero(or(
iszero(amount), iszero(amount),
eq(div(totalAmount, amount), amountsElement) eq(div(totalAmount, amount), amountsElement)
@ -228,7 +228,7 @@ contract MultiAssetProxy is
let nestedAssetDataElementOffset := calldataload(add(nestedAssetDataContentsStart, i)) let nestedAssetDataElementOffset := calldataload(add(nestedAssetDataContentsStart, i))
// In order to find the start of the `nestedAssetData[i]` contents, we must add: // In order to find the start of the `nestedAssetData[i]` contents, we must add:
// assetDataOffset // assetDataOffset
// + 32 (assetData len) // + 32 (assetData len)
// + 4 (assetProxyId) // + 4 (assetProxyId)
// + nestedAssetDataOffset // + nestedAssetDataOffset
@ -274,7 +274,7 @@ contract MultiAssetProxy is
mstore(164, assetProxies_slot) mstore(164, assetProxies_slot)
assetProxy := sload(keccak256(132, 64)) assetProxy := sload(keccak256(132, 64))
} }
// Revert if AssetProxy with given id does not exist // Revert if AssetProxy with given id does not exist
if iszero(assetProxy) { if iszero(assetProxy) {
// Revert with `Error("ASSET_PROXY_DOES_NOT_EXIST")` // Revert with `Error("ASSET_PROXY_DOES_NOT_EXIST")`
@ -284,7 +284,7 @@ contract MultiAssetProxy is
mstore(96, 0) mstore(96, 0)
revert(0, 100) revert(0, 100)
} }
// Copy `nestedAssetData[i]` from calldata to memory // Copy `nestedAssetData[i]` from calldata to memory
calldatacopy( calldatacopy(
132, // memory slot after `amounts[i]` 132, // memory slot after `amounts[i]`
@ -298,7 +298,7 @@ contract MultiAssetProxy is
assetProxy, // call address of asset proxy assetProxy, // call address of asset proxy
0, // don't send any ETH 0, // don't send any ETH
0, // pointer to start of input 0, // pointer to start of input
add(164, nestedAssetDataElementLen), // length of input add(164, nestedAssetDataElementLen), // length of input
0, // write output over memory that won't be reused 0, // write output over memory that won't be reused
0 // don't copy output to memory 0 // don't copy output to memory
) )

View File

@ -18,7 +18,7 @@
pragma solidity ^0.5.9; pragma solidity ^0.5.9;
import "../../archive/interfaces/IOwnable.sol"; import "@0x/contracts-utils/contracts/src/interfaces/IOwnable.sol";
contract IAuthorizable is contract IAuthorizable is