w3wallets 0.6.0 → 0.8.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
@@ -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
- switchAccount(nameOrAddress: string, network?: "ETH" | "SOL"): Promise<void>;
70
+ switchAccount(accountName: {
71
+ name: string;
72
+ }): Promise<void>;
73
+ switchAccount(accountAddress: {
74
+ address: string;
75
+ }): Promise<void>;
71
76
  importAccount(privateKey: string): Promise<void>;
72
77
  addAccount(accountName?: string): Promise<void>;
73
78
  getAccountName(): Promise<string>;
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
- switchAccount(nameOrAddress: string, network?: "ETH" | "SOL"): Promise<void>;
70
+ switchAccount(accountName: {
71
+ name: string;
72
+ }): Promise<void>;
73
+ switchAccount(accountAddress: {
74
+ address: string;
75
+ }): Promise<void>;
71
76
  importAccount(privateKey: string): Promise<void>;
72
77
  addAccount(accountName?: string): Promise<void>;
73
78
  getAccountName(): Promise<string>;
package/dist/index.js CHANGED
@@ -136,6 +136,7 @@ var Backpack = class extends Wallet {
136
136
  await (0, import_test.expect)(this.page.getByText("You're all good!")).toBeVisible();
137
137
  }
138
138
  await this.page.goto(`chrome-extension://${this.extensionId}/popup.html`);
139
+ await this.page.getByTestId("AccountBalanceRoundedIcon").waitFor({ state: "visible" });
139
140
  }
140
141
  };
141
142
 
