Skip to content

Commit

Permalink
Add WalletProxyHook (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScreamingHawk authored Dec 20, 2024
1 parent db6789c commit 09c54e7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
12 changes: 12 additions & 0 deletions contracts/hooks/WalletProxyHook.sol
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();
}
}
12 changes: 12 additions & 0 deletions contracts/hooks/interfaces/IWalletProxy.sol
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);
}
37 changes: 37 additions & 0 deletions foundry_test/hooks/WalletProxyHook.t.sol
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));
}
}

0 comments on commit 09c54e7

Please sign in to comment.