feat: add account -> owner mapping in ICA router (#3447)

### Description

- added accountOwner mapping to the ICA router for easier tracking of
remote owners for the transaction type inference by the AppGovernor

### Drive-by changes

none

### Related issues

none

### Backward compatibility

yes

### Testing

unit
pull/3466/head
Kunal Arora 8 months ago committed by GitHub
parent 5514ab1deb
commit 59e89afc5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      solidity/contracts/middleware/InterchainAccountRouter.sol
  2. 19
      solidity/test/InterchainAccountRouter.t.sol

@ -38,6 +38,11 @@ contract InterchainAccountRouter is Router {
using TypeCasts for address;
using TypeCasts for bytes32;
struct AccountOwner {
uint32 origin;
bytes32 owner; // remote owner
}
// ============ Constants ============
address internal implementation;
@ -45,6 +50,8 @@ contract InterchainAccountRouter is Router {
// ============ Public Storage ============
mapping(uint32 => bytes32) public isms;
// reverse lookup from the ICA account to the remote owner
mapping(address => AccountOwner) public accountOwners;
// ============ Upgrade Gap ============
@ -394,6 +401,7 @@ contract InterchainAccountRouter is Router {
if (!Address.isContract(_account)) {
bytes memory _bytecode = MinimalProxy.bytecode(implementation);
_account = payable(Create2.deploy(0, _salt, _bytecode));
accountOwners[_account] = AccountOwner(_origin, _owner);
emit InterchainAccountCreated(_origin, _owner, _ism, _account);
}
return OwnableMulticall(_account);

@ -320,6 +320,25 @@ contract InterchainAccountRouterTest is Test {
assertEq(address(igp).balance, expectedGasPayment);
}
function testFuzz_getDeployedInterchainAccount_checkAccountOwners(
address owner
) public {
// act
ica = destinationRouter.getDeployedInterchainAccount(
origin,
owner,
address(originRouter),
address(environment.isms(destination))
);
(uint32 domain, bytes32 ownerBytes) = destinationRouter.accountOwners(
address(ica)
);
// assert
assertEq(domain, origin);
assertEq(ownerBytes, owner.addressToBytes32());
}
function testFuzz_singleCallRemoteWithDefault(bytes32 data) public {
// arrange
originRouter.enrollRemoteRouterAndIsm(

Loading…
Cancel
Save