@1inch/solidity-utils 1.2.9 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,14 +18,24 @@ library AddressArray {
18
18
 
19
19
  function get(Data storage self) internal view returns(address[] memory arr) {
20
20
  uint256 lengthAndFirst = self._raw[0];
21
+ arr = new address[](lengthAndFirst >> 160);
22
+ _get(self, arr, lengthAndFirst);
23
+ }
24
+
25
+ function get(Data storage self, address[] memory output) internal view returns(address[] memory) {
26
+ return _get(self, output, self._raw[0]);
27
+ }
28
+
29
+ function _get(Data storage self, address[] memory output, uint256 lengthAndFirst) private view returns(address[] memory) {
21
30
  uint256 len = lengthAndFirst >> 160;
22
- arr = new address[](len);
31
+ require(len <= output.length, "AddressArray: too small output");
23
32
  if (len > 0) {
24
- arr[0] = address(uint160(lengthAndFirst));
33
+ output[0] = address(uint160(lengthAndFirst));
25
34
  for (uint i = 1; i < len; i++) {
26
- arr[i] = address(uint160(self._raw[i]));
35
+ output[i] = address(uint160(self._raw[i]));
27
36
  }
28
37
  }
38
+ return output;
29
39
  }
30
40
 
31
41
  function push(Data storage self, address account) internal returns(uint256) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1inch/solidity-utils",
3
- "version": "1.2.9",
3
+ "version": "1.3.0",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",