w3wallets 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/index.d.mts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +39 -3
- package/dist/index.mjs +39 -3
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# w3wallets
|
|
2
|
+
|
|
3
|
+
Web3 wallets for Playwright.
|
|
4
|
+
|
|
5
|
+
> [!IMPORTANT]
|
|
6
|
+
> This is Alpha!
|
|
7
|
+
|
|
8
|
+
This library provides methods for interacting with Web3 wallets using Playwright.
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install -D w3wallets
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Getting Started
|
|
15
|
+
|
|
16
|
+
Only the `Backpack` wallet is supported at this point.
|
|
17
|
+
|
|
18
|
+
#### 1. Download wallets
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npx w3wallets
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### 2. Wrap your fixture `withWallets`
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { test as base } from "@playwright/test";
|
|
28
|
+
import { withWallets } from "../src/withWallets";
|
|
29
|
+
|
|
30
|
+
const test = withWallets(base, { backpack: true });
|
|
31
|
+
|
|
32
|
+
test("has title", async ({ page, backpack }) => {
|
|
33
|
+
await page.goto("https://playwright.dev/");
|
|
34
|
+
|
|
35
|
+
await backpack.onboard(
|
|
36
|
+
"4wDJd9Ds5ueTdS95ReAZGSBVkjMcNKbgZk47xcmqzpUJjCt7VoB2Cs7hqwXWRnopzXqE4mCP6BEDHCYrFttEcBw2",
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import * as playwright_test from 'playwright/test';
|
|
2
|
-
import { test, BrowserContext } from '@playwright/test';
|
|
2
|
+
import { Page, test, BrowserContext } from '@playwright/test';
|
|
3
|
+
|
|
4
|
+
declare class Backpack {
|
|
5
|
+
private page;
|
|
6
|
+
constructor(page: Page);
|
|
7
|
+
onboard(privateKey: string): Promise<void>;
|
|
8
|
+
}
|
|
3
9
|
|
|
4
10
|
type Config = {
|
|
5
11
|
backpack: boolean;
|
|
6
12
|
};
|
|
7
|
-
declare function
|
|
13
|
+
declare function withWallets(test: typeof test, config: Config): playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & {
|
|
8
14
|
context: BrowserContext;
|
|
15
|
+
backpack: Backpack;
|
|
16
|
+
extensionId: string;
|
|
9
17
|
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
10
18
|
|
|
11
|
-
export { withExtensions };
|
|
19
|
+
export { withWallets as withExtensions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import * as playwright_test from 'playwright/test';
|
|
2
|
-
import { test, BrowserContext } from '@playwright/test';
|
|
2
|
+
import { Page, test, BrowserContext } from '@playwright/test';
|
|
3
|
+
|
|
4
|
+
declare class Backpack {
|
|
5
|
+
private page;
|
|
6
|
+
constructor(page: Page);
|
|
7
|
+
onboard(privateKey: string): Promise<void>;
|
|
8
|
+
}
|
|
3
9
|
|
|
4
10
|
type Config = {
|
|
5
11
|
backpack: boolean;
|
|
6
12
|
};
|
|
7
|
-
declare function
|
|
13
|
+
declare function withWallets(test: typeof test, config: Config): playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & {
|
|
8
14
|
context: BrowserContext;
|
|
15
|
+
backpack: Backpack;
|
|
16
|
+
extensionId: string;
|
|
9
17
|
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
10
18
|
|
|
11
|
-
export { withExtensions };
|
|
19
|
+
export { withWallets as withExtensions };
|
package/dist/index.js
CHANGED
|
@@ -30,18 +30,47 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
withExtensions: () =>
|
|
33
|
+
withExtensions: () => withWallets
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
|
-
// src/
|
|
37
|
+
// src/withWallets.ts
|
|
38
38
|
var import_path = __toESM(require("path"));
|
|
39
39
|
var import_fs = __toESM(require("fs"));
|
|
40
40
|
var import_test = require("@playwright/test");
|
|
41
41
|
var import_test2 = require("@playwright/test");
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
// src/backpack/index.ts
|
|
44
|
+
var Backpack = class {
|
|
45
|
+
constructor(page) {
|
|
46
|
+
this.page = page;
|
|
47
|
+
}
|
|
48
|
+
async onboard(privateKey) {
|
|
49
|
+
await this.page.getByRole("button", { name: "I already have a wallet" }).click();
|
|
50
|
+
await this.page.getByRole("button", { name: "Show advanced options" }).click();
|
|
51
|
+
await this.page.getByRole("button", { name: "Import with private key" }).click();
|
|
52
|
+
await this.page.getByPlaceholder("Enter private key").fill(privateKey);
|
|
53
|
+
await this.page.getByRole("button", { name: "Import" }).click();
|
|
54
|
+
await this.page.getByPlaceholder("Password", { exact: true }).fill("11111111");
|
|
55
|
+
await this.page.getByPlaceholder("Confirm Password").fill("11111111");
|
|
56
|
+
await this.page.getByRole("checkbox").click();
|
|
57
|
+
await this.page.getByRole("button", { name: "Next" }).click();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/withWallets.ts
|
|
62
|
+
function withWallets(test, config) {
|
|
43
63
|
const backpack = import_path.default.join(process.cwd(), "extensions", "backpack");
|
|
44
64
|
return test.extend({
|
|
65
|
+
backpack: async ({ context, extensionId }, use) => {
|
|
66
|
+
const page = context.pages()[0];
|
|
67
|
+
if (!page) throw Error("No pages in context");
|
|
68
|
+
const backpack2 = new Backpack(page);
|
|
69
|
+
await page.goto(
|
|
70
|
+
`chrome-extension://${extensionId}/options.html?onboarding=true`
|
|
71
|
+
);
|
|
72
|
+
await use(backpack2);
|
|
73
|
+
},
|
|
45
74
|
context: async ({}, use) => {
|
|
46
75
|
const userDataDir = import_path.default.join(process.cwd(), ".tmp-user-data");
|
|
47
76
|
const backpackDownloaded = import_fs.default.existsSync(
|
|
@@ -58,6 +87,13 @@ function withExtensions(test, config) {
|
|
|
58
87
|
});
|
|
59
88
|
await use(context);
|
|
60
89
|
await context.close();
|
|
90
|
+
},
|
|
91
|
+
extensionId: async ({ context }, use) => {
|
|
92
|
+
let [background] = context.serviceWorkers();
|
|
93
|
+
if (!background) background = await context.waitForEvent("serviceworker");
|
|
94
|
+
const extensionId = background.url().split("/")[2];
|
|
95
|
+
if (!extensionId) throw Error("No extension id");
|
|
96
|
+
await use(extensionId);
|
|
61
97
|
}
|
|
62
98
|
});
|
|
63
99
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,40 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/withWallets.ts
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import "@playwright/test";
|
|
5
5
|
import { chromium } from "@playwright/test";
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
// src/backpack/index.ts
|
|
8
|
+
var Backpack = class {
|
|
9
|
+
constructor(page) {
|
|
10
|
+
this.page = page;
|
|
11
|
+
}
|
|
12
|
+
async onboard(privateKey) {
|
|
13
|
+
await this.page.getByRole("button", { name: "I already have a wallet" }).click();
|
|
14
|
+
await this.page.getByRole("button", { name: "Show advanced options" }).click();
|
|
15
|
+
await this.page.getByRole("button", { name: "Import with private key" }).click();
|
|
16
|
+
await this.page.getByPlaceholder("Enter private key").fill(privateKey);
|
|
17
|
+
await this.page.getByRole("button", { name: "Import" }).click();
|
|
18
|
+
await this.page.getByPlaceholder("Password", { exact: true }).fill("11111111");
|
|
19
|
+
await this.page.getByPlaceholder("Confirm Password").fill("11111111");
|
|
20
|
+
await this.page.getByRole("checkbox").click();
|
|
21
|
+
await this.page.getByRole("button", { name: "Next" }).click();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/withWallets.ts
|
|
26
|
+
function withWallets(test, config) {
|
|
7
27
|
const backpack = path.join(process.cwd(), "extensions", "backpack");
|
|
8
28
|
return test.extend({
|
|
29
|
+
backpack: async ({ context, extensionId }, use) => {
|
|
30
|
+
const page = context.pages()[0];
|
|
31
|
+
if (!page) throw Error("No pages in context");
|
|
32
|
+
const backpack2 = new Backpack(page);
|
|
33
|
+
await page.goto(
|
|
34
|
+
`chrome-extension://${extensionId}/options.html?onboarding=true`
|
|
35
|
+
);
|
|
36
|
+
await use(backpack2);
|
|
37
|
+
},
|
|
9
38
|
context: async ({}, use) => {
|
|
10
39
|
const userDataDir = path.join(process.cwd(), ".tmp-user-data");
|
|
11
40
|
const backpackDownloaded = fs.existsSync(
|
|
@@ -22,9 +51,16 @@ function withExtensions(test, config) {
|
|
|
22
51
|
});
|
|
23
52
|
await use(context);
|
|
24
53
|
await context.close();
|
|
54
|
+
},
|
|
55
|
+
extensionId: async ({ context }, use) => {
|
|
56
|
+
let [background] = context.serviceWorkers();
|
|
57
|
+
if (!background) background = await context.waitForEvent("serviceworker");
|
|
58
|
+
const extensionId = background.url().split("/")[2];
|
|
59
|
+
if (!extensionId) throw Error("No extension id");
|
|
60
|
+
await use(extensionId);
|
|
25
61
|
}
|
|
26
62
|
});
|
|
27
63
|
}
|
|
28
64
|
export {
|
|
29
|
-
withExtensions
|
|
65
|
+
withWallets as withExtensions
|
|
30
66
|
};
|