w3wallets 0.2.2 → 0.3.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 +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +42 -16
- package/dist/index.mjs +42 -16
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -21,14 +21,23 @@ declare abstract class Wallet implements IWallet {
|
|
|
21
21
|
|
|
22
22
|
declare class Backpack extends Wallet {
|
|
23
23
|
private defaultPassword;
|
|
24
|
+
private currentAccountId;
|
|
25
|
+
private maxAccountId;
|
|
24
26
|
gotoOnboardPage(): Promise<void>;
|
|
25
27
|
onboard(network: BackPackNetwork, privateKey: string): Promise<void>;
|
|
28
|
+
addAccount(network: BackPackNetwork, privateKey: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Switch account
|
|
31
|
+
* @param id The first added account has id 1, the second – 2, and so on
|
|
32
|
+
*/
|
|
33
|
+
switchAccount(id: number): Promise<void>;
|
|
26
34
|
unlock(): Promise<void>;
|
|
27
|
-
goToSettings(accountName?: string): Promise<void>;
|
|
28
35
|
setRPC(network: BackPackNetwork, rpc: string): Promise<void>;
|
|
29
36
|
ignoreAndProceed(): Promise<void>;
|
|
30
37
|
approve(): Promise<void>;
|
|
31
38
|
deny(): Promise<void>;
|
|
39
|
+
private _clickOnAccount;
|
|
40
|
+
private _importAccount;
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
declare class PolkadotJS extends Wallet {
|
package/dist/index.d.ts
CHANGED
|
@@ -21,14 +21,23 @@ declare abstract class Wallet implements IWallet {
|
|
|
21
21
|
|
|
22
22
|
declare class Backpack extends Wallet {
|
|
23
23
|
private defaultPassword;
|
|
24
|
+
private currentAccountId;
|
|
25
|
+
private maxAccountId;
|
|
24
26
|
gotoOnboardPage(): Promise<void>;
|
|
25
27
|
onboard(network: BackPackNetwork, privateKey: string): Promise<void>;
|
|
28
|
+
addAccount(network: BackPackNetwork, privateKey: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Switch account
|
|
31
|
+
* @param id The first added account has id 1, the second – 2, and so on
|
|
32
|
+
*/
|
|
33
|
+
switchAccount(id: number): Promise<void>;
|
|
26
34
|
unlock(): Promise<void>;
|
|
27
|
-
goToSettings(accountName?: string): Promise<void>;
|
|
28
35
|
setRPC(network: BackPackNetwork, rpc: string): Promise<void>;
|
|
29
36
|
ignoreAndProceed(): Promise<void>;
|
|
30
37
|
approve(): Promise<void>;
|
|
31
38
|
deny(): Promise<void>;
|
|
39
|
+
private _clickOnAccount;
|
|
40
|
+
private _importAccount;
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
declare class PolkadotJS extends Wallet {
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,8 @@ var Wallet = class {
|
|
|
58
58
|
// src/backpack/backpack.ts
|
|
59
59
|
var Backpack = class extends Wallet {
|
|
60
60
|
defaultPassword = "11111111";
|
|
61
|
+
currentAccountId = 0;
|
|
62
|
+
maxAccountId = 0;
|
|
61
63
|
async gotoOnboardPage() {
|
|
62
64
|
await this.page.goto(
|
|
63
65
|
`chrome-extension://${this.extensionId}/options.html?onboarding=true`
|
|
@@ -65,28 +67,34 @@ var Backpack = class extends Wallet {
|
|
|
65
67
|
await (0, import_test.expect)(this.page.getByText("Welcome to Backpack")).toBeVisible();
|
|
66
68
|
}
|
|
67
69
|
async onboard(network, privateKey) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
await this.page.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
await this.
|
|
70
|
+
this.currentAccountId++;
|
|
71
|
+
this.maxAccountId++;
|
|
72
|
+
return this._importAccount(network, privateKey, true);
|
|
73
|
+
}
|
|
74
|
+
async addAccount(network, privateKey) {
|
|
75
|
+
this.maxAccountId++;
|
|
76
|
+
this.currentAccountId = this.maxAccountId;
|
|
77
|
+
await this.page.goto(
|
|
78
|
+
`chrome-extension://${this.extensionId}/options.html?add-user-account=true`
|
|
79
|
+
);
|
|
80
|
+
await this._importAccount(network, privateKey, false);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Switch account
|
|
84
|
+
* @param id The first added account has id 1, the second – 2, and so on
|
|
85
|
+
*/
|
|
86
|
+
async switchAccount(id) {
|
|
87
|
+
await this.page.getByRole("button", { name: `A${this.currentAccountId}` }).click();
|
|
88
|
+
await this.page.getByRole("button", { name: `Account ${id}` }).click();
|
|
89
|
+
this.currentAccountId = id;
|
|
79
90
|
}
|
|
80
91
|
async unlock() {
|
|
81
92
|
await this.page.getByPlaceholder("Password").fill(this.defaultPassword);
|
|
82
93
|
await this.page.getByRole("button", { name: "Unlock" }).click();
|
|
83
94
|
}
|
|
84
|
-
async goToSettings(accountName) {
|
|
85
|
-
await this.page.getByRole("button", { name: accountName ?? "A1" }).click();
|
|
86
|
-
await this.page.getByRole("button", { name: "Settings" }).click();
|
|
87
|
-
}
|
|
88
95
|
async setRPC(network, rpc) {
|
|
89
|
-
await this.
|
|
96
|
+
await this._clickOnAccount();
|
|
97
|
+
await this.page.getByRole("button", { name: "Settings" }).click();
|
|
90
98
|
await this.page.getByRole("button", { name: network }).click();
|
|
91
99
|
await this.page.getByRole("button", { name: "RPC Connection" }).click();
|
|
92
100
|
await this.page.getByRole("button", { name: "Custom" }).click();
|
|
@@ -103,6 +111,24 @@ var Backpack = class extends Wallet {
|
|
|
103
111
|
async deny() {
|
|
104
112
|
await this.page.getByText("Deny", { exact: true }).click();
|
|
105
113
|
}
|
|
114
|
+
async _clickOnAccount() {
|
|
115
|
+
return this.page.getByRole("button", { name: `A${this.currentAccountId}`, exact: true }).click();
|
|
116
|
+
}
|
|
117
|
+
async _importAccount(network, privateKey, isOnboard) {
|
|
118
|
+
await this.page.getByRole("button", { name: "Import wallet" }).click();
|
|
119
|
+
await this.page.getByRole("button", { name: network }).click();
|
|
120
|
+
await this.page.getByRole("button", { name: "Import private key" }).click();
|
|
121
|
+
await this.page.getByPlaceholder("Enter private key").fill(privateKey);
|
|
122
|
+
await this.page.getByRole("button", { name: "Import" }).click();
|
|
123
|
+
if (isOnboard) {
|
|
124
|
+
await this.page.getByPlaceholder("Password", { exact: true }).fill(this.defaultPassword);
|
|
125
|
+
await this.page.getByPlaceholder("Confirm Password").fill(this.defaultPassword);
|
|
126
|
+
await this.page.getByRole("checkbox").click();
|
|
127
|
+
await this.page.getByRole("button", { name: "Next" }).click();
|
|
128
|
+
}
|
|
129
|
+
await (0, import_test.expect)(this.page.getByText("You're all good!")).toBeVisible();
|
|
130
|
+
await this.page.goto(`chrome-extension://${this.extensionId}/popup.html`);
|
|
131
|
+
}
|
|
106
132
|
};
|
|
107
133
|
|
|
108
134
|
// src/polkadotJS/polkadotJS.ts
|
package/dist/index.mjs
CHANGED
|
@@ -24,6 +24,8 @@ var Wallet = class {
|
|
|
24
24
|
// src/backpack/backpack.ts
|
|
25
25
|
var Backpack = class extends Wallet {
|
|
26
26
|
defaultPassword = "11111111";
|
|
27
|
+
currentAccountId = 0;
|
|
28
|
+
maxAccountId = 0;
|
|
27
29
|
async gotoOnboardPage() {
|
|
28
30
|
await this.page.goto(
|
|
29
31
|
`chrome-extension://${this.extensionId}/options.html?onboarding=true`
|
|
@@ -31,28 +33,34 @@ var Backpack = class extends Wallet {
|
|
|
31
33
|
await expect(this.page.getByText("Welcome to Backpack")).toBeVisible();
|
|
32
34
|
}
|
|
33
35
|
async onboard(network, privateKey) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
await this.page.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
await this.
|
|
36
|
+
this.currentAccountId++;
|
|
37
|
+
this.maxAccountId++;
|
|
38
|
+
return this._importAccount(network, privateKey, true);
|
|
39
|
+
}
|
|
40
|
+
async addAccount(network, privateKey) {
|
|
41
|
+
this.maxAccountId++;
|
|
42
|
+
this.currentAccountId = this.maxAccountId;
|
|
43
|
+
await this.page.goto(
|
|
44
|
+
`chrome-extension://${this.extensionId}/options.html?add-user-account=true`
|
|
45
|
+
);
|
|
46
|
+
await this._importAccount(network, privateKey, false);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Switch account
|
|
50
|
+
* @param id The first added account has id 1, the second – 2, and so on
|
|
51
|
+
*/
|
|
52
|
+
async switchAccount(id) {
|
|
53
|
+
await this.page.getByRole("button", { name: `A${this.currentAccountId}` }).click();
|
|
54
|
+
await this.page.getByRole("button", { name: `Account ${id}` }).click();
|
|
55
|
+
this.currentAccountId = id;
|
|
45
56
|
}
|
|
46
57
|
async unlock() {
|
|
47
58
|
await this.page.getByPlaceholder("Password").fill(this.defaultPassword);
|
|
48
59
|
await this.page.getByRole("button", { name: "Unlock" }).click();
|
|
49
60
|
}
|
|
50
|
-
async goToSettings(accountName) {
|
|
51
|
-
await this.page.getByRole("button", { name: accountName ?? "A1" }).click();
|
|
52
|
-
await this.page.getByRole("button", { name: "Settings" }).click();
|
|
53
|
-
}
|
|
54
61
|
async setRPC(network, rpc) {
|
|
55
|
-
await this.
|
|
62
|
+
await this._clickOnAccount();
|
|
63
|
+
await this.page.getByRole("button", { name: "Settings" }).click();
|
|
56
64
|
await this.page.getByRole("button", { name: network }).click();
|
|
57
65
|
await this.page.getByRole("button", { name: "RPC Connection" }).click();
|
|
58
66
|
await this.page.getByRole("button", { name: "Custom" }).click();
|
|
@@ -69,6 +77,24 @@ var Backpack = class extends Wallet {
|
|
|
69
77
|
async deny() {
|
|
70
78
|
await this.page.getByText("Deny", { exact: true }).click();
|
|
71
79
|
}
|
|
80
|
+
async _clickOnAccount() {
|
|
81
|
+
return this.page.getByRole("button", { name: `A${this.currentAccountId}`, exact: true }).click();
|
|
82
|
+
}
|
|
83
|
+
async _importAccount(network, privateKey, isOnboard) {
|
|
84
|
+
await this.page.getByRole("button", { name: "Import wallet" }).click();
|
|
85
|
+
await this.page.getByRole("button", { name: network }).click();
|
|
86
|
+
await this.page.getByRole("button", { name: "Import private key" }).click();
|
|
87
|
+
await this.page.getByPlaceholder("Enter private key").fill(privateKey);
|
|
88
|
+
await this.page.getByRole("button", { name: "Import" }).click();
|
|
89
|
+
if (isOnboard) {
|
|
90
|
+
await this.page.getByPlaceholder("Password", { exact: true }).fill(this.defaultPassword);
|
|
91
|
+
await this.page.getByPlaceholder("Confirm Password").fill(this.defaultPassword);
|
|
92
|
+
await this.page.getByRole("checkbox").click();
|
|
93
|
+
await this.page.getByRole("button", { name: "Next" }).click();
|
|
94
|
+
}
|
|
95
|
+
await expect(this.page.getByText("You're all good!")).toBeVisible();
|
|
96
|
+
await this.page.goto(`chrome-extension://${this.extensionId}/popup.html`);
|
|
97
|
+
}
|
|
72
98
|
};
|
|
73
99
|
|
|
74
100
|
// src/polkadotJS/polkadotJS.ts
|