w3wallets 0.8.2 → 0.8.4
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 +4 -4
- package/dist/index.js +16 -10
- package/dist/index.mjs +16 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ npm install -D w3wallets
|
|
|
15
15
|
|
|
16
16
|
## Getting Started
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
`MetaMask`, `Backpack`, and `Polkadot{.js}` wallets are currently supported.
|
|
19
19
|
|
|
20
20
|
<p align="center">
|
|
21
21
|
<img src="https://images.ctfassets.net/clixtyxoaeas/1ezuBGezqfIeifWdVtwU4c/d970d4cdf13b163efddddd5709164d2e/MetaMask-icon-Fox.svg" alt="Metamask Logo" width="60"/>
|
|
@@ -31,9 +31,9 @@ npx w3wallets backpack polkadotJS
|
|
|
31
31
|
|
|
32
32
|
The unzipped files should be stored in the `.w3wallets/<wallet-name>` directory. Add them to `.gitignore`.
|
|
33
33
|
|
|
34
|
-
#### 2. Wrap your fixture `withWallets`
|
|
34
|
+
#### 2. Wrap your fixture with `withWallets`
|
|
35
35
|
|
|
36
|
-
Install
|
|
36
|
+
Install the required wallets into Chromium using `withWallets`.
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
39
|
// your-fixture.ts
|
|
@@ -57,7 +57,7 @@ export { expect } from "@playwright/test";
|
|
|
57
57
|
|
|
58
58
|
#### 3. Use the installed wallets in tests
|
|
59
59
|
|
|
60
|
-
Most
|
|
60
|
+
Most commonly, 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.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);
|
|
@@ -230,10 +231,7 @@ var Metamask = class extends Wallet {
|
|
|
230
231
|
await this.page.getByTestId("metametrics-no-thanks").click();
|
|
231
232
|
await this.page.getByTestId("onboarding-complete-done").click();
|
|
232
233
|
await this.page.getByTestId("pin-extension-done").click();
|
|
233
|
-
await this.page.getByTestId("
|
|
234
|
-
await this.page.getByTestId("unlock-submit").click();
|
|
235
|
-
await this.page.waitForTimeout(1e3);
|
|
236
|
-
await this.clickTopRightCornerToCloseAllTheMarketingBullshit();
|
|
234
|
+
await this.page.getByTestId("not-now-button").click();
|
|
237
235
|
}
|
|
238
236
|
async switchAccount(accountNameOrAddress) {
|
|
239
237
|
await this.page.getByTestId("account-menu-icon").click();
|
|
@@ -268,7 +266,8 @@ var Metamask = class extends Wallet {
|
|
|
268
266
|
}
|
|
269
267
|
async connectToNetwork(settingsOrName) {
|
|
270
268
|
if (typeof settingsOrName !== "string") {
|
|
271
|
-
await this.page.
|
|
269
|
+
await this.page.getByTestId("account-options-menu-button").click();
|
|
270
|
+
await this.page.getByTestId("global-menu-networks").click();
|
|
272
271
|
await this.page.getByRole("button", { name: "Add a custom network" }).click();
|
|
273
272
|
await this.page.getByTestId("network-form-network-name").fill(settingsOrName.name);
|
|
274
273
|
await this.page.getByTestId("network-form-chain-id").fill(settingsOrName.chainId.toString());
|
|
@@ -278,12 +277,19 @@ var Metamask = class extends Wallet {
|
|
|
278
277
|
await this.page.getByTestId("rpc-url-input-test").fill(settingsOrName.rpc);
|
|
279
278
|
await this.page.getByRole("button", { name: "Add URL" }).click();
|
|
280
279
|
await this.page.getByRole("button", { name: "Save" }).click();
|
|
280
|
+
} else {
|
|
281
|
+
await this.page.getByTestId("sort-by-networks").click();
|
|
282
|
+
await this.page.getByRole("button", { name: "Default" }).click();
|
|
283
|
+
const additionalNetwork = this.page.getByTestId("additional-network-item").getByText(settingsOrName);
|
|
284
|
+
try {
|
|
285
|
+
await additionalNetwork.isEnabled({ timeout: 1e3 });
|
|
286
|
+
await additionalNetwork.click();
|
|
287
|
+
await this.page.getByTestId("confirmation-submit-button").click();
|
|
288
|
+
} catch (error) {
|
|
289
|
+
await this.page.getByText(settingsOrName).click();
|
|
290
|
+
await this.page.getByTestId("modal-header-close-button").click();
|
|
291
|
+
}
|
|
281
292
|
}
|
|
282
|
-
await this.page.locator(".mm-picker-network").click();
|
|
283
|
-
await this.page.locator("text=Show test networks >> xpath=following-sibling::label").click();
|
|
284
|
-
await this.page.getByTestId(
|
|
285
|
-
typeof settingsOrName === "string" ? settingsOrName : settingsOrName.name
|
|
286
|
-
).click();
|
|
287
293
|
}
|
|
288
294
|
async approve() {
|
|
289
295
|
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);
|
|
@@ -196,10 +197,7 @@ var Metamask = class extends Wallet {
|
|
|
196
197
|
await this.page.getByTestId("metametrics-no-thanks").click();
|
|
197
198
|
await this.page.getByTestId("onboarding-complete-done").click();
|
|
198
199
|
await this.page.getByTestId("pin-extension-done").click();
|
|
199
|
-
await this.page.getByTestId("
|
|
200
|
-
await this.page.getByTestId("unlock-submit").click();
|
|
201
|
-
await this.page.waitForTimeout(1e3);
|
|
202
|
-
await this.clickTopRightCornerToCloseAllTheMarketingBullshit();
|
|
200
|
+
await this.page.getByTestId("not-now-button").click();
|
|
203
201
|
}
|
|
204
202
|
async switchAccount(accountNameOrAddress) {
|
|
205
203
|
await this.page.getByTestId("account-menu-icon").click();
|
|
@@ -234,7 +232,8 @@ var Metamask = class extends Wallet {
|
|
|
234
232
|
}
|
|
235
233
|
async connectToNetwork(settingsOrName) {
|
|
236
234
|
if (typeof settingsOrName !== "string") {
|
|
237
|
-
await this.page.
|
|
235
|
+
await this.page.getByTestId("account-options-menu-button").click();
|
|
236
|
+
await this.page.getByTestId("global-menu-networks").click();
|
|
238
237
|
await this.page.getByRole("button", { name: "Add a custom network" }).click();
|
|
239
238
|
await this.page.getByTestId("network-form-network-name").fill(settingsOrName.name);
|
|
240
239
|
await this.page.getByTestId("network-form-chain-id").fill(settingsOrName.chainId.toString());
|
|
@@ -244,12 +243,19 @@ var Metamask = class extends Wallet {
|
|
|
244
243
|
await this.page.getByTestId("rpc-url-input-test").fill(settingsOrName.rpc);
|
|
245
244
|
await this.page.getByRole("button", { name: "Add URL" }).click();
|
|
246
245
|
await this.page.getByRole("button", { name: "Save" }).click();
|
|
246
|
+
} else {
|
|
247
|
+
await this.page.getByTestId("sort-by-networks").click();
|
|
248
|
+
await this.page.getByRole("button", { name: "Default" }).click();
|
|
249
|
+
const additionalNetwork = this.page.getByTestId("additional-network-item").getByText(settingsOrName);
|
|
250
|
+
try {
|
|
251
|
+
await additionalNetwork.isEnabled({ timeout: 1e3 });
|
|
252
|
+
await additionalNetwork.click();
|
|
253
|
+
await this.page.getByTestId("confirmation-submit-button").click();
|
|
254
|
+
} catch (error) {
|
|
255
|
+
await this.page.getByText(settingsOrName).click();
|
|
256
|
+
await this.page.getByTestId("modal-header-close-button").click();
|
|
257
|
+
}
|
|
247
258
|
}
|
|
248
|
-
await this.page.locator(".mm-picker-network").click();
|
|
249
|
-
await this.page.locator("text=Show test networks >> xpath=following-sibling::label").click();
|
|
250
|
-
await this.page.getByTestId(
|
|
251
|
-
typeof settingsOrName === "string" ? settingsOrName : settingsOrName.name
|
|
252
|
-
).click();
|
|
253
259
|
}
|
|
254
260
|
async approve() {
|
|
255
261
|
const p = await this.page.context().newPage();
|