-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db6789c
commit 0bf7d0d
Showing
3 changed files
with
61 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.18; | ||
|
||
import {IWalletProxy} from './interfaces/IWalletProxy.sol'; | ||
import {Implementation} from '../modules/commons/Implementation.sol'; | ||
|
||
contract WalletProxyHook is IWalletProxy, Implementation { | ||
/// @inheritdoc IWalletProxy | ||
function PROXY_getImplementation() public view returns (address) { | ||
return _getImplementation(); | ||
} | ||
} |
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,12 @@ | ||
// Copyright Immutable Pty Ltd 2018 - 2023 | ||
// SPDX-License-Identifier: Apache 2.0 | ||
// https://github.com/immutable/contracts/blob/a04f7ecb8a79ad8f1b67f73f770e0545deb6cba2/contracts/allowlist/IWalletProxy.sol | ||
pragma solidity 0.8.18; | ||
|
||
// Interface to retrieve the implemention stored inside the Proxy contract | ||
/// Interface for Passport Wallet's proxy contract. | ||
interface IWalletProxy { | ||
// Returns the current implementation address used by the proxy contract | ||
// solhint-disable-next-line func-name-mixedcase | ||
function PROXY_getImplementation() external view returns (address); | ||
} |
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,37 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.18; | ||
|
||
import 'contracts/hooks/WalletProxyHook.sol'; | ||
import 'contracts/hooks/interfaces/IWalletProxy.sol'; | ||
import 'contracts/modules/commons/ModuleHooks.sol'; | ||
import 'contracts/Factory.sol'; | ||
|
||
import 'foundry_test/base/AdvTest.sol'; | ||
|
||
contract WalletProxyHookTest is AdvTest { | ||
ModuleHooks private template; | ||
ModuleHooks private walletMod; | ||
WalletProxyHook private wallet; | ||
|
||
function setUp() external { | ||
Factory factory = new Factory(); | ||
template = new ModuleHooks(); | ||
walletMod = ModuleHooks(payable(factory.deploy(address(template), bytes32(0)))); | ||
WalletProxyHook hook = new WalletProxyHook(); | ||
|
||
// Add hook | ||
vm.prank(address(walletMod)); | ||
walletMod.addHook(IWalletProxy.PROXY_getImplementation.selector, address(hook)); | ||
|
||
wallet = WalletProxyHook(address(walletMod)); | ||
vm.label(address(wallet), 'wallet'); | ||
} | ||
|
||
// | ||
// Get Implementation | ||
// | ||
|
||
function test_PROXY_getImplementation() external { | ||
assertEq(wallet.PROXY_getImplementation(), address(template)); | ||
} | ||
} |