-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix import paths in Foundry tests at root
- Loading branch information
Showing
4 changed files
with
147 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
contracts/Mocks/KeyManager/KeyManagerInternalsTester.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.4; | ||
|
||
// libraries | ||
import {LSP6Utils} from "lsp6/contracts/LSP6Utils.sol"; | ||
|
||
// modules | ||
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol"; | ||
import {LSP6KeyManager} from "lsp6/contracts/LSP6KeyManager.sol"; | ||
|
||
/** | ||
* Helper contract to test internal functions of the KeyManager | ||
*/ | ||
contract KeyManagerInternalTester is LSP6KeyManager { | ||
using LSP6Utils for *; | ||
|
||
constructor(address _account) LSP6KeyManager(_account) {} | ||
|
||
function getPermissionsFor(address _address) public view returns (bytes32) { | ||
return ERC725Y(_target).getPermissionsFor(_address); | ||
} | ||
|
||
function getAllowedCallsFor( | ||
address _address | ||
) public view returns (bytes memory) { | ||
return ERC725Y(_target).getAllowedCallsFor(_address); | ||
} | ||
|
||
function getAllowedERC725YDataKeysFor( | ||
address _address | ||
) public view returns (bytes memory) { | ||
return ERC725Y(_target).getAllowedERC725YDataKeysFor(_address); | ||
} | ||
|
||
function verifyAllowedCall( | ||
address controller, | ||
uint256 operationType, | ||
address to, | ||
uint256 value, | ||
bytes memory data | ||
) public view { | ||
super._verifyAllowedCall( | ||
_target, | ||
controller, | ||
operationType, | ||
to, | ||
value, | ||
data | ||
); | ||
} | ||
|
||
function isCompactBytesArrayOfAllowedCalls( | ||
bytes memory allowedCallsCompacted | ||
) public pure returns (bool) { | ||
return allowedCallsCompacted.isCompactBytesArrayOfAllowedCalls(); | ||
} | ||
|
||
function isCompactBytesArrayOfAllowedERC725YDataKeys( | ||
bytes memory allowedERC725YDataKeysCompacted | ||
) public pure returns (bool) { | ||
return | ||
allowedERC725YDataKeysCompacted | ||
.isCompactBytesArrayOfAllowedERC725YDataKeys(); | ||
} | ||
|
||
function verifyCanSetData( | ||
address controller, | ||
bytes32 permissions, | ||
bytes32[] memory inputDataKeys, | ||
bytes[] memory inputDataValues | ||
) public view { | ||
super._verifyCanSetData( | ||
_target, | ||
controller, | ||
permissions, | ||
inputDataKeys, | ||
inputDataValues | ||
); | ||
} | ||
|
||
function verifyAllowedERC725YSingleKey( | ||
address from, | ||
bytes32 inputKey, | ||
bytes memory allowedERC725YDataKeysFor | ||
) public pure { | ||
super._verifyAllowedERC725YSingleKey( | ||
from, | ||
inputKey, | ||
allowedERC725YDataKeysFor | ||
); | ||
} | ||
|
||
function verifyAllowedERC725YDataKeys( | ||
address from, | ||
bytes32[] memory inputKeys, | ||
bytes memory allowedERC725YDataKeysCompacted, | ||
bool[] memory validatedInputKeys, | ||
uint256 allowedDataKeysFound | ||
) public pure { | ||
super._verifyAllowedERC725YDataKeys( | ||
from, | ||
inputKeys, | ||
allowedERC725YDataKeysCompacted, | ||
validatedInputKeys, | ||
allowedDataKeysFound | ||
); | ||
} | ||
|
||
function hasPermission( | ||
bytes32 _addressPermission, | ||
bytes32 _permissions | ||
) public pure returns (bool) { | ||
return _addressPermission.hasPermission(_permissions); | ||
} | ||
|
||
function verifyPermissions(address from, bytes calldata payload) public { | ||
super._verifyPermissions(_target, from, false, payload); | ||
|
||
// This event is emitted just for a sake of not marking this function as `view`, | ||
// as Hardhat has a bug that does not catch error that occured from failed `abi.decode` | ||
// inside view functions. | ||
// See these issues in the Github repository of Hardhat: | ||
// - https://github.com/NomicFoundation/hardhat/issues/3084 | ||
// - https://github.com/NomicFoundation/hardhat/issues/3475 | ||
emit PermissionsVerified(from, 0, bytes4(payload)); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.