Skip to content

Commit

Permalink
Bumping solc and removing safemath
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfornax committed Aug 21, 2024
1 parent 1c8cede commit 3830509
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions contracts/contract/util/AddressLinkedQueueStorage.sol
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
pragma solidity 0.7.6;
pragma solidity 0.8.18;

// SPDX-License-Identifier: GPL-3.0-only

import "@openzeppelin/contracts/math/SafeMath.sol";

import "../RocketBase.sol";
import "../../interface/util/AddressLinkedQueueStorageInterface.sol";

import "@openzeppelin/contracts/math/SafeMath.sol";

// Address linked queue storage helper for RocketStorage data (linked list implementation)
contract AddressLinkedQueueStorage is RocketBase, AddressLinkedQueueStorageInterface {

// Libs
using SafeMath for uint256;

// Construct
constructor(RocketStorageInterface _rocketStorageAddress) RocketBase(_rocketStorageAddress) {
version = 1;
Expand All @@ -27,7 +20,7 @@ contract AddressLinkedQueueStorage is RocketBase, AddressLinkedQueueStorageInter

// The item in a queue by index
function getItem(bytes32 _key, uint _index) override external view returns (address) {
uint index = getUint(keccak256(abi.encodePacked(_key, ".start"))).add(_index);
uint index = getUint(keccak256(abi.encodePacked(_key, ".start"))) + _index;
return getAddress(keccak256(abi.encodePacked(_key, ".item", index)));
}

Expand Down Expand Up @@ -69,7 +62,7 @@ contract AddressLinkedQueueStorage is RocketBase, AddressLinkedQueueStorageInter
// onlyLatestContract("addressLinkedListStorage", address(this)) onlyLatestNetworkContract {
require(getUint(keccak256(abi.encodePacked(_key, ".index", _value))) == 0, "Item already exists in queue");
uint endIndex = getUint(keccak256(abi.encodePacked(_key, ".end")));
uint newIndex = endIndex.add(1);
uint newIndex = endIndex + 1;

if (endIndex > 0) {
setUint(keccak256(abi.encodePacked(_key, ".next", endIndex)), newIndex);
Expand All @@ -83,7 +76,7 @@ contract AddressLinkedQueueStorage is RocketBase, AddressLinkedQueueStorageInter
setUint(keccak256(abi.encodePacked(_key, ".end")), newIndex);

// Update the length of the queue
setUint(keccak256(abi.encodePacked(_key, ".length")), getLength(_key).add(1));
setUint(keccak256(abi.encodePacked(_key, ".length")), getLength(_key) + 1);
}

// Remove an item from the start of a queue and return it
Expand All @@ -104,7 +97,7 @@ contract AddressLinkedQueueStorage is RocketBase, AddressLinkedQueueStorageInter
}

// Update the length of the queue
setUint(keccak256(abi.encodePacked(_key, ".length")), getLength(_key).sub(1));
setUint(keccak256(abi.encodePacked(_key, ".length")), getLength(_key) - 1);

return item;
}
Expand Down Expand Up @@ -139,7 +132,7 @@ contract AddressLinkedQueueStorage is RocketBase, AddressLinkedQueueStorageInter
setUint(keccak256(abi.encodePacked(_key, ".prev", index)), 0);

// Update the length of the queue
setUint(keccak256(abi.encodePacked(_key, ".length")), getLength(_key).sub(1));
setUint(keccak256(abi.encodePacked(_key, ".length")), getLength(_key) - 1);
}

}

0 comments on commit 3830509

Please sign in to comment.