Skip to content

Commit

Permalink
feat: add account -> owner mapping in ICA router (#3447)
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
aroralanuk authored Mar 20, 2024
1 parent 5514ab1 commit 59e89af
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions solidity/contracts/middleware/InterchainAccountRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@ contract InterchainAccountRouter is Router {
using TypeCasts for address;
using TypeCasts for bytes32;

struct AccountOwner {
uint32 origin;
bytes32 owner; // remote owner
}

// ============ Constants ============

address internal implementation;
bytes32 internal bytecodeHash;

// ============ Public Storage ============
mapping(uint32 => bytes32) public isms;
// reverse lookup from the ICA account to the remote owner
mapping(address => AccountOwner) public accountOwners;

// ============ Upgrade Gap ============

Expand Down Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions solidity/test/InterchainAccountRouter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 59e89af

Please sign in to comment.