From 00f3381f7c0819c5053672de495bbb81b9d56858 Mon Sep 17 00:00:00 2001 From: qd-qd Date: Thu, 18 Apr 2024 17:47:33 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20introduce=20account=20v2=20draft=20?= =?UTF-8?q?code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/v2/Account/SmartAccount.sol | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/v2/Account/SmartAccount.sol diff --git a/src/v2/Account/SmartAccount.sol b/src/v2/Account/SmartAccount.sol new file mode 100644 index 0000000..0af12c3 --- /dev/null +++ b/src/v2/Account/SmartAccount.sol @@ -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); + } +}