Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix Foundry test failing and @erc725/smart-contracts dependency clash between package #982

Merged
5 changes: 5 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ solc_version = "0.8.17"
runs = 10_000
max_test_rejects = 200_000

[profile.lsp0]
src = 'packages/lsp0-contracts/contracts'
test = 'packages/lsp0-contracts/foundry'
out = 'packages/lsp0-contracts/contracts/foundry_artifacts'

[profile.lsp2]
src = 'packages/lsp2-contracts/contracts'
test = 'packages/lsp2-contracts/foundry'
Expand Down
2,704 changes: 1,434 additions & 1,270 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"test:reentrancy": "hardhat test --no-compile packages/lsp-smart-contracts/tests/Reentrancy/Reentrancy.test.ts",
"test:reentrancyinit": "hardhat test --no-compile packages/lsp-smart-contracts/tests/Reentrancy/ReentrancyInit.test.ts"
},
"dependencies": {
"@erc725/smart-contracts-v8": "npm:@erc725/[email protected]"
},
"devDependencies": {
"@b00ste/hardhat-dodoc": "^0.3.16",
"@erc725/erc725.js": "0.23.0",
Expand Down
44 changes: 22 additions & 22 deletions packages/lsp-smart-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,27 @@
"test:benchmark": "hardhat test --no-compile tests/Benchmark.test.ts"
},
"dependencies": {
"@lukso/lsp0-contracts": "~0.15.0",
"@lukso/lsp1-contracts": "~0.15.0",
"@lukso/lsp10-contracts": "~0.15.0",
"@lukso/lsp12-contracts": "~0.15.0",
"@lukso/lsp14-contracts": "~0.15.0",
"@lukso/lsp16-contracts": "~0.15.0",
"@lukso/lsp17-contracts": "~0.15.0",
"@lukso/lsp17contractextension-contracts": "~0.15.0",
"@lukso/lsp1delegate-contracts": "~0.15.0",
"@lukso/lsp2-contracts": "~0.15.0",
"@lukso/lsp20-contracts": "~0.15.0",
"@lukso/lsp23-contracts": "~0.15.0",
"@lukso/lsp25-contracts": "~0.15.0",
"@lukso/lsp26-contracts": "~0.15.0",
"@lukso/lsp3-contracts": "~0.15.0",
"@lukso/lsp4-contracts": "~0.15.0",
"@lukso/lsp5-contracts": "~0.15.0",
"@lukso/lsp6-contracts": "~0.15.0",
"@lukso/lsp7-contracts": "~0.15.0",
"@lukso/lsp8-contracts": "~0.15.0",
"@lukso/lsp9-contracts": "~0.15.0",
"@lukso/universalprofile-contracts": "~0.15.0"
"@lukso/lsp0-contracts": "*",
"@lukso/lsp1-contracts": "*",
"@lukso/lsp10-contracts": "*",
"@lukso/lsp12-contracts": "*",
"@lukso/lsp14-contracts": "*",
"@lukso/lsp16-contracts": "*",
"@lukso/lsp17-contracts": "*",
"@lukso/lsp17contractextension-contracts": "*",
"@lukso/lsp1delegate-contracts": "*",
"@lukso/lsp2-contracts": "*",
"@lukso/lsp20-contracts": "*",
"@lukso/lsp23-contracts": "*",
"@lukso/lsp25-contracts": "*",
"@lukso/lsp26-contracts": "*",
"@lukso/lsp3-contracts": "*",
"@lukso/lsp4-contracts": "*",
"@lukso/lsp5-contracts": "*",
"@lukso/lsp6-contracts": "*",
"@lukso/lsp7-contracts": "*",
"@lukso/lsp8-contracts": "*",
"@lukso/lsp9-contracts": "*",
"@lukso/universalprofile-contracts": "*"
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion packages/lsp0-contracts/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ERC165 Interface ID
// ----------
export const INTERFACE_ID_LSP0ERC725Account = '0x24871b3d';
export const INTERFACE_ID_LSP0 = '0x24871b3d';

// ERC1271
// ----------
Expand Down
13 changes: 7 additions & 6 deletions packages/lsp0-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@
"clean": "hardhat clean && rm -Rf dist/",
"format": "prettier --write .",
"lint": "eslint . --ext .ts,.js",
"lint:solidity": "solhint 'contracts/**/*.sol' && prettier --check 'contracts/**/*.sol'"
"lint:solidity": "solhint 'contracts/**/*.sol' && prettier --check 'contracts/**/*.sol'",
"test:foundry": "FOUNDRY_PROFILE=lsp0 forge test -vvv"
},
"dependencies": {
"@erc725/smart-contracts": "^7.0.0",
"@openzeppelin/contracts": "^4.9.6",
"@lukso/lsp1-contracts": "~0.15.0",
"@lukso/lsp2-contracts": "~0.15.0",
"@lukso/lsp14-contracts": "~0.15.0",
"@lukso/lsp17contractextension-contracts": "~0.15.0",
"@lukso/lsp20-contracts": "~0.15.0"
"@lukso/lsp1-contracts": "*",
"@lukso/lsp2-contracts": "*",
"@lukso/lsp14-contracts": "*",
"@lukso/lsp17contractextension-contracts": "*",
"@lukso/lsp20-contracts": "*"
}
}
2 changes: 1 addition & 1 deletion packages/lsp10-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
},
"dependencies": {
"@erc725/smart-contracts": "^7.0.0",
"@lukso/lsp2-contracts": "~0.15.0"
"@lukso/lsp2-contracts": "*"
}
}
2 changes: 1 addition & 1 deletion packages/lsp11-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"dependencies": {
"@erc725/smart-contracts": "^7.0.0",
"@lukso/lsp25-contracts": "~0.15.0",
"@lukso/lsp25-contracts": "*",
"@openzeppelin/contracts": "^4.9.3"
}
}
6 changes: 3 additions & 3 deletions packages/lsp17-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"@erc725/smart-contracts": "^7.0.0",
"@openzeppelin/contracts": "^4.9.6",
"@account-abstraction/contracts": "^0.6.0",
"@lukso/lsp14-contracts": "~0.15.0",
"@lukso/lsp17contractextension-contracts": "~0.15.0",
"@lukso/lsp20-contracts": "~0.15.0"
"@lukso/lsp14-contracts": "*",
"@lukso/lsp17contractextension-contracts": "*",
"@lukso/lsp20-contracts": "*"
}
}
2 changes: 1 addition & 1 deletion packages/lsp17contractextension-contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lukso/lsp17contractextension-contracts",
"version": "0.15.0-rc.0",
"version": "0.16.0",
"description": "Package for the LSP17 Contract Extension standard",
"license": "Apache-2.0",
"author": "",
Expand Down
12 changes: 6 additions & 6 deletions packages/lsp1delegate-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
"dependencies": {
"@erc725/smart-contracts": "^7.0.0",
"@openzeppelin/contracts": "^4.9.6",
"@lukso/lsp1-contracts": "~0.15.0",
"@lukso/lsp5-contracts": "~0.15.0",
"@lukso/lsp7-contracts": "~0.15.0",
"@lukso/lsp8-contracts": "~0.15.0",
"@lukso/lsp9-contracts": "~0.15.0",
"@lukso/lsp10-contracts": "~0.15.0"
"@lukso/lsp1-contracts": "*",
"@lukso/lsp5-contracts": "*",
"@lukso/lsp7-contracts": "*",
"@lukso/lsp8-contracts": "*",
"@lukso/lsp9-contracts": "*",
"@lukso/lsp10-contracts": "*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.4;

// modules
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
import {ERC725Y} from "@erc725/smart-contracts-v8/contracts/ERC725Y.sol";

// constants
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.4;
// modules
import {
ERC725YInitAbstract
} from "@erc725/smart-contracts/contracts/ERC725YInitAbstract.sol";
} from "@erc725/smart-contracts-v8/contracts/ERC725YInitAbstract.sol";

