w3wallets 0.4.2 → 0.5.1

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
@@ -67,7 +67,12 @@ 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
+ switchAccount(nameOrAddress: string): Promise<void>;
71
+ importAccount(privateKey: string): Promise<void>;
72
+ addAccount(accountName?: string): Promise<void>;
73
+ getAccountName(): Promise<string>;
74
+ connectToNetwork(networkName: string): Promise<void>;
75
+ connectToNetwork(settings: NetworkSettings): Promise<void>;
71
76
  approve(): Promise<void>;
72
77
  deny(): Promise<void>;
73
78
  private usingNotificationPage;
package/dist/index.d.ts CHANGED
@@ -67,7 +67,12 @@ 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
+ switchAccount(nameOrAddress: string): Promise<void>;
71
+ importAccount(privateKey: string): Promise<void>;
72
+ addAccount(accountName?: string): Promise<void>;
73
+ getAccountName(): Promise<string>;
74
+ connectToNetwork(networkName: string): Promise<void>;
75
+ connectToNetwork(settings: NetworkSettings): Promise<void>;
71
76
  approve(): Promise<void>;
72
77
  deny(): Promise<void>;
73
78
  private usingNotificationPage;
package/dist/index.js CHANGED
@@ -222,21 +222,53 @@ var Metamask = class extends Wallet {
222
222
  await this.page.getByTestId("pin-extension-next").click();
223
223
  await this.page.getByTestId("pin-extension-done").click();
224
224
  }
