Skip to content

Commit

Permalink
Merge branch 'develop' into c4/QA
Browse files Browse the repository at this point in the history
  • Loading branch information
YamenMerhi committed Sep 27, 2023
2 parents 26c301d + f1686d5 commit 68907a0
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 213 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ The following audits and formal verification were conducted. All high-level issu
- Runtime Verification - Formal Verification, 2023-02-20, Final Result: [RuntimeVerification_formalVerification_2023_02_20.pdf](./audits/RuntimeVerification_formalVerification_2023_02_20.pdf)
- Trust Audit, 2023-04-13, Final Result: [Trust_audit_2023_04_13.pdf](./audits/Trust_audit_2023_04_13.pdf)
- Watchpug Audit, 2023-04-21, Final Result: [Watchpug_audit_2023_04_21.pdf](./audits/Watchpug_audit_2023_04_21.pdf)
- Code4Rena Audit Contest, 2023-06-30 to 2023-07-14, Final Result: [See Code4Rena audit report on Code4rena.com website](https://code4rena.com/reports/2023-06-lukso)

## Contributors ✨

Expand Down
3 changes: 3 additions & 0 deletions audits/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Smart Contracts Audits

In addition to the audits reports in pdf available in this page, you can find the audit report of the **Code4Rena audit contest** at the following link: [https://code4rena.com/reports/2021-05-lukso](https://code4rena.com/reports/2021-05-lukso)
8 changes: 4 additions & 4 deletions contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ abstract contract LSP0ERC725AccountCore is

if (!success) {
// Look for revert reason and bubble it up if present
if (result.length > 0) {
if (result.length != 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable no-inline-assembly
/// @solidity memory-safe-assembly
Expand Down Expand Up @@ -352,7 +352,7 @@ abstract contract LSP0ERC725AccountCore is

// If the caller is the owner perform setData directly
if (msg.sender == accountOwner) {
for (uint256 i = 0; i < dataKeys.length; ) {
for (uint256 i; i < dataKeys.length; ) {
_setData(dataKeys[i], dataValues[i]);

unchecked {
Expand All @@ -367,7 +367,7 @@ abstract contract LSP0ERC725AccountCore is
// Depending on the magicValue returned, a second call is done after setting data
bool verifyAfter = _verifyCall(accountOwner);

for (uint256 i = 0; i < dataKeys.length; ) {
for (uint256 i; i < dataKeys.length; ) {
_setData(dataKeys[i], dataValues[i]);

unchecked {
Expand Down Expand Up @@ -682,7 +682,7 @@ abstract contract LSP0ERC725AccountCore is
address _owner = owner();

// If owner is a contract
if (_owner.code.length > 0) {
if (_owner.code.length != 0) {
(bool success, bytes memory result) = _owner.staticcall(
abi.encodeWithSelector(
IERC1271.isValidSignature.selector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
) internal returns (bytes memory) {
// CHECK balance only when the Token contract is already deployed,
// not when tokens are being transferred on deployment through the `constructor`
if (notifier.code.length > 0) {
if (notifier.code.length != 0) {
// if the amount sent is 0, then do not update the keys
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
uint256 balance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
) internal returns (bytes memory) {
// CHECK balance only when the Token contract is already deployed,
// not when tokens are being transferred on deployment through the `constructor`
if (notifier.code.length > 0) {
if (notifier.code.length != 0) {
// if the amount sent is 0, then do not update the keys
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
uint256 balance
Expand Down
2 changes: 1 addition & 1 deletion contracts/LSP20CallVerification/LSP20CallVerification.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ abstract contract LSP20CallVerification {
bytes memory returnedData
) internal pure virtual {
// Look for revert reason and bubble it up if present
if (returnedData.length > 0) {
if (returnedData.length != 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable no-inline-assembly
/// @solidity memory-safe-assembly
Expand Down
3 changes: 1 addition & 2 deletions contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ abstract contract LSP25MultiChannelNonce {
address from,
uint128 channelId
) internal view virtual returns (uint256 idx) {
uint256 nonceInChannel = _nonceStore[from][channelId];
return (uint256(channelId) << 128) | nonceInChannel;
return (uint256(channelId) << 128) | _nonceStore[from][channelId];
}

/**
Expand Down
68 changes: 0 additions & 68 deletions contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -308,74 +308,6 @@ library LSP2Utils {
return true;
}

/**
* @dev Verify if `data` is an abi-encoded array of addresses (`address[]`) encoded according to the ABI specs.
*
* @param data The bytes value to verify.
*
* @return `true` if the `data` represents an abi-encoded array of addresses, `false` otherwise.
*/
function isEncodedArrayOfAddresses(
bytes memory data
) internal pure returns (bool) {
if (!isEncodedArray(data)) return false;

uint256 offset = uint256(bytes32(data));
uint256 arrayLength = data.toUint256(offset);

uint256 pointer = offset + 32;

for (uint256 ii = 0; ii < arrayLength; ) {
bytes32 key = data.toBytes32(pointer);

// check that the leading bytes are zero bytes "00"
// NB: address type is padded on the left (unlike bytes20 type that is padded on the right)
if (bytes12(key) != bytes12(0)) return false;

// increment the pointer
pointer += 32;

unchecked {
++ii;
}
}

return true;
}

/**
* @dev Verify if `data` is an abi-array of `bytes4` values (`bytes4[]`) encoded according to the ABI specs.
*
* @param data The bytes value to verify.
*
* @return `true` if the `data` represents an abi-encoded array of `bytes4`, `false` otherwise.
*/
function isBytes4EncodedArray(
bytes memory data
) internal pure returns (bool) {
if (!isEncodedArray(data)) return false;

uint256 offset = uint256(bytes32(data));
uint256 arrayLength = data.toUint256(offset);
uint256 pointer = offset + 32;

for (uint256 ii = 0; ii < arrayLength; ) {
bytes32 key = data.toBytes32(pointer);

// check that the trailing bytes are zero bytes "00"
if (uint224(uint256(key)) != 0) return false;

// increment the pointer
pointer += 32;

unchecked {
++ii;
}
}

return true;
}

/**
* @dev Verify if `data` is a valid array of value encoded as a `CompactBytesArray` according to the LSP2 `CompactBytesArray` valueType specification.
*
Expand Down
Loading

0 comments on commit 68907a0

Please sign in to comment.