Skip to content

Commit

Permalink
✨ introduce account v2 draft code
Browse files Browse the repository at this point in the history
This draft boilerplate introduces the upgrade function that reinitializes
the contract and burns the nonce 0. The burn of the nonce 0 is required
if the entrypoint changes. There are no consequences for burning arbitrary
nonce value
  • Loading branch information
qd-qd committed Apr 18, 2024
1 parent d55272e commit 00f3381
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/v2/Account/SmartAccount.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.8.20 <0.9.0;

import { SmartAccount as SmartAccountV1 } from "src/v1/Account/SmartAccount.sol";
import { IEntryPoint } from "@eth-infinitism/interfaces/IEntryPoint.sol";

/// @custom:experimental This is just a draft of the new version of the SmartAccount contract.
/// The most important part here is the behavior of the `upgrade` function.
contract SmartAccount is SmartAccountV1 {
constructor(address entryPoint, address webAuthnVerifier) SmartAccountV1(entryPoint, webAuthnVerifier) { }

function upgrade() external virtual reinitializer(2) {
// burn the nonce 0 -- this will prevent the creation flow from being called again
IEntryPoint(entryPointAddress).incrementNonce(0);
}
}

0 comments on commit 00f3381

Please sign in to comment.