225
- async connectToNetwork(settings, switchNetwork = true) {
226
- await this.page.locator(".mm-picker-network").click();
227
- await this.page.getByRole("button", { name: "Add a custom network" }).click();
228
- await this.page.getByTestId("network-form-network-name").fill(settings.name);
229
- await this.page.getByTestId("network-form-chain-id").fill(settings.chainId.toString());
230
- await this.page.getByTestId("network-form-ticker-input").fill(settings.currencySymbol);
231
- await this.page.getByTestId("test-add-rpc-drop-down").click();
232
- await this.page.getByRole("button", { name: "Add RPC URL" }).click();
233
- await this.page.getByTestId("rpc-url-input-test").fill(settings.rpc);
234
- await this.page.getByRole("button", { name: "Add URL" }).click();
235
- await this.page.getByRole("button", { name: "Save" }).click();
236
- if (switchNetwork) {
225
+ async switchAccount(nameOrAddress) {
226
+ if (nameOrAddress.startsWith("0x"))
227
+ nameOrAddress = nameOrAddress.slice(0, 7);
228
+ await this.page.getByTestId("account-menu-icon").click();
229
+ await this.page.locator(".multichain-account-menu-popover__list--menu-item").filter({ hasText: nameOrAddress }).click();
230
+ }
231
+ async importAccount(privateKey) {
232
+ await this.page.getByTestId("account-menu-icon").click();
233
+ await this.page.getByTestId("multichain-account-menu-popover-action-button").click();
234
+ await this.page.getByTestId("multichain-account-menu-popover-add-imported-account").click();
235
+ await this.page.locator("#private-key-box").fill(privateKey);
236
+ await this.page.getByTestId("import-account-confirm-button").click();
237
+ }
238
+ async addAccount(accountName) {
239
+ await this.page.getByTestId("account-menu-icon").click();
240
+ await this.page.getByTestId("multichain-account-menu-popover-action-button").click();
241
+ await this.page.getByTestId("multichain-account-menu-popover-add-account").click();
242
+ if (accountName) {
243
+ await this.page.locator("#account-name").fill(accountName);
244
+ }
245
+ await this.page.getByTestId("submit-add-account-with-name").click();
246
+ }
247
+ async getAccountName() {
248
+ const accountSelect = this.page.getByTestId("account-menu-icon");
249
+ await (0, import_test3.expect)(accountSelect).toBeVisible();
250
+ const text = await accountSelect.textContent();
251
+ if (!text) throw Error("Cannot get account name");
252
+ return text;
253
+ }
254
+ async connectToNetwork(settingsOrName) {
255
+ if (typeof settingsOrName !== "string") {
237
256
  await this.page.locator(".mm-picker-network").click();
238
- await this.page.getByTestId(settings.name).click();
257
+ await this.page.getByRole("button", { name: "Add a custom network" }).click();
258
+ await this.page.getByTestId("network-form-network-name").fill(settingsOrName.name);
259
+ await this.page.getByTestId("network-form-chain-id").fill(settingsOrName.chainId.toString());
260
+ await this.page.getByTestId("network-form-ticker-input").fill(settingsOrName.currencySymbol);
261
+ await this.page.getByTestId("test-add-rpc-drop-down").click();
262
+ await this.page.getByRole("button", { name: "Add RPC URL" }).click();
263
+ await this.page.getByTestId("rpc-url-input-test").fill(settingsOrName.rpc);
264
+ await this.page.getByRole("button", { name: "Add URL" }).click();
265
+ await this.page.getByRole("button", { name: "Save" }).click();
239
266
  }
267
+ await this.page.locator(".mm-picker-network").click();
268
+ await this.page.locator("text=Show test networks >> xpath=following-sibling::label").click();
269
+ await this.page.getByTestId(
270
+ typeof settingsOrName === "string" ? settingsOrName : settingsOrName.name
271
+ ).click();
240
272
  }
241
273
  // async approve() {
242
274
  // return this.usingNotificationPage((p) =>
package/dist/index.mjs CHANGED
@@ -163,7 +163,7 @@ var PolkadotJS = class extends Wallet {
163
163
  };
164
164
 
165
165
  // src/metamask/metamask.ts
166
- import "@playwright/test";
166
+ import { expect as expect3 } from "@playwright/test";
167
167
  var Metamask = class extends Wallet {
168
168
  defaultPassword = "11111111";
169
169
  async gotoOnboardPage() {
@@ -188,21 +188,53 @@ var Metamask = class extends Wallet {
188
188
  await this.page.getByTestId("pin-extension-next").click();
189
189
  await this.page.getByTestId("pin-extension-done").click();
190
190
  }
191
- async connectToNetwork(settings, switchNetwork = true) {
192
- await this.page.locator(".mm-picker-network").click();
193
- await this.page.getByRole("button", { name: "Add a custom network" }).click();
194
- await this.page.getByTestId("network-form-network-name").fill(settings.name);
195
- await this.page.getByTestId("network-form-chain-id").fill(settings.chainId.toString());
196
- await this.page.getByTestId("network-form-ticker-input").fill(settings.currencySymbol);
197
- await this.page.getByTestId("test-add-rpc-drop-down").click();
198
- await this.page.getByRole("button", { name: "Add RPC URL" }).click();
199
- await this.page.getByTestId("rpc-url-input-test").fill(settings.rpc);
200
- await this.page.getByRole("button", { name: "Add URL" }).click();
201
- await this.page.getByRole("button", { name: "Save" }).click();
202
- if (switchNetwork) {
191
+ async switchAccount(nameOrAddress) {
192
+ if (nameOrAddress.startsWith("0x"))
193
+ nameOrAddress = nameOrAddress.slice(0, 7);
194
+ await this.page.getByTestId("account-menu-icon").click();
195
+ await this.page.locator(".multichain-account-menu-popover__list--menu-item").filter({ hasText: nameOrAddress }).click();
196
+ }
197
+ async importAccount(privateKey) {
198
+ await this.page.getByTestId("account-menu-icon").click();
199
+ await this.page.getByTestId("multichain-account-menu-popover-action-button").click();
200
+ await this.page.getByTestId("multichain-account-menu-popover-add-imported-account").click();
201
+ await this.page.locator("#private-key-box").fill(privateKey);
202
+ await this.page.getByTestId("import-account-confirm-button").click();
203
+ }
204
+ async addAccount(accountName) {
205
+ await this.page.getByTestId("account-menu-icon").click();
206
+ await this.page.getByTestId("multichain-account-menu-popover-action-button").click();
207
+ await this.page.getByTestId("multichain-account-menu-popover-add-account").click();
208
+ if (accountName) {
209
+ await this.page.locator("#account-name").fill(accountName);
210
+ }
211
+ await this.page.getByTestId("submit-add-account-with-name").click();
212
+ }
213
+ async getAccountName() {
214
+ const accountSelect = this.page.getByTestId("account-menu-icon");
215
+ await expect3(accountSelect).toBeVisible();
216
+ const text = await accountSelect.textContent();
217
+ if (!text) throw Error("Cannot get account name");
218
+ return text;
219
+ }
220
+ async connectToNetwork(settingsOrName) {
221
+ if (typeof settingsOrName !== "string") {
203
222
  await this.page.locator(".mm-picker-network").click();
204
- await this.page.getByTestId(settings.name).click();
223
+ await this.page.getByRole("button", { name: "Add a custom network" }).click();
224
+ await this.page.getByTestId("network-form-network-name").fill(settingsOrName.name);
225
+ await this.page.getByTestId("network-form-chain-id").fill(settingsOrName.chainId.toString());
226
+ await this.page.getByTestId("network-form-ticker-input").fill(settingsOrName.currencySymbol);
227
+ await this.page.getByTestId("test-add-rpc-drop-down").click();
228
+ await this.page.getByRole("button", { name: "Add RPC URL" }).click();
229
+ await this.page.getByTestId("rpc-url-input-test").fill(settingsOrName.rpc);
230
+ await this.page.getByRole("button", { name: "Add URL" }).click();
231
+ await this.page.getByRole("button", { name: "Save" }).click();
205
232
  }
233
+ await this.page.locator(".mm-picker-network").click();
234
+ await this.page.locator("text=Show test networks >> xpath=following-sibling::label").click();
235
+ await this.page.getByTestId(
236
+ typeof settingsOrName === "string" ? settingsOrName : settingsOrName.name
237
+ ).click();
206
238
  }
207
239
  // async approve() {
208
240
  // 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.2",
4
+ "version": "0.5.1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "homepage": "https://github.com/Maksandre/w3wallets",