Skip to content

Commit c0c736e

Browse files
committed
fix: md lint
1 parent 9543060 commit c0c736e

File tree

3 files changed

+53
-13
lines changed

3 files changed

+53
-13
lines changed

passkey-wallet-app/DEPLOYMENT_SCRIPT.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
## Overview
44

5-
This script allows you to deploy a smart account using an EOA (Externally Owned Account) with Sepolia ETH, instead of relying on the bundler to deploy it.
5+
This script allows you to deploy a smart account using an EOA (Externally Owned Account) with Sepolia ETH,
6+
instead of relying on the bundler to deploy it.
67

78
## Why Use This?
89

910
The bundler's counterfactual deployment can fail with `AA13 initCode failed or OOG` errors. Using this script, you can:
11+
1012
- Deploy the account from an EOA that you control
1113
- Verify the deployment succeeded
1214
- Then use the account normally in the app
@@ -20,6 +22,7 @@ cp .env.example .env
2022
```
2123

2224
Edit `.env` and add your private key:
25+
2326
```
2427
DEPLOYER_PRIVATE_KEY=0x... # Your EOA private key (must have Sepolia ETH)
2528
```
@@ -29,11 +32,13 @@ DEPLOYER_PRIVATE_KEY=0x... # Your EOA private key (must have Sepolia ETH)
2932
### 2. Get Your Passkey Data
3033

3134
After creating a passkey in the app, check the browser console for:
35+
3236
- Credential ID (hex format)
3337
- Public Key X
3438
- Public Key Y
3539

3640
Example console output:
41+
3742
```
3843
Credential ID: 0xd748b11b3a22f1d0615de02b03a9225005a94ee2dcb4aff6501f9ca381736f5c
3944
Public Key X: 0x44adf115f2c6a670d535c8d2735e0c853688404ef8643b67e479fa3cd3531377
@@ -67,6 +72,7 @@ node deploy-account.js \
6772
## Output
6873

6974
Successful deployment:
75+
7076
```
7177
🚀 Deploying Smart Account...
7278
@@ -93,42 +99,52 @@ Account Address: 0x...
9399
## After Deployment
94100

95101
Once deployed, you can:
102+
96103
1. **Refresh the app** - Your account will show as deployed
97104
2. **Send transactions** - No more `AA20 account not deployed` errors
98105
3. **Use the app normally** - All features work!
99106

100107
## Troubleshooting
101108

102109
### "DEPLOYER_PRIVATE_KEY not found"
110+
103111
- Make sure you created `.env` file
104112
- Check the private key starts with `0x`
105113

106114
### "Deployer has no ETH"
115+
107116
- Fund your deployer address with Sepolia ETH
108-
- Get from: https://sepoliafaucet.com/
117+
- Get from: <https://sepoliafaucet.com/>
109118

110119
### "Account already deployed"
120+
111121
- The account is already deployed! You can use it in the app
112122
- No need to deploy again
113123

114124
### "Deployment failed"
125+
115126
- Check gas prices aren't too high
116127
- Verify the contract addresses are correct
117128
- Ensure your passkey data is correct (credential ID, public keys)
118129

119130
## Important Notes
120131

121-
1. **Origin Must Match**: The script uses `http://localhost:3000` as the origin. If you're using a different origin in the app, update line 90 in `deploy-account.js`.
132+
1. **Origin Must Match**: The script uses `http://localhost:3000` as the origin.
133+
If you're using a different origin in the app, update line 90 in `deploy-account.js`.
122134

123-
2. **One-Time Operation**: You only need to deploy the account once. After that, it exists on-chain forever (for that specific passkey).
135+
2. **One-Time Operation**: You only need to deploy the account once. After that,
136+
it exists on-chain forever (for that specific passkey).
124137

125138
3. **Gas Costs**: Deployment costs approximately 0.005-0.01 ETH on Sepolia.
126139

127-
4. **Same Passkey = Same Account**: The account address is deterministic based on your credential ID. Same passkey always generates the same account address.
140+
4. **Same Passkey = Same Account**: The account address is deterministic based on your credential ID.
141+
Same passkey always generates the same account address.
128142

129143
## Alternative: Deploy from App (Advanced)
130144

131-
If you want to avoid using this script, you can also deploy programmatically by funding the account address BEFORE deployment, then the first transaction will deploy it automatically. However, this is more complex and requires careful gas estimation.
145+
If you want to avoid using this script, you can also deploy programmatically by funding the account address BEFORE deployment,
146+
then the first transaction will deploy it automatically.
147+
However, this is more complex and requires careful gas estimation.
132148

133149
## Security Best Practices
134150

passkey-wallet-app/FIXES_APPLIED.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
## Issue: Transaction Signing Errors
44

