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

Add WalletProxyHook #191

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
}
Loading