Skip to content

Commit c88ee42

Browse files
authored
Release 1.0.0 (#55)
* Refactor wallet structure * Refactor wallet exports and improve configuration structure * Add test-dapp package with initial configuration and dependencies * Remove test-contracts package and update test-dapp configuration for Foundry integration * Update test-dapp configuration and components * Add ERC-20 token functionality to test-dapp * Refactor test-dapp to integrate ERC-721 NFT functionality and streamline ERC-20 components * Add SignMessageSection component to test-dapp for signing messages functionality * add infra * Сonditionally display ERC-20 and ERC-721 sections based on environment * Enhance w3wallets CLI with short aliases and detailed help options * Enhance withWallets function to derive Chrome extension IDs from manifest.json and improve error handling for service worker initialization * add metamask functionality * Fix codestyle * Update w3wallets package version to 1.0.0-beta.1 * Restore pjs test * remove backpack * remove test-app * fix CI * Update peer dependency for @playwright/test to version 1.57.0 * Add recursive submodule checkout in Playwright CI workflow * Refactor start script for test-dapp to improve deployment process * Enhance start script for test-dapp to build and run Next.js production server; add additional Chrome flags in withWallets for improved performance * Do not remova pages in fixture * Update Metamask onboarding page URL and increase button visibility timeout * Refactor Metamask onboarding process to improve mnemonic input handling and code readability * Implement configurable action timeout for wallet interactions and update example environment variables * Refactor Metamask interactions to remove hardcoded timeouts, utilizing default timeout from Wallet class configuration * Replace Hardhat references with Anvil * Add erc-20 tests * fix * fix format * Update w3wallets version to 1.0.0-beta.3 in package.json * One worker on CI * fix ci * increase workers * Squashed commit of the following: commit 21d9cc03d1e04421da297070025e4aaf12f75174 Author: Max Andreev <maxick20@gmail.com> Date: Sun Feb 1 22:23:01 2026 +0500 update caching commit d95a5bd4478319e3fc4f28c5c96577d9269d3c5f Author: Max Andreev <maxick20@gmail.com> Date: Sun Feb 1 15:32:07 2026 +0500 Fix cached wallet restoration for MV3 extensions Persist chrome.storage.session data to chrome.storage.local during cache build using a helper page to bypass LavaMoat scuttling. Set storageKind to "data" so MetaMask reads all state from local storage on restart. Add homeUrl to WalletConfig for navigating to extension home in cached mode, and update test to handle unlock + "wallet ready" interstitial. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> commit e1da2b33d061c6508aa2b94e8b7bfc1d5b0ae372 Author: Max Andreev <maxick20@gmail.com> Date: Sun Feb 1 14:52:56 2026 +0500 Add example setup, cached test, and gitignore entry Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> commit cf365e4736c28d54135b4d20411d203b26f697a2 Author: Max Andreev <maxick20@gmail.com> Date: Sun Feb 1 14:41:36 2026 +0500 Update withWallets to support cached wallet configs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> commit 23c9bbab29f6b298e785dfb74b3ded5233e1804a Author: Max Andreev <maxick20@gmail.com> Date: Sun Feb 1 14:35:33 2026 +0500 Add cache build logic and CLI command Implements buildCacheForSetup and buildAllCaches in src/cache/buildCache.ts, adds src/scripts/cache.ts as compiled CLI entry point, and delegates `npx w3wallets cache` from download.js to the compiled script. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> commit 9edfdf3b6f6e0853c349f4abe713d69120d17ff0 Author: Max Andreev <maxick20@gmail.com> Date: Sun Feb 1 14:26:03 2026 +0500 Add cache types, constants and defineSetup Introduce the cache module foundation: SetupFn/CachedWalletConfig types, CACHE_DIR constant, defineSetup helper, and isCachedConfig type guard. * add cahce script * add expect timeout * update playwright * update lock file
1 parent 7f72150 commit c88ee42

File tree

26 files changed

+643
-47
lines changed

26 files changed

+643
-47
lines changed

.github/workflows/playwright.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
name: "Playwright Tests"
1919
runs-on: ubuntu-latest
2020
container:
21-
image: mcr.microsoft.com/playwright:v1.57.0-noble
21+
image: mcr.microsoft.com/playwright:v1.58.1-noble
2222
env:
2323
NEXT_PUBLIC_WC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WC_PROJECT_ID }}
2424
steps:
@@ -55,8 +55,16 @@ jobs:
5555
- name: 🖨 Copy test envs
5656
run: cp packages/w3wallets/.env.example packages/w3wallets/.env
5757

58+
- name: 🔨 Build w3wallets
59+
run: yarn build
60+
working-directory: packages/w3wallets
61+
62+
- name: 🗄️ Build wallet cache
63+
run: xvfb-run --auto-servernum --server-args='-screen 0 1280x800x24' npx w3wallets cache tests/wallets-cache/
64+
working-directory: packages/w3wallets
65+
5866
- name: 🧪 Run tests
59-
run: xvfb-run --auto-servernum --server-args='-screen 0 1280x800x24' yarn test
67+
run: xvfb-run --auto-servernum --server-args='-screen 0 1280x800x24' yarn test:ci
6068