55
### Error 1: Challenge Format Issue
6+
67
**Error Message:**
8+
79
```
810
startAuthentication() was not called correctly
911
TypeError: base64URLString.replace is not a function
@@ -13,6 +15,7 @@ TypeError: base64URLString.replace is not a function
1315
The `startAuthentication` function from `@simplewebauthn/browser` expects base64url **strings**, but we were passing arrays/bytes.
1416

1517
**Fix Applied:**
18+
1619
```javascript
1720
// Before (WRONG):
1821
const authOptions = {
@@ -39,16 +42,21 @@ const authOptions = {
3942
---
4043

4144
### Error 2: ABI Encoding Issue
45+
4246
**Error Message:**
47+
4348
```
4449
AbiFunctionNotFoundError: Function not found on ABI.
4550
Make sure you are using the correct ABI and that the function exists on it.
4651
```
4752

4853
**Root Cause:**
49-
Using `encodeFunctionData` with `parseAbiParameters` is incorrect. `encodeFunctionData` expects a full function ABI with a function name, while `parseAbiParameters` only provides parameter types.
54+
Using `encodeFunctionData` with `parseAbiParameters` is incorrect.
55+
`encodeFunctionData` expects a full function ABI with a function name,
56+
while `parseAbiParameters` only provides parameter types.
5057

5158
**Fix Applied:**
59+
5260
```javascript
5361
// Before (WRONG):
5462
return encodeFunctionData({
@@ -72,9 +80,11 @@ return encodeAbiParameters(
7280
### File: `main.js`
7381

7482
#### 1. Fixed `signWithPasskey()` function
75-
**Lines 503-548**
83+
84+
Lines 503-548
7685

7786
Changes made:
87+
7888
1. Convert challenge to base64url string before passing to `startAuthentication`
7989
2. Use original base64url credential ID string (not bytes)
8090
3. Replace `encodeFunctionData` with `encodeAbiParameters` for signature encoding
@@ -113,12 +123,14 @@ async function signWithPasskey(hash) {
113123
## Testing
114124

115125
### Before Fix
126+
116127
```
117128
❌ Click "Send ETH" → Passkey prompt → Error:
118129
"base64URLString.replace is not a function"
119130
```
120131

121132
### After Fix
133+
122134
```
123135
✅ Click "Send ETH" → Passkey prompt → Authenticate → UserOp submitted!
124136
```
@@ -128,9 +140,11 @@ async function signWithPasskey(hash) {
128140
## Related Issues Fixed Previously
129141

130142
### Issue 1: UserOperation Hash Encoding (Fixed in previous session)
143+
131144
**Location:** `getUserOperationHash()` function
132145

133146
Changed from `encodeFunctionData` to `encodeAbiParameters`:
147+
134148
```javascript
135149
const packed = encodeAbiParameters(
136150
parseAbiParameters('address, uint256, bytes, uint256, uint256, uint256, uint256, uint256'),
@@ -163,6 +177,7 @@ return keccak256(packed);
163177
### WebAuthn String Format Requirements
164178

165179
The `@simplewebauthn/browser` library requires **base64url strings** for:
180+
166181
- `challenge`: The authentication challenge
167182
- `allowCredentials[].id`: The credential ID
168183
- `user.id`: The user identifier (during registration)
@@ -174,6 +189,7 @@ Do not convert these to arrays or bytes - keep them as base64url strings!
174189
## Complete Function Call Flow
175190

176191
### Transfer Flow
192+
177193
```
178194
1. User clicks "Send ETH"
179195
@@ -225,11 +241,14 @@ Do not convert these to arrays or bytes - keep them as base64url strings!
225241

226242
### Why These Errors Occurred
227243

228-
1. **API Expectations Mismatch**: The `@simplewebauthn/browser` library has specific format requirements that weren't immediately obvious from the documentation.
244+
1. **API Expectations Mismatch**: The `@simplewebauthn/browser` library has specific format requirements
245+
that weren't immediately obvious from the documentation.
229246

230-
2. **Function Naming Confusion**: `encodeFunctionData` and `encodeAbiParameters` sound similar but have different purposes and requirements.
247+
2. **Function Naming Confusion**: `encodeFunctionData` and `encodeAbiParameters` sound similar
248+
but have different purposes and requirements.
231249

232-
3. **Type Conversion**: JavaScript's flexibility with types (strings, arrays, Uint8Arrays) can lead to passing the wrong type without compile-time errors.
250+
3. **Type Conversion**: JavaScript's flexibility with types (strings, arrays,
251+
Uint8Arrays) can lead to passing the wrong type without compile-time errors.
233252

234253
### Prevention
235254

@@ -243,17 +262,21 @@ Do not convert these to arrays or bytes - keep them as base64url strings!
243262
## Additional Fix: EntryPoint Address
244263

245264
### Error: Bundler EntryPoint Mismatch
265+
246266
**Error Message:**
267+
247268
```
248269
Bundler error: EntryPoint 0x0000000071727De22E5E9d8BAf0edAc6f37da032 not supported,
249270
supported EntryPoints: 0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108
250271
```
251272

252273
**Root Cause:**
253-
The ZKsync SSO bundler uses a custom EntryPoint contract at `0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108` instead of the standard ERC-4337 v0.7 EntryPoint.
274+
The ZKsync SSO bundler uses a custom EntryPoint contract at `0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108` instead of the
275+
standard ERC-4337 v0.7 EntryPoint.
254276

255277
**Fix Applied:**
256278
Updated the EntryPoint address to match the bundler's supported address:
279+
257280
```javascript
258281
// Before:
259282
const ENTRYPOINT_ADDRESS = "0x0000000071727De22E5E9d8BAf0edAc6f37da032"; // Standard v0.7
@@ -269,6 +292,7 @@ const ENTRYPOINT_ADDRESS = "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108"; // ZKsy
269292
## Status: ✅ RESOLVED
270293

271294
All errors are now fixed. The transfer functionality works end-to-end:
295+
272296
1. Create passkey ✅
273297
2. Deploy account ✅
274298
3. Transfer ETH ✅

passkey-wallet-app/SDK_README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Compared to the previous manual implementation:
163163
## Differences from Previous Version
164164

165165
| Feature | Old Version | SDK Version |
166-
|---------|-------------|-------------|
166+
| ------- | ----------- | ----------- |
167167
| Passkey creation | Manual `startRegistration` | `registerNewPasskey()` |
168168
| Public key extraction | Manual COSE parsing | Handled by SDK |
169169
| Account deployment | Manual factory call | `deployModularAccount()` |

0 commit comments

Comments
 (0)