w3wallets 0.5.3 → 0.7.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
@@ -13,7 +13,7 @@ interface IWallet {
13
13
  }
14
14
 
15
15
  declare abstract class Wallet implements IWallet {
16
- protected page: Page;
16
+ page: Page;
17
17
  protected extensionId: string;
18
18
  constructor(page: Page, extensionId: string);
19
19
  abstract gotoOnboardPage(): Promise<void>;
@@ -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
@@ -13,7 +13,7 @@ interface IWallet {
13
13
  }
14
14
 
15
15
  declare abstract class Wallet implements IWallet {
16
- protected page: Page;
16
+ page: Page;
17
17
  protected extensionId: string;
18
18
  constructor(page: Page, extensionId: string);
19
19
  abstract gotoOnboardPage(): Promise<void>;
@@ -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,11 +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({ has: this.page.getByTestId("second-currency-display").filter({ hasText: network }) }).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
+ }
232
242
  }
233
243
  async importAccount(privateKey) {
234
244
  await this.page.getByTestId("account-menu-icon").click();
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,11 +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({ has: this.page.getByTestId("second-currency-display").filter({ hasText: network }) }).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
+ }
198
208
  }
199
209
  async importAccount(privateKey) {
200
210
  await this.page.getByTestId("account-menu-icon").click();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "w3wallets",
3
3
  "description": "browser wallets for playwright",
4
- "version": "0.5.3",
4
+ "version": "0.7.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "homepage": "https://github.com/Maksandre/w3wallets",