@@ -198,6 +199,13 @@ var PolkadotJS = class extends Wallet {
198
199
 
199
200
  // src/metamask/metamask.ts
200
201
  var import_test3 = require("@playwright/test");
202
+
203
+ // tests/utils/address.ts
204
+ var shortenAddress = (address) => {
205
+ return `${address.slice(0, 7)}...${address.slice(-5)}`;
206
+ };
207
+
208
+ // src/metamask/metamask.ts
201
209
  var Metamask = class extends Wallet {
202
210
  defaultPassword = "11111111";
203
211
  async gotoOnboardPage() {
@@ -224,13 +232,13 @@ var Metamask = class extends Wallet {
224
232
  await this.page.waitForTimeout(1e3);
225
233
  await this.clickTopRightCornerToCloseAllTheMarketingBullshit();
226
234
  }
227
- async switchAccount(nameOrAddress, network = "ETH") {
228
- if (nameOrAddress.startsWith("0x"))
229
- nameOrAddress = nameOrAddress.slice(0, 7);
235
+ async switchAccount(accountNameOrAddress) {
230
236
  await this.page.getByTestId("account-menu-icon").click();
231
- await this.page.locator(".multichain-account-menu-popover__list--menu-item").filter({ hasText: nameOrAddress }).filter({
232
- has: this.page.getByTestId("second-currency-display").filter({ hasText: network })
233
- }).click();
237
+ if ("name" in accountNameOrAddress) {
238
+ await this.page.locator(".multichain-account-list-item__account-name").getByRole("button", { name: accountNameOrAddress.name, exact: true }).click();
239
+ } else {
240
+ await this.page.getByTestId("account-list-address").filter({ hasText: shortenAddress(accountNameOrAddress.address) }).click();
241
+ }
234
242
  }
235
243
  async importAccount(privateKey) {
236
244
  await this.page.getByTestId("account-menu-icon").click();
@@ -274,20 +282,11 @@ var Metamask = class extends Wallet {
274
282
  typeof settingsOrName === "string" ? settingsOrName : settingsOrName.name
275
283
  ).click();
276
284
  }
277
- // async approve() {
278
- // return this.usingNotificationPage((p) =>
279
- // p
280
- // .locator(
281
- // '[data-test-id="confirm-footer-button"], [data-test-id="confirm-btn"]',
282
- // )
283
- // .click(),
284
- // );
285
- // }
286
285
  async approve() {
287
286
  const p = await this.page.context().newPage();
288
287
  await p.goto(`chrome-extension://${this.extensionId}/notification.html`);
289
288
  await p.locator(
290
- '[data-testid="confirm-footer-button"], [data-testid="confirm-btn"]'
289
+ '[data-testid="confirm-footer-button"], [data-testid="confirm-btn"], [data-testid="page-container-footer-next"], [data-testid="confirmation-submit-button"]'
291
290
  ).click();
292
291
  await p.close();
293
292
  }
package/dist/index.mjs CHANGED
@@ -102,6 +102,7 @@ var Backpack = class extends Wallet {
102
102
  await expect(this.page.getByText("You're all good!")).toBeVisible();
103
103
  }
104
104
  await this.page.goto(`chrome-extension://${this.extensionId}/popup.html`);
105
+ await this.page.getByTestId("AccountBalanceRoundedIcon").waitFor({ state: "visible" });
105
106
  }
106
107
  };
107
108
 
@@ -164,6 +165,13 @@ var PolkadotJS = class extends Wallet {
164
165
 
165
166
  // src/metamask/metamask.ts
166
167
  import { expect as expect3 } from "@playwright/test";
168
+
169
+ // tests/utils/address.ts
170
+ var shortenAddress = (address) => {
171
+ return `${address.slice(0, 7)}...${address.slice(-5)}`;
172
+ };
173
+
174
+ // src/metamask/metamask.ts
167
175
  var Metamask = class extends Wallet {
168
176
  defaultPassword = "11111111";
169
177
  async gotoOnboardPage() {
@@ -190,13 +198,13 @@ var Metamask = class extends Wallet {
190
198
  await this.page.waitForTimeout(1e3);
191
199
  await this.clickTopRightCornerToCloseAllTheMarketingBullshit();
192
200
  }
193
- async switchAccount(nameOrAddress, network = "ETH") {
194
- if (nameOrAddress.startsWith("0x"))
195
- nameOrAddress = nameOrAddress.slice(0, 7);
201
+ async switchAccount(accountNameOrAddress) {
196
202
  await this.page.getByTestId("account-menu-icon").click();
197
- await this.page.locator(".multichain-account-menu-popover__list--menu-item").filter({ hasText: nameOrAddress }).filter({
198
- has: this.page.getByTestId("second-currency-display").filter({ hasText: network })
199
- }).click();
203
+ if ("name" in accountNameOrAddress) {
204
+ await this.page.locator(".multichain-account-list-item__account-name").getByRole("button", { name: accountNameOrAddress.name, exact: true }).click();
205
+ } else {
206
+ await this.page.getByTestId("account-list-address").filter({ hasText: shortenAddress(accountNameOrAddress.address) }).click();
207
+ }
200
208
  }
201
209
  async importAccount(privateKey) {
202
210
  await this.page.getByTestId("account-menu-icon").click();
@@ -240,20 +248,11 @@ var Metamask = class extends Wallet {
240
248
  typeof settingsOrName === "string" ? settingsOrName : settingsOrName.name
241
249
  ).click();
242
250
  }
243
- // async approve() {
244
- // return this.usingNotificationPage((p) =>
245
- // p
246
- // .locator(
247
- // '[data-test-id="confirm-footer-button"], [data-test-id="confirm-btn"]',
248
- // )
249
- // .click(),
250
- // );
251
- // }
252
251
  async approve() {
253
252
  const p = await this.page.context().newPage();
254
253
  await p.goto(`chrome-extension://${this.extensionId}/notification.html`);
255
254
  await p.locator(
256
- '[data-testid="confirm-footer-button"], [data-testid="confirm-btn"]'
255
+ '[data-testid="confirm-footer-button"], [data-testid="confirm-btn"], [data-testid="page-container-footer-next"], [data-testid="confirmation-submit-button"]'
257
256
  ).click();
258
257
  await p.close();
259
258
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "w3wallets",
3
3
  "description": "browser wallets for playwright",
4
- "version": "0.6.0",
4
+ "version": "0.8.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "homepage": "https://github.com/Maksandre/w3wallets",