w3wallets 0.8.3 → 0.9.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 CHANGED
@@ -76,8 +76,9 @@ declare class Metamask extends Wallet {
76
76
  importAccount(privateKey: string): Promise<void>;
77
77
  addAccount(accountName?: string): Promise<void>;
78
78
  getAccountName(): Promise<string>;
79
- connectToNetwork(networkName: string): Promise<void>;
80
- connectToNetwork(settings: NetworkSettings): Promise<void>;
79
+ connectToNetwork(networkName: string, networkType?: "Default" | "Custom"): Promise<void>;
80
+ addCustomNetwork(settings: NetworkSettings): Promise<void>;
81
+ enableTestNetworks(): Promise<void>;
81
82
  approve(): Promise<void>;
82
83
  deny(): Promise<void>;
83
84
  private usingNotificationPage;
package/dist/index.d.ts CHANGED
@@ -76,8 +76,9 @@ declare class Metamask extends Wallet {
76
76
  importAccount(privateKey: string): Promise<void>;
77
77
  addAccount(accountName?: string): Promise<void>;
78
78
  getAccountName(): Promise<string>;
79
- connectToNetwork(networkName: string): Promise<void>;
80
- connectToNetwork(settings: NetworkSettings): Promise<void>;
79
+ connectToNetwork(networkName: string, networkType?: "Default" | "Custom"): Promise<void>;
80
+ addCustomNetwork(settings: NetworkSettings): Promise<void>;
81
+ enableTestNetworks(): Promise<void>;
81
82
  approve(): Promise<void>;
82
83
  deny(): Promise<void>;
83
84
  private usingNotificationPage;
package/dist/index.js CHANGED
@@ -221,6 +221,7 @@ var Metamask = class extends Wallet {
221
221
  await this.page.getByTestId("terms-of-use-checkbox").click();
222
222
  await this.page.getByTestId("terms-of-use-agree-button").click();
223
223
  await this.page.getByTestId("onboarding-import-wallet").click();
224
+ await this.page.getByTestId("onboarding-import-with-srp-button").click();
224
225
  await this.page.getByTestId("srp-input-import__srp-note").pressSequentially(mnemonic);
225
226
  await this.page.getByTestId("import-srp-confirm").click();
226
227
  await this.page.getByTestId("create-password-new-input").fill(password);
@@ -263,24 +264,37 @@ var Metamask = class extends Wallet {
263
264
  if (!text) throw Error("Cannot get account name");
264
265
  return text;
265
266
  }
266
- async connectToNetwork(settingsOrName) {
267
- if (typeof settingsOrName !== "string") {
268
- await this.page.locator(".mm-picker-network").click();
269
- await this.page.getByRole("button", { name: "Add a custom network" }).click();
270
- await this.page.getByTestId("network-form-network-name").fill(settingsOrName.name);
271
- await this.page.getByTestId("network-form-chain-id").fill(settingsOrName.chainId.toString());
272
- await this.page.getByTestId("network-form-ticker-input").fill(settingsOrName.currencySymbol);
273
- await this.page.getByTestId("test-add-rpc-drop-down").click();
274
- await this.page.getByRole("button", { name: "Add RPC URL" }).click();
275
- await this.page.getByTestId("rpc-url-input-test").fill(settingsOrName.rpc);
276
- await this.page.getByRole("button", { name: "Add URL" }).click();
277
- await this.page.getByRole("button", { name: "Save" }).click();
267
+ async connectToNetwork(networkName, networkType = "Default") {
268
+ await this.page.getByTestId("sort-by-networks").click();
269
+ await this.page.getByRole("button", { name: networkType }).click();
270
+ const additionalNetwork = this.page.getByTestId("additional-network-item").getByText(networkName);
271
+ try {
272
+ await additionalNetwork.isEnabled({ timeout: 1e3 });
273
+ await additionalNetwork.click();
274
+ await this.page.getByTestId("confirmation-submit-button").click();
275
+ } catch (error) {
276
+ await this.page.getByText(networkName).click();
277
+ await this.page.getByTestId("modal-header-close-button").click();
278
278
  }
279
- await this.page.locator(".mm-picker-network").click();
279
+ }
280
+ async addCustomNetwork(settings) {
281
+ await this.page.getByTestId("account-options-menu-button").click();
282
+ await this.page.getByTestId("global-menu-networks").click();
283
+ await this.page.getByRole("button", { name: "Add a custom network" }).click();
284
+ await this.page.getByTestId("network-form-network-name").fill(settings.name);
285
+ await this.page.getByTestId("network-form-chain-id").fill(settings.chainId.toString());
286
+ await this.page.getByTestId("network-form-ticker-input").fill(settings.currencySymbol);
287
+ await this.page.getByTestId("test-add-rpc-drop-down").click();
288
+ await this.page.getByRole("button", { name: "Add RPC URL" }).click();
289
+ await this.page.getByTestId("rpc-url-input-test").fill(settings.rpc);
290
+ await this.page.getByRole("button", { name: "Add URL" }).click();
291
+ await this.page.getByRole("button", { name: "Save" }).click();
292
+ }
293
+ async enableTestNetworks() {
294
+ await this.page.getByTestId("account-options-menu-button").click();
295
+ await this.page.getByTestId("global-menu-networks").click();
280
296
  await this.page.locator("text=Show test networks >> xpath=following-sibling::label").click();
281
- await this.page.getByTestId(
282
- typeof settingsOrName === "string" ? settingsOrName : settingsOrName.name
283
- ).click();
297
+ await this.page.keyboard.press("Escape");
284
298
  }
285
299
  async approve() {
286
300
  const p = await this.page.context().newPage();
package/dist/index.mjs CHANGED
@@ -187,6 +187,7 @@ var Metamask = class extends Wallet {
187
187
  await this.page.getByTestId("terms-of-use-checkbox").click();
188
188
  await this.page.getByTestId("terms-of-use-agree-button").click();
189
189
  await this.page.getByTestId("onboarding-import-wallet").click();
190
+ await this.page.getByTestId("onboarding-import-with-srp-button").click();
190
191
  await this.page.getByTestId("srp-input-import__srp-note").pressSequentially(mnemonic);
191
192
  await this.page.getByTestId("import-srp-confirm").click();
192
193
  await this.page.getByTestId("create-password-new-input").fill(password);
@@ -229,24 +230,37 @@ var Metamask = class extends Wallet {
229
230
  if (!text) throw Error("Cannot get account name");
230
231
  return text;
231
232
  }
232
- async connectToNetwork(settingsOrName) {
233
- if (typeof settingsOrName !== "string") {
234
- await this.page.locator(".mm-picker-network").click();
235
- await this.page.getByRole("button", { name: "Add a custom network" }).click();
236
- await this.page.getByTestId("network-form-network-name").fill(settingsOrName.name);
237
- await this.page.getByTestId("network-form-chain-id").fill(settingsOrName.chainId.toString());
238
- await this.page.getByTestId("network-form-ticker-input").fill(settingsOrName.currencySymbol);
239
- await this.page.getByTestId("test-add-rpc-drop-down").click();
240
- await this.page.getByRole("button", { name: "Add RPC URL" }).click();
241
- await this.page.getByTestId("rpc-url-input-test").fill(settingsOrName.rpc);
242
- await this.page.getByRole("button", { name: "Add URL" }).click();
243
- await this.page.getByRole("button", { name: "Save" }).click();
233
+ async connectToNetwork(networkName, networkType = "Default") {
234
+ await this.page.getByTestId("sort-by-networks").click();
235
+ await this.page.getByRole("button", { name: networkType }).click();
236
+ const additionalNetwork = this.page.getByTestId("additional-network-item").getByText(networkName);
237
+ try {
238
+ await additionalNetwork.isEnabled({ timeout: 1e3 });
239
+ await additionalNetwork.click();
240
+ await this.page.getByTestId("confirmation-submit-button").click();
241
+ } catch (error) {
242
+ await this.page.getByText(networkName).click();
243
+ await this.page.getByTestId("modal-header-close-button").click();
244
244
  }
245
- await this.page.locator(".mm-picker-network").click();
245
+ }
246
+ async addCustomNetwork(settings) {
247
+ await this.page.getByTestId("account-options-menu-button").click();
248
+ await this.page.getByTestId("global-menu-networks").click();
249
+ await this.page.getByRole("button", { name: "Add a custom network" }).click();
250
+ await this.page.getByTestId("network-form-network-name").fill(settings.name);
251
+ await this.page.getByTestId("network-form-chain-id").fill(settings.chainId.toString());
252
+ await this.page.getByTestId("network-form-ticker-input").fill(settings.currencySymbol);
253
+ await this.page.getByTestId("test-add-rpc-drop-down").click();
254
+ await this.page.getByRole("button", { name: "Add RPC URL" }).click();
255
+ await this.page.getByTestId("rpc-url-input-test").fill(settings.rpc);
256
+ await this.page.getByRole("button", { name: "Add URL" }).click();
257
+ await this.page.getByRole("button", { name: "Save" }).click();
258
+ }
259
+ async enableTestNetworks() {
260
+ await this.page.getByTestId("account-options-menu-button").click();
261
+ await this.page.getByTestId("global-menu-networks").click();
246
262
  await this.page.locator("text=Show test networks >> xpath=following-sibling::label").click();
247
- await this.page.getByTestId(
248
- typeof settingsOrName === "string" ? settingsOrName : settingsOrName.name
249
- ).click();
263
+ await this.page.keyboard.press("Escape");
250
264
  }
251
265
  async approve() {
252
266
  const p = await this.page.context().newPage();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "w3wallets",
3
3
  "description": "browser wallets for playwright",
4
- "version": "0.8.3",
4
+ "version": "0.9.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "homepage": "https://github.com/Maksandre/w3wallets",