@@ -35,9 +35,6 @@ contract AccountConfiguration {
3535 // INITIALIZATION
3636 ////////
3737
38- /// @notice Designed for 7702 accounts to initialize on first use
39- function initializeAccount () external {}
40-
4138 function createAccount (
4239 Owner[] calldata initialOwners ,
4340 uint256 nonce ,
@@ -82,21 +79,25 @@ contract AccountConfiguration {
8279 }
8380
8481 function removeOwner (bytes32 ownerId ) external {
85- require (isOwner (msg .sender , ownerId));
86- delete verifiers[ownerId][msg .sender ];
87- emit OwnerRemoved (msg .sender , ownerId);
82+ _removeOwner (msg .sender , ownerId);
8883 }
8984
90- /// @notice Apply signed, replayable owner changes
91- function applyOwnerChanges (address account , uint64 startSequence , OwnerChange[] calldata ownerChanges ) external {
92- // // validate signature
93- // if (startSequence != ownerChangeSequence[account]) revert InvalidOwnerChangeSequence(startSequence, ownerChangeSequence[account]);
94- // for (uint256 i; i < ownerChanges.length; i++) {
95- // if (ownerChangeSequence[account] != ownerChanges[i].sequence) revert InvalidOwnerChange(ownerChanges[i]);
96- // ownerChangeSequence[account]++;
97- // // update account owner configuration
98- // }
99- // emit (account, ownerChanges);
85+ /// @notice Apply replayable owner changes
86+ function applyOwnerChanges (
87+ address account ,
88+ OwnerChange[] calldata ownerChanges ,
89+ bytes32 ownerId ,
90+ bytes calldata verifyData
91+ ) external {
92+ bytes32 digest = keccak256 (abi.encode (account, ownerChanges, ownerChangeSequence[account]++ ));
93+ require (IVerifier (verifiers[ownerId][account]).verify (account, ownerId, digest, verifyData));
94+ for (uint256 i; i < ownerChanges.length ; i++ ) {
95+ if (ownerChanges[i].add) {
96+ _addOwner (account, ownerChanges[i].owner);
97+ } else {
98+ _removeOwner (account, ownerChanges[i].owner.id);
99+ }
100+ }
100101 }
101102
102103 ////////
@@ -147,7 +148,7 @@ contract AccountConfiguration {
147148 }
148149
149150 ////////
150- // INTERNAL FUNCTIONS
151+ // INTERNALS
151152 ////////
152153
153154 function _addOwner (address account , Owner calldata owner ) internal {
@@ -156,4 +157,10 @@ contract AccountConfiguration {
156157 verifiers[owner.id][account] = owner.verifier;
157158 emit OwnerAdded (account, owner.id, owner.verifier);
158159 }
160+
161+ function _removeOwner (address account , bytes32 ownerId ) internal {
162+ require (isOwner (account, ownerId));
163+ delete verifiers[ownerId][account];
164+ emit OwnerRemoved (account, ownerId);
165+ }
159166}
0 commit comments