@avalix/chroma 0.0.9 → 0.0.11
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 +23 -5
- package/dist/index.d.mts +9987 -0
- package/dist/{index.js → index.mjs} +23 -33
- package/package.json +20 -15
- package/scripts/download-extensions.ts +26 -1
- package/src/context-playwright/index.ts +0 -1
- package/src/utils/download-extension.integration.test.ts +95 -0
- package/src/utils/download-extension.test.ts +173 -0
- package/src/utils/download-extension.ts +33 -6
- package/src/wallets/polkadot-js.ts +21 -12
- package/src/wallets/talisman.ts +12 -9
- package/dist/index.d.ts +0 -65
|
@@ -5,9 +5,11 @@ import path from 'node:path'
|
|
|
5
5
|
import process from 'node:process'
|
|
6
6
|
|
|
7
7
|
// Polkadot-JS specific configuration
|
|
8
|
+
// https://github.com/polkadot-js/extension/releases
|
|
9
|
+
const VERSION = '0.62.6'
|
|
8
10
|
export const POLKADOT_JS_CONFIG = {
|
|
9
|
-
downloadUrl:
|
|
10
|
-
extensionName:
|
|
11
|
+
downloadUrl: `https://github.com/polkadot-js/extension/releases/download/v${VERSION}/master-chrome-build.zip`,
|
|
12
|
+
extensionName: `polkadot-extension-${VERSION}`,
|
|
11
13
|
} as const
|
|
12
14
|
|
|
13
15
|
// Helper function to find extension popup
|
|
@@ -48,7 +50,6 @@ export async function getPolkadotJSExtensionPath(): Promise<string> {
|
|
|
48
50
|
)
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
console.log(`✅ Found Polkadot-JS extension at: ${extensionDir}`)
|
|
52
53
|
return extensionDir
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -73,6 +74,10 @@ export async function importPolkadotJSAccount(
|
|
|
73
74
|
await extensionPage.waitForTimeout(100)
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
if (await extensionPage.getByRole('button', { name: 'I Understand' }).isVisible()) {
|
|
78
|
+
await extensionPage.getByRole('button', { name: 'I Understand' }).click()
|
|
79
|
+
}
|
|
80
|
+
|
|
76
81
|
// Navigate to import seed page
|
|
77
82
|
await extensionPage.goto(`${extensionPopupUrl}#/account/import-seed`)
|
|
78
83
|
|
|
@@ -83,8 +88,6 @@ export async function importPolkadotJSAccount(
|
|
|
83
88
|
await extensionPage.locator('input[type="password"]').fill(password)
|
|
84
89
|
await extensionPage.locator('div').filter({ hasText: /^Repeat password for verification$/ }).getByRole('textbox').fill(password)
|
|
85
90
|
await extensionPage.getByRole('button', { name: 'Add the account with the supplied seed' }).click()
|
|
86
|
-
|
|
87
|
-
console.log(`✅ Created Polkadot-JS wallet account: ${name}`)
|
|
88
91
|
}
|
|
89
92
|
finally {
|
|
90
93
|
await extensionPage.close()
|
|
@@ -99,10 +102,20 @@ export async function authorizePolkadotJS(
|
|
|
99
102
|
const extensionId = page.__extensionId
|
|
100
103
|
|
|
101
104
|
const extensionPopup = await findExtensionPopup(context, extensionId)
|
|
102
|
-
await extensionPopup.getByText('Select all').click()
|
|
103
|
-
await extensionPopup.getByRole('button', { name: /Connect \d+ account\(s\)/ }).click()
|
|
104
105
|
|
|
105
|
-
|
|
106
|
+
if (await extensionPopup.getByRole('button', { name: 'I Understand' }).isVisible()) {
|
|
107
|
+
await extensionPopup.getByRole('button', { name: 'I Understand' }).click()
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Check if "Select all" checkbox is already checked
|
|
111
|
+
const selectAllCheckbox = extensionPopup.getByText('Select all').locator('..').locator('input[type="checkbox"]')
|
|
112
|
+
const isChecked = await selectAllCheckbox.isChecked().catch(() => false)
|
|
113
|
+
|
|
114
|
+
if (!isChecked) {
|
|
115
|
+
await extensionPopup.getByText('Select all').click()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
await extensionPopup.getByRole('button', { name: /Connect \d+ account\(s\)/ }).click()
|
|
106
119
|
}
|
|
107
120
|
|
|
108
121
|
// Polkadot-JS specific transaction approval implementation
|
|
@@ -117,8 +130,6 @@ export async function approvePolkadotJSTx(
|
|
|
117
130
|
const extensionPopup = await findExtensionPopup(context, extensionId)
|
|
118
131
|
await extensionPopup.getByRole('textbox').fill(password)
|
|
119
132
|
await extensionPopup.getByRole('button', { name: 'Sign the transaction' }).click()
|
|
120
|
-
|
|
121
|
-
console.log('✅ Polkadot-JS transaction signed successfully')
|
|
122
133
|
}
|
|
123
134
|
|
|
124
135
|
// Polkadot-JS specific transaction rejection implementation
|
|
@@ -130,6 +141,4 @@ export async function rejectPolkadotJSTx(
|
|
|
130
141
|
|
|
131
142
|
const extensionPopup = await findExtensionPopup(context, extensionId)
|
|
132
143
|
await extensionPopup.getByRole('link', { name: 'Cancel' }).click()
|
|
133
|
-
|
|
134
|
-
console.log('✅ Polkadot-JS transaction rejected successfully')
|
|
135
144
|
}
|
package/src/wallets/talisman.ts
CHANGED
|
@@ -5,9 +5,11 @@ import path from 'node:path'
|
|
|
5
5
|
import process from 'node:process'
|
|
6
6
|
|
|
7
7
|
// Talisman specific configuration
|
|
8
|
+
// https://github.com/avalix-labs/polkadot-wallets/tree/main/talisman
|
|
9
|
+
const VERSION = '3.1.13'
|
|
8
10
|
export const TALISMAN_CONFIG = {
|
|
9
|
-
downloadUrl:
|
|
10
|
-
extensionName:
|
|
11
|
+
downloadUrl: `https://github.com/avalix-labs/polkadot-wallets/raw/refs/heads/main/talisman/talisman-${VERSION}.zip`,
|
|
12
|
+
extensionName: `talisman-extension-${VERSION}`,
|
|
11
13
|
} as const
|
|
12
14
|
|
|
13
15
|
// Helper function to find extension popup
|
|
@@ -49,7 +51,6 @@ export async function getTalismanExtensionPath(): Promise<string> {
|
|
|
49
51
|
)
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
console.log(`✅ Found Talisman extension at: ${extensionDir}`)
|
|
53
54
|
return extensionDir
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -71,10 +72,8 @@ export async function importEthPrivateKey(
|
|
|
71
72
|
|
|
72
73
|
for (const p of pages) {
|
|
73
74
|
const url = p.url()
|
|
74
|
-
console.log(`📄 Found page: ${url}`)
|
|
75
75
|
if (url.includes('onboarding.html') || url.includes(`chrome-extension://${extensionId}/`)) {
|
|
76
76
|
extensionPage = p
|
|
77
|
-
console.log(`✅ Found Talisman onboarding page: ${url}`)
|
|
78
77
|
break
|
|
79
78
|
}
|
|
80
79
|
}
|
|
@@ -85,7 +84,6 @@ export async function importEthPrivateKey(
|
|
|
85
84
|
|
|
86
85
|
// If not found, wait before retrying
|
|
87
86
|
if (attempt < maxAttempts - 1) {
|
|
88
|
-
console.log(`⏳ Attempt ${attempt + 1}/${maxAttempts}: Waiting for onboarding page...`)
|
|
89
87
|
await new Promise(resolve => setTimeout(resolve, retryDelay))
|
|
90
88
|
}
|
|
91
89
|
}
|
|
@@ -124,8 +122,6 @@ export async function importEthPrivateKey(
|
|
|
124
122
|
await extensionPage.getByRole('button', { name: 'Save' }).click()
|
|
125
123
|
|
|
126
124
|
await extensionPage.close()
|
|
127
|
-
|
|
128
|
-
console.log('✅ Talisman account import completed')
|
|
129
125
|
}
|
|
130
126
|
catch (error) {
|
|
131
127
|
console.error('❌ Error during Talisman account import:', error)
|
|
@@ -153,7 +149,6 @@ export async function authorizeTalisman(
|
|
|
153
149
|
await anotherPopup.getByRole('button', { name: 'Approve' }).click()
|
|
154
150
|
}
|
|
155
151
|
catch {
|
|
156
|
-
console.log('No another popup found, skipping')
|
|
157
152
|
}
|
|
158
153
|
}
|
|
159
154
|
|
|
@@ -165,6 +160,14 @@ export async function approveTalismanTx(
|
|
|
165
160
|
const extensionId = page.__extensionId
|
|
166
161
|
|
|
167
162
|
const extensionPopup = await findExtensionPopup(context, extensionId)
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
await extensionPopup.getByRole('button', { name: 'Yes' }).click()
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
console.log('No another popup found, skipping')
|
|
169
|
+
}
|
|
170
|
+
|
|
168
171
|
await extensionPopup.getByRole('button', { name: 'Approve' }).click()
|
|
169
172
|
}
|
|
170
173
|
|
package/dist/index.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { BrowserContext, Page, expect } from "@playwright/test";
|
|
2
|
-
import * as playwright_test0 from "playwright/test";
|
|
3
|
-
|
|
4
|
-
//#region src/context-playwright/types.d.ts
|
|
5
|
-
type WalletType = 'polkadot-js' | 'talisman';
|
|
6
|
-
interface WalletAccount {
|
|
7
|
-
seed: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
password?: string;
|
|
10
|
-
}
|
|
11
|
-
interface WalletConfig {
|
|
12
|
-
type: WalletType;
|
|
13
|
-
downloadUrl?: string;
|
|
14
|
-
}
|
|
15
|
-
interface BaseWalletInstance {
|
|
16
|
-
extensionId: string;
|
|
17
|
-
importMnemonic: (options: WalletAccount) => Promise<void>;
|
|
18
|
-
authorize: (options?: {
|
|
19
|
-
accountName?: string;
|
|
20
|
-
}) => Promise<void>;
|
|
21
|
-
approveTx: (options?: {
|
|
22
|
-
password?: string;
|
|
23
|
-
}) => Promise<void>;
|
|
24
|
-
rejectTx: () => Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
interface PolkadotJsWalletInstance extends BaseWalletInstance {
|
|
27
|
-
type: 'polkadot-js';
|
|
28
|
-
}
|
|
29
|
-
interface TalismanWalletInstance extends BaseWalletInstance {
|
|
30
|
-
type: 'talisman';
|
|
31
|
-
importEthPrivateKey: (options: {
|
|
32
|
-
privateKey: string;
|
|
33
|
-
name?: string;
|
|
34
|
-
password?: string;
|
|
35
|
-
}) => Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
interface WalletTypeMap {
|
|
38
|
-
'polkadot-js': PolkadotJsWalletInstance;
|
|
39
|
-
'talisman': TalismanWalletInstance;
|
|
40
|
-
}
|
|
41
|
-
type Wallets = WalletTypeMap;
|
|
42
|
-
type ConfiguredWallets<T extends readonly WalletConfig[]> = { [K in T[number]['type']]: WalletTypeMap[K] };
|
|
43
|
-
type ExtendedPage = Page & {
|
|
44
|
-
__extensionContext: BrowserContext;
|
|
45
|
-
__walletExtensionIds: Map<string, string>;
|
|
46
|
-
};
|
|
47
|
-
interface ChromaTestOptions<T extends readonly WalletConfig[] = WalletConfig[]> {
|
|
48
|
-
wallets?: T;
|
|
49
|
-
headless?: boolean;
|
|
50
|
-
slowMo?: number;
|
|
51
|
-
}
|
|
52
|
-
interface WalletFixtures<W = Wallets> {
|
|
53
|
-
page: ExtendedPage;
|
|
54
|
-
wallets: W;
|
|
55
|
-
}
|
|
56
|
-
interface WalletWorkerFixtures {
|
|
57
|
-
walletContext: BrowserContext;
|
|
58
|
-
walletExtensionIds: Map<string, string>;
|
|
59
|
-
}
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region src/context-playwright/index.d.ts
|
|
62
|
-
declare function createWalletTest<const T extends readonly WalletConfig[]>(options?: ChromaTestOptions<T>): playwright_test0.TestType<playwright_test0.PlaywrightTestArgs & playwright_test0.PlaywrightTestOptions & WalletFixtures<T extends readonly WalletConfig[] ? ConfiguredWallets<T> : WalletTypeMap>, playwright_test0.PlaywrightWorkerArgs & playwright_test0.PlaywrightWorkerOptions & WalletWorkerFixtures>;
|
|
63
|
-
declare const test: ReturnType<typeof createWalletTest>;
|
|
64
|
-
//#endregion
|
|
65
|
-
export { createWalletTest, expect, test };
|