w3wallets 0.0.3 → 0.1.0
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/dist/index.d.mts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +53 -16
- package/dist/index.mjs +50 -13
- package/package.json +11 -5
- package/README.md +0 -39
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import * as playwright_test from 'playwright/test';
|
|
2
2
|
import { Page, test, BrowserContext } from '@playwright/test';
|
|
3
3
|
|
|
4
|
+
type BackPackNetwork = "Eclipse";
|
|
5
|
+
|
|
4
6
|
declare class Backpack {
|
|
5
7
|
private page;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
private extensionId;
|
|
9
|
+
private defaultPassword;
|
|
10
|
+
constructor(page: Page, extensionId: string);
|
|
11
|
+
onboard(network: BackPackNetwork, privateKey: string): Promise<void>;
|
|
12
|
+
unlock(): Promise<void>;
|
|
13
|
+
goToSettings(accountName?: string): Promise<void>;
|
|
14
|
+
setRPC(network: BackPackNetwork, rpc: string): Promise<void>;
|
|
15
|
+
ignoreAndProceed(): Promise<void>;
|
|
16
|
+
approve(): Promise<void>;
|
|
17
|
+
deny(): Promise<void>;
|
|
8
18
|
}
|
|
9
19
|
|
|
10
20
|
type Config = {
|
|
@@ -16,4 +26,4 @@ declare function withWallets(test: typeof test, config: Config): playwright_test
|
|
|
16
26
|
extensionId: string;
|
|
17
27
|
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
18
28
|
|
|
19
|
-
export { withWallets
|
|
29
|
+
export { withWallets };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import * as playwright_test from 'playwright/test';
|
|
2
2
|
import { Page, test, BrowserContext } from '@playwright/test';
|
|
3
3
|
|
|
4
|
+
type BackPackNetwork = "Eclipse";
|
|
5
|
+
|
|
4
6
|
declare class Backpack {
|
|
5
7
|
private page;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
private extensionId;
|
|
9
|
+
private defaultPassword;
|
|
10
|
+
constructor(page: Page, extensionId: string);
|
|
11
|
+
onboard(network: BackPackNetwork, privateKey: string): Promise<void>;
|
|
12
|
+
unlock(): Promise<void>;
|
|
13
|
+
goToSettings(accountName?: string): Promise<void>;
|
|
14
|
+
setRPC(network: BackPackNetwork, rpc: string): Promise<void>;
|
|
15
|
+
ignoreAndProceed(): Promise<void>;
|
|
16
|
+
approve(): Promise<void>;
|
|
17
|
+
deny(): Promise<void>;
|
|
8
18
|
}
|
|
9
19
|
|
|
10
20
|
type Config = {
|
|
@@ -16,4 +26,4 @@ declare function withWallets(test: typeof test, config: Config): playwright_test
|
|
|
16
26
|
extensionId: string;
|
|
17
27
|
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
18
28
|
|
|
19
|
-
export { withWallets
|
|
29
|
+
export { withWallets };
|
package/dist/index.js
CHANGED
|
@@ -30,55 +30,92 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
|
|
33
|
+
withWallets: () => withWallets
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// src/withWallets.ts
|
|
38
38
|
var import_path = __toESM(require("path"));
|
|
39
39
|
var import_fs = __toESM(require("fs"));
|
|
40
|
-
var import_test = require("@playwright/test");
|
|
41
40
|
var import_test2 = require("@playwright/test");
|
|
41
|
+
var import_test3 = require("@playwright/test");
|
|
42
42
|
|
|
43
|
-
// src/backpack/
|
|
43
|
+
// src/backpack/backpack.ts
|
|
44
|
+
var import_test = require("@playwright/test");
|
|
44
45
|
var Backpack = class {
|
|
45
|
-
constructor(page) {
|
|
46
|
+
constructor(page, extensionId) {
|
|
46
47
|
this.page = page;
|
|
48
|
+
this.extensionId = extensionId;
|
|
47
49
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
await this.page.getByRole("button", { name: "
|
|
51
|
-
await this.page.getByRole("button", { name:
|
|
50
|
+
defaultPassword = "11111111";
|
|
51
|
+
async onboard(network, privateKey) {
|
|
52
|
+
await this.page.getByRole("button", { name: "Import wallet" }).click();
|
|
53
|
+
await this.page.getByRole("button", { name: network }).click();
|
|
54
|
+
await this.page.getByRole("button", { name: "Import private key" }).click();
|
|
52
55
|
await this.page.getByPlaceholder("Enter private key").fill(privateKey);
|
|
53
56
|
await this.page.getByRole("button", { name: "Import" }).click();
|
|
54
|
-
await this.page.getByPlaceholder("Password", { exact: true }).fill(
|
|
55
|
-
await this.page.getByPlaceholder("Confirm Password").fill(
|
|
57
|
+
await this.page.getByPlaceholder("Password", { exact: true }).fill(this.defaultPassword);
|
|
58
|
+
await this.page.getByPlaceholder("Confirm Password").fill(this.defaultPassword);
|
|
56
59
|
await this.page.getByRole("checkbox").click();
|
|
57
60
|
await this.page.getByRole("button", { name: "Next" }).click();
|
|
61
|
+
await (0, import_test.expect)(this.page.getByText("You're all good!")).toBeVisible();
|
|
62
|
+
await this.page.goto(`chrome-extension://${this.extensionId}/popup.html`);
|
|
63
|
+
}
|
|
64
|
+
async unlock() {
|
|
65
|
+
await this.page.getByPlaceholder("Password").fill(this.defaultPassword);
|
|
66
|
+
await this.page.getByRole("button", { name: "Unlock" }).click();
|
|
67
|
+
}
|
|
68
|
+
async goToSettings(accountName) {
|
|
69
|
+
await this.page.getByRole("button", { name: accountName ?? "A1" }).click();
|
|
70
|
+
await this.page.getByRole("button", { name: "Settings" }).click();
|
|
71
|
+
}
|
|
72
|
+
async setRPC(network, rpc) {
|
|
73
|
+
await this.goToSettings();
|
|
74
|
+
await this.page.getByRole("button", { name: network }).click();
|
|
75
|
+
await this.page.getByRole("button", { name: "RPC Connection" }).click();
|
|
76
|
+
await this.page.getByRole("button", { name: "Custom" }).click();
|
|
77
|
+
await this.page.getByPlaceholder("RPC URL").fill(rpc);
|
|
78
|
+
await this.page.keyboard.press("Enter");
|
|
79
|
+
}
|
|
80
|
+
async ignoreAndProceed() {
|
|
81
|
+
const ignoreButton = this.page.getByText("Ignore and proceed anyway.");
|
|
82
|
+
await ignoreButton.click();
|
|
83
|
+
}
|
|
84
|
+
async approve() {
|
|
85
|
+
await this.page.getByText("Approve").click();
|
|
86
|
+
}
|
|
87
|
+
async deny() {
|
|
88
|
+
await this.page.getByText("Deny").click();
|
|
58
89
|
}
|
|
59
90
|
};
|
|
60
91
|
|
|
61
92
|
// src/withWallets.ts
|
|
62
93
|
function withWallets(test, config) {
|
|
63
|
-
const backpack = import_path.default.join(process.cwd(), "
|
|
94
|
+
const backpack = import_path.default.join(process.cwd(), "wallets", "backpack");
|
|
64
95
|
return test.extend({
|
|
65
96
|
backpack: async ({ context, extensionId }, use) => {
|
|
66
97
|
const page = context.pages()[0];
|
|
67
98
|
if (!page) throw Error("No pages in context");
|
|
68
|
-
const backpack2 = new Backpack(page);
|
|
99
|
+
const backpack2 = new Backpack(page, extensionId);
|
|
69
100
|
await page.goto(
|
|
70
101
|
`chrome-extension://${extensionId}/options.html?onboarding=true`
|
|
71
102
|
);
|
|
72
103
|
await use(backpack2);
|
|
73
104
|
},
|
|
74
|
-
context: async ({}, use) => {
|
|
75
|
-
const userDataDir = import_path.default.join(
|
|
105
|
+
context: async ({}, use, testInfo) => {
|
|
106
|
+
const userDataDir = import_path.default.join(
|
|
107
|
+
process.cwd(),
|
|
108
|
+
".w3wallets",
|
|
109
|
+
testInfo.testId
|
|
110
|
+
);
|
|
111
|
+
if (import_fs.default.existsSync(userDataDir))
|
|
112
|
+
import_fs.default.rmSync(userDataDir, { recursive: true });
|
|
76
113
|
const backpackDownloaded = import_fs.default.existsSync(
|
|
77
114
|
import_path.default.join(backpack, "manifest.json")
|
|
78
115
|
);
|
|
79
116
|
if (!backpackDownloaded)
|
|
80
117
|
throw Error("Cannot find Backpack. download it `npx w3wallets`");
|
|
81
|
-
const context = await
|
|
118
|
+
const context = await import_test3.chromium.launchPersistentContext(userDataDir, {
|
|
82
119
|
headless: false,
|
|
83
120
|
args: [
|
|
84
121
|
`--disable-extensions-except=${backpack}`,
|
|
@@ -99,5 +136,5 @@ function withWallets(test, config) {
|
|
|
99
136
|
}
|
|
100
137
|
// Annotate the CommonJS export names for ESM import in node:
|
|
101
138
|
0 && (module.exports = {
|
|
102
|
-
|
|
139
|
+
withWallets
|
|
103
140
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -4,39 +4,76 @@ import fs from "fs";
|
|
|
4
4
|
import "@playwright/test";
|
|
5
5
|
import { chromium } from "@playwright/test";
|
|
6
6
|
|
|
7
|
-
// src/backpack/
|
|
7
|
+
// src/backpack/backpack.ts
|
|
8
|
+
import { expect } from "@playwright/test";
|
|
8
9
|
var Backpack = class {
|
|
9
|
-
constructor(page) {
|
|
10
|
+
constructor(page, extensionId) {
|
|
10
11
|
this.page = page;
|
|
12
|
+
this.extensionId = extensionId;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
await this.page.getByRole("button", { name: "
|
|
15
|
-
await this.page.getByRole("button", { name:
|
|
14
|
+
defaultPassword = "11111111";
|
|
15
|
+
async onboard(network, privateKey) {
|
|
16
|
+
await this.page.getByRole("button", { name: "Import wallet" }).click();
|
|
17
|
+
await this.page.getByRole("button", { name: network }).click();
|
|
18
|
+
await this.page.getByRole("button", { name: "Import private key" }).click();
|
|
16
19
|
await this.page.getByPlaceholder("Enter private key").fill(privateKey);
|
|
17
20
|
await this.page.getByRole("button", { name: "Import" }).click();
|
|
18
|
-
await this.page.getByPlaceholder("Password", { exact: true }).fill(
|
|
19
|
-
await this.page.getByPlaceholder("Confirm Password").fill(
|
|
21
|
+
await this.page.getByPlaceholder("Password", { exact: true }).fill(this.defaultPassword);
|
|
22
|
+
await this.page.getByPlaceholder("Confirm Password").fill(this.defaultPassword);
|
|
20
23
|
await this.page.getByRole("checkbox").click();
|
|
21
24
|
await this.page.getByRole("button", { name: "Next" }).click();
|
|
25
|
+
await expect(this.page.getByText("You're all good!")).toBeVisible();
|
|
26
|
+
await this.page.goto(`chrome-extension://${this.extensionId}/popup.html`);
|
|
27
|
+
}
|
|
28
|
+
async unlock() {
|
|
29
|
+
await this.page.getByPlaceholder("Password").fill(this.defaultPassword);
|
|
30
|
+
await this.page.getByRole("button", { name: "Unlock" }).click();
|
|
31
|
+
}
|
|
32
|
+
async goToSettings(accountName) {
|
|
33
|
+
await this.page.getByRole("button", { name: accountName ?? "A1" }).click();
|
|
34
|
+
await this.page.getByRole("button", { name: "Settings" }).click();
|
|
35
|
+
}
|
|
36
|
+
async setRPC(network, rpc) {
|
|
37
|
+
await this.goToSettings();
|
|
38
|
+
await this.page.getByRole("button", { name: network }).click();
|
|
39
|
+
await this.page.getByRole("button", { name: "RPC Connection" }).click();
|
|
40
|
+
await this.page.getByRole("button", { name: "Custom" }).click();
|
|
41
|
+
await this.page.getByPlaceholder("RPC URL").fill(rpc);
|
|
42
|
+
await this.page.keyboard.press("Enter");
|
|
43
|
+
}
|
|
44
|
+
async ignoreAndProceed() {
|
|
45
|
+
const ignoreButton = this.page.getByText("Ignore and proceed anyway.");
|
|
46
|
+
await ignoreButton.click();
|
|
47
|
+
}
|
|
48
|
+
async approve() {
|
|
49
|
+
await this.page.getByText("Approve").click();
|
|
50
|
+
}
|
|
51
|
+
async deny() {
|
|
52
|
+
await this.page.getByText("Deny").click();
|
|
22
53
|
}
|
|
23
54
|
};
|
|
24
55
|
|
|
25
56
|
// src/withWallets.ts
|
|
26
57
|
function withWallets(test, config) {
|
|
27
|
-
const backpack = path.join(process.cwd(), "
|
|
58
|
+
const backpack = path.join(process.cwd(), "wallets", "backpack");
|
|
28
59
|
return test.extend({
|
|
29
60
|
backpack: async ({ context, extensionId }, use) => {
|
|
30
61
|
const page = context.pages()[0];
|
|
31
62
|
if (!page) throw Error("No pages in context");
|
|
32
|
-
const backpack2 = new Backpack(page);
|
|
63
|
+
const backpack2 = new Backpack(page, extensionId);
|
|
33
64
|
await page.goto(
|
|
34
65
|
`chrome-extension://${extensionId}/options.html?onboarding=true`
|
|
35
66
|
);
|
|
36
67
|
await use(backpack2);
|
|
37
68
|
},
|
|
38
|
-
context: async ({}, use) => {
|
|
39
|
-
const userDataDir = path.join(
|
|
69
|
+
context: async ({}, use, testInfo) => {
|
|
70
|
+
const userDataDir = path.join(
|
|
71
|
+
process.cwd(),
|
|
72
|
+
".w3wallets",
|
|
73
|
+
testInfo.testId
|
|
74
|
+
);
|
|
75
|
+
if (fs.existsSync(userDataDir))
|
|
76
|
+
fs.rmSync(userDataDir, { recursive: true });
|
|
40
77
|
const backpackDownloaded = fs.existsSync(
|
|
41
78
|
path.join(backpack, "manifest.json")
|
|
42
79
|
);
|
|
@@ -62,5 +99,5 @@ function withWallets(test, config) {
|
|
|
62
99
|
});
|
|
63
100
|
}
|
|
64
101
|
export {
|
|
65
|
-
withWallets
|
|
102
|
+
withWallets
|
|
66
103
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w3wallets",
|
|
3
3
|
"description": "browser wallets for playwright",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.1.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"
|
|
7
|
+
"homepage": "https://github.com/Maksandre/w3wallets",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/Maksandre/w3wallets/issues"
|
|
10
|
+
},
|
|
11
|
+
"author": "Max Andreev",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/Maksandre/w3wallets.git"
|
|
15
|
+
},
|
|
8
16
|
"license": "MIT",
|
|
9
17
|
"publishConfig": {
|
|
10
18
|
"access": "public"
|
|
@@ -12,9 +20,7 @@
|
|
|
12
20
|
"files": [
|
|
13
21
|
"dist"
|
|
14
22
|
],
|
|
15
|
-
"bin":
|
|
16
|
-
"w3wallets": "./src/scripts/download.js"
|
|
17
|
-
},
|
|
23
|
+
"bin": "./src/scripts/download.js",
|
|
18
24
|
"devDependencies": {
|
|
19
25
|
"@arethetypeswrong/cli": "^0.17.2",
|
|
20
26
|
"@changesets/cli": "^2.27.11",
|
package/README.md
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
```
|