w3wallets 0.4.1 → 0.5.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/README.md CHANGED
@@ -57,7 +57,7 @@ export { expect } from "@playwright/test";
57
57
 
58
58
  #### 3. Use the installed wallets in tests
59
59
 
60
- Most of the actions will use the following methods:
60
+ Most often, you will use the following methods:
61
61
 
62
62
  1. `onboard`: to set up your wallet
63
63
  2. `approve`: for operations that confirm actions
package/dist/index.d.mts CHANGED
@@ -67,7 +67,8 @@ declare class Metamask extends Wallet {
67
67
  * @param mnemonic 12-word mnemonic seed phrase
68
68
  */
69
69
  onboard(mnemonic: string, password?: string): Promise<void>;
70
- connectToNetwork(settings: NetworkSettings, switchNetwork?: boolean): Promise<void>;
70
+ connectToNetwork(networkName: string): Promise<void>;
71
+ connectToNetwork(settings: NetworkSettings): Promise<void>;
71
72
  approve(): Promise<void>;
72
73
  deny(): Promise<void>;
73
74
  private usingNotificationPage;
package/dist/index.d.ts CHANGED
@@ -67,7 +67,8 @@ declare class Metamask extends Wallet {
67
67
  * @param mnemonic 12-word mnemonic seed phrase
68
68
  */
69
69
  onboard(mnemonic: string, password?: string): Promise<void>;
70
- connectToNetwork(settings: NetworkSettings, switchNetwork?: boolean): Promise<void>;
70
+ connectToNetwork(networkName: string): Promise<void>;
71
+ connectToNetwork(settings: NetworkSettings): Promise<void>;
71
72
  approve(): Promise<void>;
72
73
  deny(): Promise<void>;
73
74
  private usingNotificationPage;
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ var Backpack = class extends Wallet {
62
62
  maxAccountId = 0;
63
63
  async gotoOnboardPage() {
64
64
  await this.page.goto(
65
- `chrome-extension://${this.extensionId}/options.html?onboarding=true`
65
+ `chrome-extension://${this.extensionId}/onboarding.html`
66
66
  );
67
67
  await (0, import_test.expect)(this.page.getByText("Welcome to Backpack")).toBeVisible();
68
68
  }
@@ -75,7 +75,7 @@ var Backpack = class extends Wallet {
75
75
  this.maxAccountId++;
76
76
  this.currentAccountId = this.maxAccountId;
77
77
  await this.page.goto(
78
- `chrome-extension://${this.extensionId}/options.html?add-user-account=true`
78
+ `chrome-extension://${this.extensionId}/onboarding.html?add-user-account=true`
79
79
  );
80
80
  await this._importAccount(network, privateKey, false);
81
81
  }
@@ -115,18 +115,26 @@ var Backpack = class extends Wallet {
115
115
  return this.page.getByRole("button", { name: `A${this.currentAccountId}`, exact: true }).click();
116
116
  }
117
117
  async _importAccount(network, privateKey, isOnboard) {
118
- await this.page.getByRole("button", { name: "Import wallet" }).click();
119
- await this.page.getByRole("button", { name: network }).click();
120
- await this.page.getByRole("button", { name: "Import private key" }).click();
121
- await this.page.getByPlaceholder("Enter private key").fill(privateKey);
122
- await this.page.getByRole("button", { name: "Import" }).click();
118
+ {
119
+ await this.page.waitForTimeout(2e3);
120
+ if (await this.page.getByText("You're all good!").isVisible()) {
121
+ await this.page.getByLabel("Go back").click();
122
+ }
123
+ }
124
+ await this.page.getByRole("button", { name: "I agree to the terms" }).click();
125
+ await this.page.getByText("I already have a wallet").click();
126
+ await this.page.getByText("Show all networks").click();
127
+ await this.page.getByText(network).click();
128
+ await this.page.getByText("Private key").click();
129
+ await this.page.getByPlaceholder("Private key").fill(privateKey);
130
+ await this.page.waitForTimeout(1e3);
131
+ await this.page.getByText("Import", { exact: true }).click();
123
132
  if (isOnboard) {
124
- await this.page.getByPlaceholder("Password", { exact: true }).fill(this.defaultPassword);
125
- await this.page.getByPlaceholder("Confirm Password").fill(this.defaultPassword);
126
- await this.page.getByRole("checkbox").click();
127
- await this.page.getByRole("button", { name: "Next" }).click();
133
+ await this.page.getByRole("textbox").nth(1).fill(this.defaultPassword);
134
+ await this.page.getByRole("textbox").nth(2).fill(this.defaultPassword);
135
+ await this.page.getByText("Next", { exact: true }).click();
136
+ await (0, import_test.expect)(this.page.getByText("You're all good!")).toBeVisible();
128
137
  }
129
- await (0, import_test.expect)(this.page.getByText("You're all good!")).toBeVisible();
130
138
  await this.page.goto(`chrome-extension://${this.extensionId}/popup.html`);
131
139
  }
132
140
  };
@@ -214,21 +222,24 @@ var Metamask = class extends Wallet {
214
222
  await this.page.getByTestId("pin-extension-next").click();
215
223
  await this.page.getByTestId("pin-extension-done").click();
216
224
  }
217
- async connectToNetwork(settings, switchNetwork = true) {
218
- await this.page.locator(".mm-picker-network").click();
219
- await this.page.getByRole("button", { name: "Add a custom network" }).click();
220
- await this.page.getByTestId("network-form-network-name").fill(settings.name);
221
- await this.page.getByTestId("network-form-chain-id").fill(settings.chainId.toString());
222
- await this.page.getByTestId("network-form-ticker-input").fill(settings.currencySymbol);
223
- await this.page.getByTestId("test-add-rpc-drop-down").click();
224
- await this.page.getByRole("button", { name: "Add RPC URL" }).click();
225
- await this.page.getByTestId("rpc-url-input-test").fill(settings.rpc);
226
- await this.page.getByRole("button", { name: "Add URL" }).click();
227
- await this.page.getByRole("button", { name: "Save" }).click();
228
- if (switchNetwork) {
225
+ async connectToNetwork(settingsOrName) {
226
+ if (typeof settingsOrName !== "string") {
229
227
  await this.page.locator(".mm-picker-network").click();
230
- await this.page.getByTestId(settings.name).click();
228
+ await this.page.getByRole("button", { name: "Add a custom network" }).click();
229
+ await this.page.getByTestId("network-form-network-name").fill(settingsOrName.name);
230
+ await this.page.getByTestId("network-form-chain-id").fill(settingsOrName.chainId.toString());
231
+ await this.page.getByTestId("network-form-ticker-input").fill(settingsOrName.currencySymbol);
232
+ await this.page.getByTestId("test-add-rpc-drop-down").click();
233
+ await this.page.getByRole("button", { name: "Add RPC URL" }).click();
234
+ await this.page.getByTestId("rpc-url-input-test").fill(settingsOrName.rpc);
235
+ await this.page.getByRole("button", { name: "Add URL" }).click();
236
+ await this.page.getByRole("button", { name: "Save" }).click();
231
237
  }
238
+ await this.page.locator(".mm-picker-network").click();
239
+ await this.page.locator("text=Show test networks >> xpath=following-sibling::label").click();
240
+ await this.page.getByTestId(
241
+ typeof settingsOrName === "string" ? settingsOrName : settingsOrName.name
242
+ ).click();
232
243
  }
233
244
  // async approve() {
234
245
  // return this.usingNotificationPage((p) =>
package/dist/index.mjs CHANGED
@@ -28,7 +28,7 @@ var Backpack = class extends Wallet {
28
28
  maxAccountId = 0;
29
29
  async gotoOnboardPage() {
30
30
  await this.page.goto(
31
- `chrome-extension://${this.extensionId}/options.html?onboarding=true`
31
+ `chrome-extension://${this.extensionId}/onboarding.html`
32
32
  );
33
33
  await expect(this.page.getByText("Welcome to Backpack")).toBeVisible();
34
34
  }
@@ -41,7 +41,7 @@ var Backpack = class extends Wallet {
41
41
  this.maxAccountId++;
42
42
  this.currentAccountId = this.maxAccountId;
43
43
  await this.page.goto(
44
- `chrome-extension://${this.extensionId}/options.html?add-user-account=true`
44
+ `chrome-extension://${this.extensionId}/onboarding.html?add-user-account=true`
45
45
  );
46
46
  await this._importAccount(network, privateKey, false);
47
47
  }
@@ -81,18 +81,26 @@ var Backpack = class extends Wallet {
81
81
  return this.page.getByRole("button", { name: `A${this.currentAccountId}`, exact: true }).click();
82
82
  }
83
83
  async _importAccount(network, privateKey, isOnboard) {
84
- await this.page.getByRole("button", { name: "Import wallet" }).click();
85
- await this.page.getByRole("button", { name: network }).click();
86
- await this.page.getByRole("button", { name: "Import private key" }).click();
87
- await this.page.getByPlaceholder("Enter private key").fill(privateKey);
88
- await this.page.getByRole("button", { name: "Import" }).click();
84
+ {
85
+ await this.page.waitForTimeout(2e3);
86
+ if (await this.page.getByText("You're all good!").isVisible()) {
87
+ await this.page.getByLabel("Go back").click();
88
+ }
89
+ }
90
+ await this.page.getByRole("button", { name: "I agree to the terms" }).click();
91
+ await this.page.getByText("I already have a wallet").click();
92
+ await this.page.getByText("Show all networks").click();
93
+ await this.page.getByText(network).click();
94
+ await this.page.getByText("Private key").click();
95
+ await this.page.getByPlaceholder("Private key").fill(privateKey);
96
+ await this.page.waitForTimeout(1e3);
97
+ await this.page.getByText("Import", { exact: true }).click();
89
98
  if (isOnboard) {
90
- await this.page.getByPlaceholder("Password", { exact: true }).fill(this.defaultPassword);
91
- await this.page.getByPlaceholder("Confirm Password").fill(this.defaultPassword);
92
- await this.page.getByRole("checkbox").click();
93
- await this.page.getByRole("button", { name: "Next" }).click();
99
+ await this.page.getByRole("textbox").nth(1).fill(this.defaultPassword);
100
+ await this.page.getByRole("textbox").nth(2).fill(this.defaultPassword);
101
+ await this.page.getByText("Next", { exact: true }).click();
102
+ await expect(this.page.getByText("You're all good!")).toBeVisible();
94
103
  }
95
- await expect(this.page.getByText("You're all good!")).toBeVisible();
96
104
  await this.page.goto(`chrome-extension://${this.extensionId}/popup.html`);
97
105
  }
98
106
  };
@@ -180,21 +188,24 @@ var Metamask = class extends Wallet {
180
188
  await this.page.getByTestId("pin-extension-next").click();
181
189
  await this.page.getByTestId("pin-extension-done").click();
182
190
  }
183
- async connectToNetwork(settings, switchNetwork = true) {
184
- await this.page.locator(".mm-picker-network").click();
185
- await this.page.getByRole("button", { name: "Add a custom network" }).click();
186
- await this.page.getByTestId("network-form-network-name").fill(settings.name);
187
- await this.page.getByTestId("network-form-chain-id").fill(settings.chainId.toString());
188
- await this.page.getByTestId("network-form-ticker-input").fill(settings.currencySymbol);
189
- await this.page.getByTestId("test-add-rpc-drop-down").click();
190
- await this.page.getByRole("button", { name: "Add RPC URL" }).click();
191
- await this.page.getByTestId("rpc-url-input-test").fill(settings.rpc);
192
- await this.page.getByRole("button", { name: "Add URL" }).click();
193
- await this.page.getByRole("button", { name: "Save" }).click();
194
- if (switchNetwork) {
191
+ async connectToNetwork(settingsOrName) {
192
+ if (typeof settingsOrName !== "string") {
195
193
  await this.page.locator(".mm-picker-network").click();
196
- await this.page.getByTestId(settings.name).click();
194
+ await this.page.getByRole("button", { name: "Add a custom network" }).click();
195
+ await this.page.getByTestId("network-form-network-name").fill(settingsOrName.name);
196
+ await this.page.getByTestId("network-form-chain-id").fill(settingsOrName.chainId.toString());
197
+ await this.page.getByTestId("network-form-ticker-input").fill(settingsOrName.currencySymbol);
198
+ await this.page.getByTestId("test-add-rpc-drop-down").click();
199
+ await this.page.getByRole("button", { name: "Add RPC URL" }).click();
200
+ await this.page.getByTestId("rpc-url-input-test").fill(settingsOrName.rpc);
201
+ await this.page.getByRole("button", { name: "Add URL" }).click();
202
+ await this.page.getByRole("button", { name: "Save" }).click();
197
203
  }
204
+ await this.page.locator(".mm-picker-network").click();
205
+ await this.page.locator("text=Show test networks >> xpath=following-sibling::label").click();
206
+ await this.page.getByTestId(
207
+ typeof settingsOrName === "string" ? settingsOrName : settingsOrName.name
208
+ ).click();
198
209
  }
199
210
  // async approve() {
200
211
  // return this.usingNotificationPage((p) =>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "w3wallets",
3
3
  "description": "browser wallets for playwright",
4
- "version": "0.4.1",
4
+ "version": "0.5.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "homepage": "https://github.com/Maksandre/w3wallets",