• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SetProtocol / set-protocol-contracts / 5673

pending completion
5673

Pull #468

circleci

Alexander Soong
Remove require string message from Admin
Pull Request #468: Add checks to admin functions for adding factories, modules, and pric…

33 of 322 branches covered (10.25%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 1 file covered. (100.0%)

117 of 1003 relevant lines covered (11.67%)

2.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/contracts/core/lib/ExchangeHeaderLibrary.sol
1
/*
2
    Copyright 2018 Set Labs Inc.
3

4
    Licensed under the Apache License, Version 2.0 (the "License");
5
    you may not use this file except in compliance with the License.
6
    You may obtain a copy of the License at
7

8
    http://www.apache.org/licenses/LICENSE-2.0
9

10
    Unless required by applicable law or agreed to in writing, software
11
    distributed under the License is distributed on an "AS IS" BASIS,
12
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
    See the License for the specific language governing permissions and
14
    limitations under the License.
15
*/
16

17
pragma solidity 0.5.7;
18
pragma experimental "ABIEncoderV2";
19

20
import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";
21

22
import { LibBytes } from "../../external/0x/LibBytes.sol";
23

24

25
/**
26
 * @title ExchangeHeaderLibrary
27
 * @author Set Protocol
28
 *
29
 * This library contains functions and structs to assist with parsing exchange orders data
30
 */
31
library ExchangeHeaderLibrary {
32
    using LibBytes for bytes;
33
    using SafeMath for uint256;
34

35
    // ============ Structs ============
36

37
    struct ExchangeHeader {
38
        uint8 exchange;
39
        uint8 orderCount;
40
        uint256 orderDataBytesLength;
41
    }
42

43
    function EXCHANGE_HEADER_LENGTH()
44
        internal
45
        pure
46
        returns (uint256)
47
    {
48
        return uint256(96);
×
49
    }
50

51
    // ============ Internal Functions ============
52

53
    /**
54
     * Function to convert bytes into ExchangeHeader
55
     *
56
     * @param _orderData      Bytes representing the order body information
57
     * @return ExchangeHeader  Struct containing data for a batch of exchange orders
58
     */
59
    function parseExchangeHeader(
60
        bytes memory _orderData,
61
        uint256 _offset
62
    )
63
        internal
64
        pure
65
        returns (ExchangeHeader memory)
66
    {
67
        ExchangeHeader memory header;
×
68

69
        uint256 headerDataStart = _orderData.contentAddress().add(_offset);
×
70

71
        assembly {
×
72
            mstore(header,          mload(headerDataStart))            // exchange
73
            mstore(add(header, 32), mload(add(headerDataStart, 32)))   // orderCount
74
            mstore(add(header, 64), mload(add(headerDataStart, 64)))   // orderDataBytesLength
75
        }
76

77
        return header;
×
78
    }
79

80
    /**
81
     * Function to extract the exchange body from the order data
82
     *
83
     * @param _orderData                Bytes representing the exchange order information
84
     * @param _scannedBytes             Number representing the number of bytes already processed
85
     * @param _exchangeDataLength       Length of the exchange data from the exchange data header
86
     * @return ExchangeBody  Bytes representing the exchange body
87
     */
88
    function sliceBodyData(
89
        bytes memory _orderData,
90
        uint256 _scannedBytes,
91
        uint256 _exchangeDataLength
92
    )
93
        internal
94
        pure
95
        returns (bytes memory)
96
    {
97
        bytes memory bodyData = LibBytes.slice(
×
98
            _orderData,
99
            _scannedBytes.add(EXCHANGE_HEADER_LENGTH()),
100
            _scannedBytes.add(_exchangeDataLength)
101
        );
102

103
        return bodyData;
×
104
    }
105
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc