Skip to content

Commit c52c4ac

Browse files
committed
refactor: exclude EIP-7702 EOAs from warning + track dismissal by account
1 parent 9766414 commit c52c4ac

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/components/smartContractWalletWarning.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const StyledP = styled.p`
1515
margin: 0;
1616
`;
1717

18-
const storageKey = "@kleros/dispute-resolver/alert/smart-contract-wallet-warning";
18+
const STORAGE_KEY = "@kleros/dispute-resolver/alert/smart-contract-wallet-warning";
19+
const EIP7702_PREFIX = "0xef0100";
1920

2021
export default class SmartContractWalletWarning extends React.Component {
2122
constructor(props) {
@@ -28,7 +29,7 @@ export default class SmartContractWalletWarning extends React.Component {
2829

2930
getStoredWarningState = () => {
3031
try {
31-
const storedValue = localStorage.getItem(storageKey);
32+
const storedValue = localStorage.getItem(`${STORAGE_KEY}:${this.props.activeAddress}`);
3233
if (storedValue === null) return true;
3334
return JSON.parse(storedValue);
3435
} catch {
@@ -44,6 +45,7 @@ export default class SmartContractWalletWarning extends React.Component {
4445
if (prevProps.activeAddress !== this.props.activeAddress ||
4546
prevProps.web3Provider !== this.props.web3Provider) {
4647
this.checkIfSmartWallet();
48+
this.setState({ showWarning: this.getStoredWarningState() });
4749
}
4850
}
4951

@@ -57,7 +59,11 @@ export default class SmartContractWalletWarning extends React.Component {
5759

5860
try {
5961
const code = await web3Provider.getCode(activeAddress);
60-
this.setState({ isSmartContractWallet: code !== "0x" });
62+
const formattedCode = code.toLowerCase();
63+
const isEip7702Eoa = formattedCode.startsWith(EIP7702_PREFIX);
64+
65+
//Do not show warning for EIP-7702 EOAs
66+
this.setState({ isSmartContractWallet: code !== "0x" && !isEip7702Eoa });
6167
} catch (error) {
6268
console.error("Error getting code at wallet address", error);
6369
this.setState({ isSmartContractWallet: false });
@@ -66,7 +72,7 @@ export default class SmartContractWalletWarning extends React.Component {
6672

6773
handleClose = () => {
6874
this.setState({ showWarning: false });
69-
localStorage.setItem(storageKey, false);
75+
localStorage.setItem(`${STORAGE_KEY}:${this.props.activeAddress}`, false);
7076
};
7177

7278
render() {

0 commit comments

Comments
 (0)