contract StorageLookupAssertion is Assertion {
Protocol public protocol;
constructor(Protocol protocol_) {
protocol = protocol_;
}
function triggers() public view override {
registerCallTrigger(this.assertionStorageLookup.selector);
}
function assertionStorageLookup() public {
// Define a whitelist of allowed owner addresses
address[] memory whitelist = new address[](2);
whitelist[0] = address(0x1);
whitelist[1] = address(0x2);
// Read owner from storage slot 0
// Complex casting is needed because load() returns bytes32
// 1. Convert bytes32 to uint256
// 2. Convert uint256 to uint160 (address size)
// 3. Cast to address type
address owner = address(uint160(uint256(ph.load(address(protocol), bytes32(uint256(0))))));
// Verify the owner is in the whitelist
for (uint256 i = 0; i < whitelist.length; i++) {
if (owner == whitelist[i]) {
return;
}
}
revert("Owner not in whitelist");
}
}