6169
- name: Upload test artifacts
6270
uses: actions/upload-artifact@v4

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"deploy": "yarn workspace @w3wallets/test-dapp deploy",
1111
"build": "yarn workspace w3wallets build",
1212
"download-wallets": "yarn workspace w3wallets download-wallets",
13-
"test": "yarn workspace w3wallets test"
13+
"test": "yarn workspace w3wallets test",
14+
"test:ci": "yarn workspace w3wallets test:ci"
1415
},
1516
"packageManager": "yarn@4.6.0",
1617
"dependencies": {

packages/w3wallets/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ ETHEREUM_PRIVATE_KEY1=0x903518e191f3843d017f0f9611cfdd27c655565917887faf2762549e
33
ETHEREUM_MNEMONIC2=typical flock crash unique wage turtle become trim legend diet dance kitchen
44
ETHEREUM_PRIVATE_KEY2=0xbf80a3a6906d48c828b1f3a71ee529092375557f3ab4d3088f1e9495cdb7b624
55
SUBSTRATE_SEED=focus inspire onion claw ski jaguar kidney screen bike kiss icon aerobic
6-
W3WALLETS_ACTION_TIMEOUT=60000
6+
W3WALLETS_ACTION_TIMEOUT=60000
7+
W3WALLETS_EXPECT_TIMEOUT=60000

packages/w3wallets/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,65 @@ test("Can connect MetaMask to dApp", async ({ page, metamask }) => {
105105
});
106106
```
107107

108+
## Caching
109+
110+
Wallet onboarding can be slow. Caching lets you run the setup once and reuse the browser profile across tests.
111+
112+
#### 1. Create a setup file
113+
114+
Create a `*.cache.ts` file in a `wallets-cache/` directory (default):
115+
116+
```ts
117+
// wallets-cache/default.cache.ts
118+
import { prepareWallet, metamask } from "w3wallets";
119+
120+
export default prepareWallet(metamask, async (wallet, page) => {
121+
await wallet.onboard("your seed phrase ...", "YourPassword123!");
122+
});
123+
```
124+
125+
#### 2. Build the cache
126+
127+
```sh
128+
npx w3wallets cache
129+
```
130+
131+
<details>
132+
<summary>CLI Options</summary>
133+
134+
```
135+
USAGE:
136+
npx w3wallets cache [OPTIONS] [directory]
137+
138+
OPTIONS:
139+
-f, --force Force rebuild even if cache exists
140+
--headed Run browser in headed mode
141+
directory Directory containing *.cache.{ts,js} files (default: ./wallets-cache/)
142+
```
143+
144+
</details>
145+
146+
The cached profiles are stored in `.w3wallets/cache/`. The `.w3wallets` directory should already be in `.gitignore`.
147+
148+
#### 3. Use cached wallets in tests
149+
150+
Import the setup and pass it to `withWallets`:
151+
152+
```ts
153+
import { test as base, expect } from "@playwright/test";
154+
import { withWallets } from "w3wallets";
155+
import cachedMetamask from "./wallets-cache/default.cache";
156+
157+
const test = withWallets(base, cachedMetamask);
158+
159+
test("wallet is ready", async ({ metamask }) => {
160+
await metamask.unlock("YourPassword123!");
161+
// wallet is already onboarded
162+
});
163+
```
164+
165+
> **Note:** All wallets in a test must be either all cached or all non-cached.
166+
108167
## Configuration
109168

110169
Configure library behavior via environment variables:

packages/w3wallets/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "w3wallets",
33
"description": "browser wallets for playwright",
4-
"version": "1.0.0-beta.3",
4+
"version": "1.0.0-beta.4",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"homepage": "https://github.com/Maksandre/w3wallets",
@@ -31,7 +31,7 @@
3131
"bin": "./src/scripts/download.js",
3232
"scripts": {
3333
"download-wallets": "npx w3wallets pjs mm",
34-
"test": "npx playwright test --project=local --workers=2",
34+
"test": "npx playwright test --project=local",
3535
"test:ci": "npx playwright test --project=ci",
3636
"build": "tsup",
3737
"clean": "rm -rf dist",
@@ -46,7 +46,7 @@
4646
"devDependencies": {
4747
"@arethetypeswrong/cli": "^0.17.2",
4848
"@changesets/cli": "^2.27.11",
49-
"@playwright/test": "1.57.0",
49+
"@playwright/test": "1.58.1",
5050
"@types/node": "^22.10.5",
5151
"dotenv": "^16.4.7",
5252
"prettier": "^3.4.2",

packages/w3wallets/playwright.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ export default defineConfig({
1111
/* Fail the build on CI if you accidentally left test.only in the source code. */
1212
forbidOnly: !!process.env.CI,
1313
/* Retry on CI only */
14-
// retries: process.env.CI ? 2 : 0,
14+
retries: process.env.CI ? 1 : 0,
1515
/* Opt out of parallel tests on CI. */
16-
// workers: process.env.CI ? 1 : undefined,
16+
workers: process.env.CI ? 2 : undefined,
1717
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
1818
reporter: "html",
1919
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */

0 commit comments

Comments
 (0)