w3wallets 0.10.2 → 1.0.0-beta.2
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 +69 -21
- package/dist/index.d.mts +128 -56
- package/dist/index.d.ts +128 -56
- package/dist/index.js +272 -305
- package/dist/index.mjs +263 -302
- package/package.json +5 -8
- package/src/scripts/download.js +361 -68
package/README.md
CHANGED
|
@@ -15,21 +15,56 @@ npm install -D w3wallets
|
|
|
15
15
|
|
|
16
16
|
## Getting Started
|
|
17
17
|
|
|
18
|
-
`MetaMask
|
|
18
|
+
`MetaMask` 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"/>
|
|
22
|
-
<img src="https://raw.githubusercontent.com/coral-xyz/backpack/refs/heads/master/assets/backpack.png" alt="Backpack Logo" width="60"/>
|
|
23
22
|
<img src="https://polkadot.js.org/logo.svg" alt="Polkadot JS Logo" width="60"/>
|
|
24
23
|
</p>
|
|
25
24
|
|
|
26
25
|
#### 1. Download wallets
|
|
27
26
|
|
|
28
27
|
```sh
|
|
29
|
-
npx w3wallets
|
|
28
|
+
npx w3wallets metamask polkadotjs
|
|
30
29
|
```
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
Short aliases are also supported:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npx w3wallets mm pjs
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The unzipped files are stored in the `.w3wallets/<wallet-name>` directory. Add `.w3wallets` to `.gitignore`.
|
|
38
|
+
|
|
39
|
+
<details>
|
|
40
|
+
<summary>CLI Options</summary>
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
USAGE:
|
|
44
|
+
npx w3wallets [OPTIONS] <targets...>
|
|
45
|
+
|
|
46
|
+
TARGETS:
|
|
47
|
+
Alias name Known wallet alias (metamask, polkadotjs)
|
|
48
|
+
Short alias Short form (mm, pjs)
|
|
49
|
+
Extension ID 32-character Chrome extension ID
|
|
50
|
+
URL Chrome Web Store URL
|
|
51
|
+
|
|
52
|
+
OPTIONS:
|
|
53
|
+
-h, --help Show help message
|
|
54
|
+
-l, --list List available wallet aliases
|
|
55
|
+
-o, --output Output directory (default: .w3wallets)
|
|
56
|
+
-f, --force Force re-download even if already exists
|
|
57
|
+
--debug Save raw .crx file for debugging
|
|
58
|
+
|
|
59
|
+
EXAMPLES:
|
|
60
|
+
npx w3wallets metamask # Download MetaMask
|
|
61
|
+
npx w3wallets mm pjs # Download all wallets (short)
|
|
62
|
+
npx w3wallets --list # List available aliases
|
|
63
|
+
npx w3wallets -o ./extensions metamask # Custom output directory
|
|
64
|
+
npx w3wallets --force mm # Force re-download
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
</details>
|
|
33
68
|
|
|
34
69
|
#### 2. Wrap your fixture with `withWallets`
|
|
35
70
|
|
|
@@ -37,20 +72,10 @@ Install the required wallets into Chromium using `withWallets`.
|
|
|
37
72
|
|
|
38
73
|
```ts
|
|
39
74
|
// your-fixture.ts
|
|
40
|
-
import { withWallets } from "w3wallets";
|
|
75
|
+
import { withWallets, metamask, polkadotJS } from "w3wallets";
|
|
41
76
|
import { test as base } from "@playwright/test";
|
|
42
77
|
|
|
43
|
-
export const test = withWallets(
|
|
44
|
-
base,
|
|
45
|
-
"backpack",
|
|
46
|
-
"polkadotJS",
|
|
47
|
-
).extend<BaseFixture>({
|
|
48
|
-
magic: (_, use) => use(42),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
type BaseFixture = {
|
|
52
|
-
magic: number;
|
|
53
|
-
};
|
|
78
|
+
export const test = withWallets(base, metamask, polkadotJS);
|
|
54
79
|
|
|
55
80
|
export { expect } from "@playwright/test";
|
|
56
81
|
```
|
|
@@ -64,12 +89,35 @@ Most commonly, you will use the following methods:
|
|
|
64
89
|
3. `deny`: for actions that reject or cancel operations
|
|
65
90
|
|
|
66
91
|
```ts
|
|
67
|
-
import { test } from "./your-fixture";
|
|
92
|
+
import { test, expect } from "./your-fixture";
|
|
68
93
|
|
|
69
|
-
test("Can
|
|
70
|
-
const
|
|
71
|
-
"
|
|
94
|
+
test("Can connect MetaMask to dApp", async ({ page, metamask }) => {
|
|
95
|
+
const mnemonic =
|
|
96
|
+
"set your seed phrase test test test test test test test junk";
|
|
72
97
|
|
|
73
|
-
await
|
|
98
|
+
await metamask.onboard(mnemonic);
|
|
99
|
+
await page.goto("https://your-dapp.com");
|
|
100
|
+
|
|
101
|
+
await page.getByRole("button", { name: "Connect Wallet" }).click();
|
|
102
|
+
await metamask.approve();
|
|
103
|
+
|
|
104
|
+
await expect(page.getByText("Connected")).toBeVisible();
|
|
74
105
|
});
|
|
75
106
|
```
|
|
107
|
+
|
|
108
|
+
## Configuration
|
|
109
|
+
|
|
110
|
+
Configure library behavior via environment variables:
|
|
111
|
+
|
|
112
|
+
| Variable | Description | Default |
|
|
113
|
+
| -------------------------- | ------------------------------------------------------------------------- | ----------- |
|
|
114
|
+
| `W3WALLETS_ACTION_TIMEOUT` | Timeout (ms) for all wallet actions (click, fill, navigation, assertions) | `undefined` |
|
|
115
|
+
|
|
116
|
+
Example:
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
# In .env or CI environment
|
|
120
|
+
W3WALLETS_ACTION_TIMEOUT=60000
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
This only affects w3wallets library code. Your own Playwright configuration remains independent.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,43 +1,130 @@
|
|
|
1
1
|
import * as playwright_test from 'playwright/test';
|
|
2
2
|
import { Page, test, BrowserContext } from '@playwright/test';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Represents the supported network types for the BackPack application.
|
|
6
|
-
*/
|
|
7
|
-
type BackPackNetwork = "Solana" | "Eclipse" | "Ethereum" | "Polygon" | "Base" | "Arbitrum" | "Optimism";
|
|
8
|
-
|
|
9
|
-
type WalletName = "backpack" | "polkadotJS" | "metamask";
|
|
10
|
-
type NoDuplicates<T extends readonly unknown[], Acc extends readonly unknown[] = []> = T extends [infer Head, ...infer Tail] ? Head extends Acc[number] ? never : [Head, ...NoDuplicates<Tail, [...Acc, Head]>] : T;
|
|
11
4
|
interface IWallet {
|
|
5
|
+
readonly page: Page;
|
|
12
6
|
gotoOnboardPage(): Promise<void>;
|
|
7
|
+
approve(): Promise<void>;
|
|
8
|
+
deny(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configuration object for a wallet.
|
|
12
|
+
*/
|
|
13
|
+
interface WalletConfig<TName extends string = string, TWallet extends IWallet = IWallet> {
|
|
14
|
+
/** Unique wallet identifier, used as fixture name */
|
|
15
|
+
name: TName;
|
|
16
|
+
/** Directory name under .w3wallets/ where extension is stored */
|
|
17
|
+
extensionDir: string;
|
|
18
|
+
/** Wallet class constructor */
|
|
19
|
+
WalletClass: new (page: Page, extensionId: string) => TWallet;
|
|
20
|
+
/**
|
|
21
|
+
* Chrome extension ID. If not provided, it will be derived from
|
|
22
|
+
* the manifest.json `key` field. Required for custom extensions
|
|
23
|
+
* that don't have a `key` field in their manifest.
|
|
24
|
+
*/
|
|
25
|
+
extensionId?: string;
|
|
13
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a wallet configuration object.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const myWallet = createWallet({
|
|
33
|
+
* name: "myWallet",
|
|
34
|
+
* extensionDir: "my-wallet",
|
|
35
|
+
* WalletClass: MyWalletClass,
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function createWallet<TName extends string, TWallet extends IWallet>(config: WalletConfig<TName, TWallet>): WalletConfig<TName, TWallet>;
|
|
40
|
+
/**
|
|
41
|
+
* Extracts fixture name from a wallet config.
|
|
42
|
+
*/
|
|
43
|
+
type WalletConfigName<T> = T extends WalletConfig<infer N, IWallet> ? N : never;
|
|
44
|
+
/**
|
|
45
|
+
* Extracts wallet class instance type from a wallet config.
|
|
46
|
+
*/
|
|
47
|
+
type WalletConfigInstance<T> = T extends WalletConfig<string, infer W> ? W : never;
|
|
48
|
+
/**
|
|
49
|
+
* Builds fixture types from an array of wallet configs.
|
|
50
|
+
*/
|
|
51
|
+
type WalletFixturesFromConfigs<T extends readonly WalletConfig[]> = {
|
|
52
|
+
[K in T[number] as WalletConfigName<K>]: WalletConfigInstance<K>;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Supported blockchain networks.
|
|
56
|
+
* Common networks are listed for autocomplete, but any string is accepted.
|
|
57
|
+
*/
|
|
58
|
+
type Network = "Solana" | "Eclipse" | "Ethereum" | "Polygon" | "Base" | "Arbitrum" | "Optimism" | (string & {});
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Extends Playwright test with wallet fixtures.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { withWallets, metamask, polkadotJS } from "w3wallets";
|
|
66
|
+
*
|
|
67
|
+
* const test = withWallets(base, metamask, polkadotJS);
|
|
68
|
+
*
|
|
69
|
+
* test("can connect", async ({ metamask, polkadotJS }) => {
|
|
70
|
+
* await metamask.onboard(mnemonic);
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function withWallets<const T extends readonly WalletConfig[]>(test: typeof test, ...wallets: T): playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & WalletFixturesFromConfigs<T> & {
|
|
75
|
+
context: BrowserContext;
|
|
76
|
+
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
14
77
|
|
|
15
78
|
declare abstract class Wallet implements IWallet {
|
|
16
|
-
page: Page;
|
|
17
|
-
protected extensionId: string;
|
|
79
|
+
readonly page: Page;
|
|
80
|
+
protected readonly extensionId: string;
|
|
18
81
|
constructor(page: Page, extensionId: string);
|
|
19
82
|
abstract gotoOnboardPage(): Promise<void>;
|
|
83
|
+
abstract approve(): Promise<void>;
|
|
84
|
+
abstract deny(): Promise<void>;
|
|
20
85
|
}
|
|
21
86
|
|
|
22
|
-
|
|
87
|
+
type NetworkSettings = {
|
|
88
|
+
name: string;
|
|
89
|
+
rpc: string;
|
|
90
|
+
chainId: number;
|
|
91
|
+
currencySymbol: string;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
declare class Metamask extends Wallet {
|
|
23
95
|
private defaultPassword;
|
|
24
|
-
private currentAccountId;
|
|
25
|
-
private maxAccountId;
|
|
26
96
|
gotoOnboardPage(): Promise<void>;
|
|
27
|
-
onboard(network: BackPackNetwork, privateKey: string): Promise<void>;
|
|
28
|
-
addAccount(network: BackPackNetwork, privateKey: string): Promise<void>;
|
|
29
97
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param
|
|
98
|
+
* Onboard MetaMask with a mnemonic phrase
|
|
99
|
+
* @param mnemonic - 12 or 24 word recovery phrase
|
|
100
|
+
* @param password - Optional password (defaults to TestPassword123!)
|
|
32
101
|
*/
|
|
33
|
-
|
|
34
|
-
unlock(): Promise<void>;
|
|
35
|
-
setRPC(network: BackPackNetwork, rpc: string): Promise<void>;
|
|
36
|
-
ignoreAndProceed(): Promise<void>;
|
|
102
|
+
onboard(mnemonic: string, password?: string): Promise<void>;
|
|
37
103
|
approve(): Promise<void>;
|
|
38
104
|
deny(): Promise<void>;
|
|
39
|
-
|
|
40
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Lock the MetaMask wallet
|
|
107
|
+
*/
|
|
108
|
+
lock(): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Unlock MetaMask with password
|
|
111
|
+
*/
|
|
112
|
+
unlock(password?: string): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Switch to an existing network in MetaMask
|
|
115
|
+
* @param networkName - Name of the network to switch to (e.g., "Ethereum Mainnet", "Sepolia")
|
|
116
|
+
*/
|
|
117
|
+
switchNetwork(networkName: string, networkType?: "Popular" | "Custom"): Promise<void>;
|
|
118
|
+
switchAccount(accountName: string): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Add a custom network to MetaMask
|
|
121
|
+
*/
|
|
122
|
+
addNetwork(network: NetworkSettings): Promise<void>;
|
|
123
|
+
addCustomNetwork(settings: NetworkSettings): Promise<void>;
|
|
124
|
+
enableTestNetworks(): Promise<void>;
|
|
125
|
+
importAccount(privateKey: string): Promise<void>;
|
|
126
|
+
accountNameIs(accountName: string): Promise<void>;
|
|
127
|
+
private _waitWalletStable;
|
|
41
128
|
}
|
|
42
129
|
|
|
43
130
|
declare class PolkadotJS extends Wallet {
|
|
@@ -52,41 +139,26 @@ declare class PolkadotJS extends Wallet {
|
|
|
52
139
|
private _getLabeledInput;
|
|
53
140
|
}
|
|
54
141
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Pre-built MetaMask wallet configuration.
|
|
144
|
+
*/
|
|
145
|
+
declare const metamask: WalletConfig<"metamask", Metamask>;
|
|
146
|
+
/**
|
|
147
|
+
* Pre-built Polkadot.js wallet configuration.
|
|
148
|
+
*/
|
|
149
|
+
declare const polkadotJS: WalletConfig<"polkadotJS", PolkadotJS>;
|
|
61
150
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Configuration for w3wallets library.
|
|
153
|
+
* Values can be overridden via environment variables.
|
|
154
|
+
*/
|
|
155
|
+
declare const config: {
|
|
65
156
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
157
|
+
* Timeout for actions like click, fill, waitFor, goto.
|
|
158
|
+
* Set via W3WALLETS_ACTION_TIMEOUT env variable.
|
|
159
|
+
* @default 30000 (30 seconds)
|
|
68
160
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
name: string;
|
|
72
|
-
}): Promise<void>;
|
|
73
|
-
importAccount(privateKey: string): Promise<void>;
|
|
74
|
-
addAccount(accountName?: string): Promise<void>;
|
|
75
|
-
getAccountName(): Promise<string>;
|
|
76
|
-
connectToNetwork(networkName: string, networkType?: "Popular" | "Custom"): Promise<void>;
|
|
77
|
-
addCustomNetwork(settings: NetworkSettings): Promise<void>;
|
|
78
|
-
enableTestNetworks(): Promise<void>;
|
|
79
|
-
approve(): Promise<void>;
|
|
80
|
-
deny(): Promise<void>;
|
|
81
|
-
private usingNotificationPage;
|
|
82
|
-
private clickTopRightCornerToCloseAllTheMarketingBullshit;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
declare function withWallets<T extends readonly WalletName[]>(test: typeof test, ...config: NoDuplicates<T>): playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & {
|
|
86
|
-
context: BrowserContext;
|
|
87
|
-
backpack: Backpack;
|
|
88
|
-
polkadotJS: PolkadotJS;
|
|
89
|
-
metamask: Metamask;
|
|
90
|
-
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
161
|
+
readonly actionTimeout: number | undefined;
|
|
162
|
+
};
|
|
91
163
|
|
|
92
|
-
export { withWallets };
|
|
164
|
+
export { type IWallet, Metamask, type Network, type NetworkSettings, PolkadotJS, type WalletConfig, config, createWallet, metamask, polkadotJS, withWallets };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,43 +1,130 @@
|
|
|
1
1
|
import * as playwright_test from 'playwright/test';
|
|
2
2
|
import { Page, test, BrowserContext } from '@playwright/test';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Represents the supported network types for the BackPack application.
|
|
6
|
-
*/
|
|
7
|
-
type BackPackNetwork = "Solana" | "Eclipse" | "Ethereum" | "Polygon" | "Base" | "Arbitrum" | "Optimism";
|
|
8
|
-
|
|
9
|
-
type WalletName = "backpack" | "polkadotJS" | "metamask";
|
|
10
|
-
type NoDuplicates<T extends readonly unknown[], Acc extends readonly unknown[] = []> = T extends [infer Head, ...infer Tail] ? Head extends Acc[number] ? never : [Head, ...NoDuplicates<Tail, [...Acc, Head]>] : T;
|
|
11
4
|
interface IWallet {
|
|
5
|
+
readonly page: Page;
|
|
12
6
|
gotoOnboardPage(): Promise<void>;
|
|
7
|
+
approve(): Promise<void>;
|
|
8
|
+
deny(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configuration object for a wallet.
|
|
12
|
+
*/
|
|
13
|
+
interface WalletConfig<TName extends string = string, TWallet extends IWallet = IWallet> {
|
|
14
|
+
/** Unique wallet identifier, used as fixture name */
|
|
15
|
+
name: TName;
|
|
16
|
+
/** Directory name under .w3wallets/ where extension is stored */
|
|
17
|
+
extensionDir: string;
|
|
18
|
+
/** Wallet class constructor */
|
|
19
|
+
WalletClass: new (page: Page, extensionId: string) => TWallet;
|
|
20
|
+
/**
|
|
21
|
+
* Chrome extension ID. If not provided, it will be derived from
|
|
22
|
+
* the manifest.json `key` field. Required for custom extensions
|
|
23
|
+
* that don't have a `key` field in their manifest.
|
|
24
|
+
*/
|
|
25
|
+
extensionId?: string;
|
|
13
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a wallet configuration object.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const myWallet = createWallet({
|
|
33
|
+
* name: "myWallet",
|
|
34
|
+
* extensionDir: "my-wallet",
|
|
35
|
+
* WalletClass: MyWalletClass,
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function createWallet<TName extends string, TWallet extends IWallet>(config: WalletConfig<TName, TWallet>): WalletConfig<TName, TWallet>;
|
|
40
|
+
/**
|
|
41
|
+
* Extracts fixture name from a wallet config.
|
|
42
|
+
*/
|
|
43
|
+
type WalletConfigName<T> = T extends WalletConfig<infer N, IWallet> ? N : never;
|
|
44
|
+
/**
|
|
45
|
+
* Extracts wallet class instance type from a wallet config.
|
|
46
|
+
*/
|
|
47
|
+
type WalletConfigInstance<T> = T extends WalletConfig<string, infer W> ? W : never;
|
|
48
|
+
/**
|
|
49
|
+
* Builds fixture types from an array of wallet configs.
|
|
50
|
+
*/
|
|
51
|
+
type WalletFixturesFromConfigs<T extends readonly WalletConfig[]> = {
|
|
52
|
+
[K in T[number] as WalletConfigName<K>]: WalletConfigInstance<K>;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Supported blockchain networks.
|
|
56
|
+
* Common networks are listed for autocomplete, but any string is accepted.
|
|
57
|
+
*/
|
|
58
|
+
type Network = "Solana" | "Eclipse" | "Ethereum" | "Polygon" | "Base" | "Arbitrum" | "Optimism" | (string & {});
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Extends Playwright test with wallet fixtures.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { withWallets, metamask, polkadotJS } from "w3wallets";
|
|
66
|
+
*
|
|
67
|
+
* const test = withWallets(base, metamask, polkadotJS);
|
|
68
|
+
*
|
|
69
|
+
* test("can connect", async ({ metamask, polkadotJS }) => {
|
|
70
|
+
* await metamask.onboard(mnemonic);
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function withWallets<const T extends readonly WalletConfig[]>(test: typeof test, ...wallets: T): playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & WalletFixturesFromConfigs<T> & {
|
|
75
|
+
context: BrowserContext;
|
|
76
|
+
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
14
77
|
|
|
15
78
|
declare abstract class Wallet implements IWallet {
|
|
16
|
-
page: Page;
|
|
17
|
-
protected extensionId: string;
|
|
79
|
+
readonly page: Page;
|
|
80
|
+
protected readonly extensionId: string;
|
|
18
81
|
constructor(page: Page, extensionId: string);
|
|
19
82
|
abstract gotoOnboardPage(): Promise<void>;
|
|
83
|
+
abstract approve(): Promise<void>;
|
|
84
|
+
abstract deny(): Promise<void>;
|
|
20
85
|
}
|
|
21
86
|
|
|
22
|
-
|
|
87
|
+
type NetworkSettings = {
|
|
88
|
+
name: string;
|
|
89
|
+
rpc: string;
|
|
90
|
+
chainId: number;
|
|
91
|
+
currencySymbol: string;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
declare class Metamask extends Wallet {
|
|
23
95
|
private defaultPassword;
|
|
24
|
-
private currentAccountId;
|
|
25
|
-
private maxAccountId;
|
|
26
96
|
gotoOnboardPage(): Promise<void>;
|
|
27
|
-
onboard(network: BackPackNetwork, privateKey: string): Promise<void>;
|
|
28
|
-
addAccount(network: BackPackNetwork, privateKey: string): Promise<void>;
|
|
29
97
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param
|
|
98
|
+
* Onboard MetaMask with a mnemonic phrase
|
|
99
|
+
* @param mnemonic - 12 or 24 word recovery phrase
|
|
100
|
+
* @param password - Optional password (defaults to TestPassword123!)
|
|
32
101
|
*/
|
|
33
|
-
|
|
34
|
-
unlock(): Promise<void>;
|
|
35
|
-
setRPC(network: BackPackNetwork, rpc: string): Promise<void>;
|
|
36
|
-
ignoreAndProceed(): Promise<void>;
|
|
102
|
+
onboard(mnemonic: string, password?: string): Promise<void>;
|
|
37
103
|
approve(): Promise<void>;
|
|
38
104
|
deny(): Promise<void>;
|
|
39
|
-
|
|
40
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Lock the MetaMask wallet
|
|
107
|
+
*/
|
|
108
|
+
lock(): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Unlock MetaMask with password
|
|
111
|
+
*/
|
|
112
|
+
unlock(password?: string): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Switch to an existing network in MetaMask
|
|
115
|
+
* @param networkName - Name of the network to switch to (e.g., "Ethereum Mainnet", "Sepolia")
|
|
116
|
+
*/
|
|
117
|
+
switchNetwork(networkName: string, networkType?: "Popular" | "Custom"): Promise<void>;
|
|
118
|
+
switchAccount(accountName: string): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Add a custom network to MetaMask
|
|
121
|
+
*/
|
|
122
|
+
addNetwork(network: NetworkSettings): Promise<void>;
|
|
123
|
+
addCustomNetwork(settings: NetworkSettings): Promise<void>;
|
|
124
|
+
enableTestNetworks(): Promise<void>;
|
|
125
|
+
importAccount(privateKey: string): Promise<void>;
|
|
126
|
+
accountNameIs(accountName: string): Promise<void>;
|
|
127
|
+
private _waitWalletStable;
|
|
41
128
|
}
|
|
42
129
|
|
|
43
130
|
declare class PolkadotJS extends Wallet {
|
|
@@ -52,41 +139,26 @@ declare class PolkadotJS extends Wallet {
|
|
|
52
139
|
private _getLabeledInput;
|
|
53
140
|
}
|
|
54
141
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Pre-built MetaMask wallet configuration.
|
|
144
|
+
*/
|
|
145
|
+
declare const metamask: WalletConfig<"metamask", Metamask>;
|
|
146
|
+
/**
|
|
147
|
+
* Pre-built Polkadot.js wallet configuration.
|
|
148
|
+
*/
|
|
149
|
+
declare const polkadotJS: WalletConfig<"polkadotJS", PolkadotJS>;
|
|
61
150
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Configuration for w3wallets library.
|
|
153
|
+
* Values can be overridden via environment variables.
|
|
154
|
+
*/
|
|
155
|
+
declare const config: {
|
|
65
156
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
157
|
+
* Timeout for actions like click, fill, waitFor, goto.
|
|
158
|
+
* Set via W3WALLETS_ACTION_TIMEOUT env variable.
|
|
159
|
+
* @default 30000 (30 seconds)
|
|
68
160
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
name: string;
|
|
72
|
-
}): Promise<void>;
|
|
73
|
-
importAccount(privateKey: string): Promise<void>;
|
|
74
|
-
addAccount(accountName?: string): Promise<void>;
|
|
75
|
-
getAccountName(): Promise<string>;
|
|
76
|
-
connectToNetwork(networkName: string, networkType?: "Popular" | "Custom"): Promise<void>;
|
|
77
|
-
addCustomNetwork(settings: NetworkSettings): Promise<void>;
|
|
78
|
-
enableTestNetworks(): Promise<void>;
|
|
79
|
-
approve(): Promise<void>;
|
|
80
|
-
deny(): Promise<void>;
|
|
81
|
-
private usingNotificationPage;
|
|
82
|
-
private clickTopRightCornerToCloseAllTheMarketingBullshit;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
declare function withWallets<T extends readonly WalletName[]>(test: typeof test, ...config: NoDuplicates<T>): playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & {
|
|
86
|
-
context: BrowserContext;
|
|
87
|
-
backpack: Backpack;
|
|
88
|
-
polkadotJS: PolkadotJS;
|
|
89
|
-
metamask: Metamask;
|
|
90
|
-
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
161
|
+
readonly actionTimeout: number | undefined;
|
|
162
|
+
};
|
|
91
163
|
|
|
92
|
-
export { withWallets };
|
|
164
|
+
export { type IWallet, Metamask, type Network, type NetworkSettings, PolkadotJS, type WalletConfig, config, createWallet, metamask, polkadotJS, withWallets };
|