Skip to content

Commit 611244e

Browse files
resolve cursor comments
1 parent c34e27c commit 611244e

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

delegation-toolkit/guides/erc7715/execute-on-metamask-users-behalf.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ the hood. ERC-7710 delegation is one of the core feature supported only by MetaM
111111

112112
```typescript
113113
import { getDeleGatorEnvironment } from "@metamask/delegation-toolkit";
114+
import { sepolia as chain } from "viem/chains";
114115

115116
const addresses = await walletClient.requestAddresses();
116117
const address = addresses[0];
@@ -120,17 +121,21 @@ const code = await publicClient.getCode({
120121
address,
121122
});
122123

123-
// The address to which EOA has delegated. According to EIP-7702, 0xef0100 || address
124-
// represents the delegation.
125-
//
126-
// You need to remove the first 8 characters (0xef0100) to get the delegator address.
127-
const delegatorAddress = `0x${code?.substring(8)}`;
128-
129-
const statelessDelegatorAddress = getDeleGatorEnvironment(sepolia.id).implementations.EIP7702StatelessDeleGatorImpl;
130-
131-
// If account is not upgraded to MetaMask smart account, you can
132-
// either upgrade programmatically or ask the user to switch to a smart account manually.
133-
const isAccountUpgraded = delegatorAddress.toLowerCase() === statelessDelegatorAddress.toLowerCase();
124+
if (code) {
125+
// The address to which EOA has delegated. According to EIP-7702, 0xef0100 || address
126+
// represents the delegation.
127+
//
128+
// You need to remove the first 8 characters (0xef0100) to get the delegator address.
129+
const delegatorAddress = `0x${code.substring(8)}`;
130+
131+
const statelessDelegatorAddress = getDeleGatorEnvironment(chain.id)
132+
.implementations
133+
.EIP7702StatelessDeleGatorImpl;
134+
135+
// If account is not upgraded to MetaMask smart account, you can
136+
// either upgrade programmatically or ask the user to switch to a smart account manually.
137+
const isAccountUpgraded = delegatorAddress.toLowerCase() === statelessDelegatorAddress.toLowerCase();
138+
}
134139
```
135140

136141
### 5. Request ERC-7715 permissions

gator_versioned_docs/version-0.13.0/guides/erc7715/execute-on-metamask-users-behalf.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ the hood. ERC-7710 delegation is one of the core feature supported only by MetaM
111111

112112
```typescript
113113
import { getDeleGatorEnvironment } from "@metamask/delegation-toolkit";
114+
import { sepolia as chain } from "viem/chains";
114115

115116
const addresses = await walletClient.requestAddresses();
116117
const address = addresses[0];
@@ -120,17 +121,21 @@ const code = await publicClient.getCode({
120121
address,
121122
});
122123

123-
// The address to which EOA has delegated. According to EIP-7702, 0xef0100 || address
124-
// represents the delegation.
125-
//
126-
// You need to remove the first 8 characters (0xef0100) to get the delegator address.
127-
const delegatorAddress = `0x${code?.substring(8)}`;
128-
129-
const statelessDelegatorAddress = getDeleGatorEnvironment(sepolia.id).implementations.EIP7702StatelessDeleGatorImpl;
130-
131-
// If account is not upgraded to MetaMask smart account, you can
132-
// either upgrade programmatically or ask the user to switch to a smart account manually.
133-
const isAccountUpgraded = delegatorAddress.toLowerCase() === statelessDelegatorAddress.toLowerCase();
124+
if (code) {
125+
// The address to which EOA has delegated. According to EIP-7702, 0xef0100 || address
126+
// represents the delegation.
127+
//
128+
// You need to remove the first 8 characters (0xef0100) to get the delegator address.
129+
const delegatorAddress = `0x${code.substring(8)}`;
130+
131+
const statelessDelegatorAddress = getDeleGatorEnvironment(chain.id)
132+
.implementations
133+
.EIP7702StatelessDeleGatorImpl;
134+
135+
// If account is not upgraded to MetaMask smart account, you can
136+
// either upgrade programmatically or ask the user to switch to a smart account manually.
137+
const isAccountUpgraded = delegatorAddress.toLowerCase() === statelessDelegatorAddress.toLowerCase();
138+
}
134139
```
135140

136141
### 5. Request ERC-7715 permissions

0 commit comments

Comments
 (0)