// constants
import {
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/lsp4-contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lukso/lsp4-contracts",
"version": "0.15.0-rc.0",
"version": "0.16.0",
"description": "Package for the LSP4 Digital Asset Metadata standard",
"license": "Apache-2.0",
"author": "",
Expand Down Expand Up @@ -46,7 +46,7 @@
"lint:solidity": "solhint 'contracts/**/*.sol' && prettier --check 'contracts/**/*.sol'"
},
"dependencies": {
"@erc725/smart-contracts": "^8.0.0",
"@erc725/smart-contracts-v8": "npm:@erc725/smart-contracts@8.0.0",
"@lukso/lsp2-contracts": "*"
}
}
2 changes: 1 addition & 1 deletion packages/lsp6-contracts/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LSP2ArrayKey } from '@lukso/lsp2-contracts';

export const INTERFACE_ID_LSP6KEYMANAGER = '0x23f34c62';
export const INTERFACE_ID_LSP6 = '0x23f34c62';

/**
* @dev values returned by the `isValidSignature` function of the ERC1271 standard.
Expand Down
100 changes: 100 additions & 0 deletions packages/lsp6-contracts/foundry/LSP6Permissions.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
pragma solidity ^0.8.13;

// Testing utilities
import {Test} from "forge-std/Test.sol";
import {LSP2Utils} from "@lukso/lsp2-contracts/contracts/LSP2Utils.sol";
import {LSP6Utils} from "@lukso/lsp6-contracts/contracts/LSP6Utils.sol";

// Test setup
import {
IERC725Y
} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
import {ERC725} from "@erc725/smart-contracts/contracts/ERC725.sol";
import {
LSP6KeyManager
} from "@lukso/lsp6-contracts/contracts/LSP6KeyManager.sol";

// errors
import {NotAuthorised} from "@lukso/lsp6-contracts/contracts/LSP6Errors.sol";

// constants
import {
OPERATION_4_DELEGATECALL
} from "@erc725/smart-contracts/contracts/constants.sol";
import {
_PERMISSION_DEPLOY,
_LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX
} from "@lukso/lsp6-contracts/contracts/LSP6Constants.sol";

contract LSP6Permissions is Test {
ERC725 public mainAccount;
LSP6KeyManager public keyManagerForAccount;
address public mainAccountController;
address public combineController;

function setUp() public {
mainAccountController = vm.addr(1);
vm.label(mainAccountController, "mainAccountController");
combineController = vm.addr(10);
vm.label(combineController, "combineController");
mainAccount = new ERC725(mainAccountController);

// deploy LSP6KeyManager and link it to this account
keyManagerForAccount = new LSP6KeyManager(address(mainAccount));
vm.prank(mainAccountController);
mainAccount.transferOwnership(address(keyManagerForAccount));
}

function testFail_evenWhenPermissionsGivenTwice() public {
bytes32[] memory ownerPermissions = new bytes32[](3);
ownerPermissions[0] = _PERMISSION_DEPLOY;
ownerPermissions[1] = _PERMISSION_DEPLOY;
_givePermissionsToController(
mainAccount,
combineController,
address(keyManagerForAccount),
ownerPermissions
);
bytes32 controllerPermissionDataKey = LSP2Utils
.generateMappingWithGroupingKey(
_LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX,
bytes20(combineController)
);
bytes32 controllerPermissions = bytes32(
mainAccount.getData(controllerPermissionDataKey)
);

// CHECK that granting permission `DEPLOY` twice should not result in granting permission `SUPER_SETDATA`
// - _PERMISSION_DEPLOY = 0x0000000000000000000000000000000000000000000000000000000000010000;
// - _PERMISSION_SUPER_SETDATA = 0x0000000000000000000000000000000000000000000000000000000000020000;
assert(controllerPermissions == _PERMISSION_DEPLOY);

vm.prank(combineController);

// This should revert as the controller does not have the permission to setData but is only authorised to deploy contracts
mainAccount.setData(
bytes32(
0xcafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe
),
hex"deadbeef"
);
}

function _givePermissionsToController(
IERC725Y account,
address controller,
address permissionGiver,
bytes32[] memory permissions
) internal {
bytes32 dataKey = LSP2Utils.generateMappingWithGroupingKey(
_LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX,
bytes20(controller)
);

bytes32 combinedPermissions = LSP6Utils.combinePermissions(permissions);
bytes memory dataValue = abi.encodePacked(combinedPermissions);
vm.prank(permissionGiver);

account.setData(dataKey, dataValue);
}
}
Binary file not shown.
6 changes: 3 additions & 3 deletions packages/lsp7-contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lukso/lsp7-contracts",
"version": "0.15.0-rc.0",
"version": "0.16.0",
"description": "Package for the LSP7 Digital Asset standard",
"license": "Apache-2.0",
"author": "",
Expand Down Expand Up @@ -48,8 +48,8 @@
"dependencies": {
"@erc725/smart-contracts": "^8.0.0",
"@openzeppelin/contracts": "^4.9.6",
"@lukso/lsp1-contracts": "~0.15.0",
"@lukso/lsp2-contracts": "~0.15.0",
"@lukso/lsp1-contracts": "*",
"@lukso/lsp2-contracts": "*",
"@lukso/lsp4-contracts": "*",
"@lukso/lsp17contractextension-contracts": "*"
}
Expand Down
Binary file not shown.
Loading
Loading