Get the latest Chainwright changes - #9
11 commits merged into
Conversation
[Core]: Upgrade Playwright and other core dependencies
Prepare patch update
[Release] - Fix failing release build by reverting Typescript upgrade
[Core] - Replace the 'glob' package with Node.js internal method
WalkthroughThe release updates package exports and runtime requirements, replaces external globbing with Node.js filesystem globbing, removes selected Zod validation, and updates wallet actions to use direct arguments. Setup-file tests now use temporary filesystem fixtures. ChangesRuntime and validation changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/core/test/get-setup-function.test.ts (1)
42-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for
.setup.mjsdiscovery.The production pattern now includes
.setup.mjs, but this suite does not exercise that extension. Add a fixture with a.setup.mjsfilename and assert thatgetSetupFunctionimports it.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/core/test/get-setup-function.test.ts` around lines 42 - 50, Add a .setup.mjs fixture to the setup directory created in the “selectedWallet is all” test, then invoke getSetupFunction or the existing runSetup flow and assert the generated setup function is imported and included in the result alongside the other setup files.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGELOG.md`:
- Around line 3-7: Expand the 0.11.0 “Minor Changes” entry in CHANGELOG.md to
document all upgrade-impacting changes: the engines.node requirement of >=22.18,
the new root “.” export, and removal of the specified Zod schemas and runtime
parsing, while retaining the existing glob replacement entry.
In `@src/core/test/get-setup-function.test.ts`:
- Around line 8-35: Update TEST_ROOT initialization in the test setup to use
fs.mkdtempSync with a unique prefix under os.tmpdir(), importing the os module
as needed. Keep createSetupDir and afterAll cleanup targeting this generated
per-run directory so concurrent or interrupted runs cannot share or remove
unrelated fixtures.
In `@src/wallets/keplr/types.ts`:
- Around line 44-58: Restore the public named addCustomNetworkSchema export in
src/wallets/metamask/types.ts at lines 20-25 so existing chainwright/metamask
TypeScript consumers can import it; no direct change is required in
src/wallets/keplr/types.ts lines 44-58 or src/wallets/solflare/types.ts lines
13-16, which do not expose equivalent named exports.
In `@src/wallets/phantom/actions/switch-account.phantom.ts`:
- Around line 15-18: Validate that accountName is non-empty before entering the
account search loop in the account-switching action, rejecting invalid input
before evaluating textContent?.includes(accountName). Preserve the existing
account matching and accountListButton selection behavior for valid names.
---
Nitpick comments:
In `@src/core/test/get-setup-function.test.ts`:
- Around line 42-50: Add a .setup.mjs fixture to the setup directory created in
the “selectedWallet is all” test, then invoke getSetupFunction or the existing
runSetup flow and assert the generated setup function is imported and included
in the result alongside the other setup files.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 422717af-d641-42ec-b347-532db69d02ae
⛔ Files ignored due to path filters (11)
dist/cli/index.d.tsis excluded by!**/dist/**dist/cli/index.jsis excluded by!**/dist/**dist/wallets/keplr/index.d.tsis excluded by!**/dist/**dist/wallets/keplr/index.jsis excluded by!**/dist/**dist/wallets/metamask/index.d.tsis excluded by!**/dist/**dist/wallets/metamask/index.jsis excluded by!**/dist/**dist/wallets/petra/index.jsis excluded by!**/dist/**dist/wallets/phantom/index.jsis excluded by!**/dist/**dist/wallets/solflare/index.d.tsis excluded by!**/dist/**dist/wallets/solflare/index.jsis excluded by!**/dist/**pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (20)
CHANGELOG.mdpackage.jsonpnpm-workspace.yamlsrc/cli/index.tssrc/core/get-setup-function.tssrc/core/test/get-setup-function.test.tssrc/utils/wallets/get-wallet-extension-id-from-browser.tssrc/wallets/keplr/actions/get-account-address.keplr.tssrc/wallets/keplr/actions/rename-account.keplr.tssrc/wallets/keplr/types.tssrc/wallets/metamask/actions/add-account.metamask.tssrc/wallets/metamask/actions/add-custom-network.metamask.tssrc/wallets/metamask/types.tssrc/wallets/petra/actions/rename-account.petra.tssrc/wallets/phantom/actions/get-account-address.phantom.tssrc/wallets/phantom/actions/switch-account.phantom.tssrc/wallets/solflare/actions/add-account.solflare.tssrc/wallets/solflare/types.tstsconfig.jsontsup.config.ts
💤 Files with no reviewable changes (1)
- tsconfig.json
| ## 0.11.0 | ||
|
|
||
| ### Minor Changes | ||
|
|
||
| - [Core] - Replace the 'glob' package with Node.js internal method |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Document the complete 0.11.0 upgrade impact.
The 0.11.0 entry only records the glob replacement. This release also raises engines.node to >=22.18, adds the root . export, and removes selected Zod schemas and runtime parsing. Record these changes so consumers can assess compatibility before upgrading.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@CHANGELOG.md` around lines 3 - 7, Expand the 0.11.0 “Minor Changes” entry in
CHANGELOG.md to document all upgrade-impacting changes: the engines.node
requirement of >=22.18, the new root “.” export, and removal of the specified
Zod schemas and runtime parsing, while retaining the existing glob replacement
entry.
| const TEST_ROOT = path.resolve(process.cwd(), "src/core/test/wallet-setup-test-files"); | ||
|
|
||
| let dirCounter = 0; | ||
|
|
||
| beforeAll(() => { | ||
| const setupFiles = ["metamask.setup.ts", "metamask-two.setup.ts", "phantom.setup.ts", "solflare.setup.ts"]; | ||
| fs.mkdirSync(WALLET_SETUP_DIR, { recursive: true }); | ||
| function createSetupDir(setupFiles: string[]): string { | ||
| const walletSetupDir = path.resolve(TEST_ROOT, `case-${++dirCounter}`); | ||
| fs.mkdirSync(walletSetupDir, { recursive: true }); | ||
|
|
||
| setupFiles.forEach((filename) => { | ||
| fs.writeFileSync( | ||
| path.resolve(WALLET_SETUP_DIR, filename), | ||
| path.resolve(walletSetupDir, filename), | ||
| ` | ||
| import { defineWalletSetup } from "@/core/define-wallet-setup"; | ||
|
|
||
| export default defineWalletSetup("test1234", async () => { | ||
| console.info("Setting up ${filename}....."); | ||
| return void 0; | ||
| }, ${filename === "metamask-two.setup.ts" ? '{ profileName: "profile-two" }' : undefined}); | ||
|
|
||
| `, | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| return walletSetupDir; | ||
| } | ||
|
|
||
| afterAll(() => { | ||
| fs.rmSync(WALLET_SETUP_DIR, { force: true, recursive: true }); | ||
| fs.rmSync(TEST_ROOT, { force: true, recursive: true }); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Use a unique operating-system temporary directory.
TEST_ROOT is a fixed path in the working tree. Line 35 recursively removes that path. Interrupted or concurrent runs can reuse stale fixtures, and cleanup can remove files not created by this test run.
Create TEST_ROOT with fs.mkdtempSync() under os.tmpdir().
🧰 Tools
🪛 ast-grep (0.45.0)
[warning] 16-27: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use.
Context: fs.writeFileSync(
path.resolve(walletSetupDir, filename),
import { defineWalletSetup } from "@/core/define-wallet-setup`";
export default defineWalletSetup("test1234", async () => {
console.info("Setting up ${filename}.....");
return void 0;
}, ${filename === "metamask-two.setup.ts" ? '{ profileName: "profile-two" }' : undefined});
`,
)
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
(detect-non-literal-fs-filename-typescript)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/core/test/get-setup-function.test.ts` around lines 8 - 35, Update
TEST_ROOT initialization in the test setup to use fs.mkdtempSync with a unique
prefix under os.tmpdir(), importing the os module as needed. Keep createSetupDir
and afterAll cleanup targeting this generated per-run directory so concurrent or
interrupted runs cannot share or remove unrelated fixtures.
| export type GetAccountAddressArgs = | ||
| | { | ||
| chain: "Injective" | "Injective (Testnet)" | "Polygon"; | ||
| walletName: string; | ||
| } | ||
| | { | ||
| chain: "Bitcoin" | "Bitcoin Signet" | "Bitcoin Testnet"; | ||
| chainTag: "Taproot" | "Native Segwit"; | ||
| walletName: string; | ||
| }; | ||
|
|
||
| export type RenameAccountArgs = z.infer<typeof renameAccountSchema>; | ||
| export type RenameAccountArgs = { | ||
| currentAccountName: string; | ||
| newAccountName: string; | ||
| }; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check whether the affected modules are exposed through package entry points.
fd -a '^package\.json$' . -x sh -c '
echo "=== $1 ==="
jq ".exports // .main // .module // .types" "$1"
' sh {}
# Find remaining imports of removed runtime schema values.
rg -n -C 3 \
'(getAccountAddress.*Schema|renameAccount.*Schema|addCustomNetworkSchema|addAccountSchema)' \
src README.mdRepository: TruFin-io/chainwright
Length of output: 1098
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '=== affected files ==='
for f in src/wallets/keplr/types.ts src/wallets/metamask/types.ts src/wallets/solflare/types.ts; do
echo "--- $f"
cat -n "$f"
done
printf '%s\n' '=== wallet entry points and exports ==='
for f in src/wallets/keplr/index.ts src/wallets/metamask/index.ts src/wallets/solflare/index.ts; do
echo "--- $f"
cat -n "$f"
done
printf '%s\n' '=== schema declarations and imports across tracked source/docs ==='
rg -n -C 3 \
'Schema|schema|GetAccountAddressArgs|RenameAccountArgs|AddCustomNetwork|AddAccountArgs' \
src README.md package.json || true
printf '%s\n' '=== package metadata ==='
jq '{name,version,exports}' package.jsonRepository: TruFin-io/chainwright
Length of output: 42271
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '=== recent commits ==='
git log --oneline -5
printf '%s\n' '=== change summary ==='
git diff --stat HEAD^ HEAD -- src/wallets/keplr src/wallets/metamask src/wallets/solflare package.json 2>/dev/null || true
printf '%s\n' '=== parent-to-current changes in affected files ==='
for f in src/wallets/keplr/types.ts src/wallets/keplr/index.ts \
src/wallets/metamask/types.ts src/wallets/metamask/index.ts \
src/wallets/solflare/types.ts src/wallets/solflare/index.ts; do
echo "--- $f"
git diff --no-ext-diff --unified=8 HEAD^ HEAD -- "$f" 2>/dev/null || true
done
printf '%s\n' '=== all exports from affected wallet source files ==='
rg -n '^(export|export \*)' \
src/wallets/keplr src/wallets/metamask src/wallets/solflare \
-g '*.ts' | head -200
printf '%s\n' '=== schema identifiers in repository history and current tree ==='
for rev in HEAD^ HEAD; do
echo "--- $rev"
git grep -n -E '(getAccountAddress.*Schema|renameAccount.*Schema|addCustomNetworkSchema|addAccountSchema)' "$rev" -- . ':!package-lock.json' || true
doneRepository: TruFin-io/chainwright
Length of output: 13249
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '=== commits that add or remove the schema identifiers ==='
git log --all --oneline --reverse -S 'getAccountAddressSchema' -- . || true
git log --all --oneline --reverse -S 'renameAccountSchema' -- . || true
git log --all --oneline --reverse -S 'addCustomNetworkSchema' -- . || true
git log --all --oneline --reverse -S 'addAccountSchema' -- . || true
printf '%s\n' '=== current and parent generated entry-point declarations ==='
for rev in HEAD^ HEAD; do
echo "--- $rev"
for f in dist/wallets/keplr/index.d.ts dist/wallets/metamask/index.d.ts dist/wallets/solflare/index.d.ts; do
echo "[$f]"
git show "$rev:$f" 2>/dev/null | rg -n -C 3 \
'(getAccountAddressSchema|renameAccountSchema|addCustomNetworkSchema|addAccountSchema|export \{)' \
| head -80 || true
done
done
printf '%s\n' '=== relevant source at the last schema-containing revision ==='
rev="$(git log --all --format='%H' -S 'getAccountAddressSchema' -- src dist | tail -1)"
if [ -n "$rev" ]; then
echo "revision=$rev"
for f in src/wallets/keplr/types.ts src/wallets/metamask/types.ts src/wallets/solflare/types.ts \
src/wallets/keplr/index.ts src/wallets/metamask/index.ts src/wallets/solflare/index.ts; do
echo "[$f]"
git show "$rev:$f" 2>/dev/null | sed -n '1,90p' || true
done
fiRepository: TruFin-io/chainwright
Length of output: 151
🏁 Script executed:
#!/bin/bash
set -euo pipefail
for rev in HEAD^ HEAD; do
echo "=== $rev ==="
for f in dist/wallets/keplr/index.d.ts dist/wallets/metamask/index.d.ts dist/wallets/solflare/index.d.ts; do
echo "--- $f"
git show "$rev:$f" 2>/dev/null | grep -n -E \
'getAccountAddressSchema|renameAccountSchema|addCustomNetworkSchema|addAccountSchema|^export \{' \
| tail -12 || true
done
done
echo '=== source snapshots ==='
for rev in HEAD^ HEAD; do
echo "--- $rev"
for f in src/wallets/keplr/types.ts src/wallets/metamask/types.ts src/wallets/solflare/types.ts \
src/wallets/keplr/index.ts src/wallets/metamask/index.ts src/wallets/solflare/index.ts; do
echo "[$f]"
git show "$rev:$f" 2>/dev/null | grep -n -E \
'Schema|schema|export \*|export type \*|export type' || true
done
doneRepository: TruFin-io/chainwright
Length of output: 6055
🏁 Script executed:
#!/bin/bash
set -euo pipefail
for rev in HEAD^ HEAD; do
echo "=== $rev runtime files ==="
git ls-tree -r --name-only "$rev" dist/wallets/keplr dist/wallets/metamask dist/wallets/solflare \
| grep -E '\.(js|mjs|cjs)$' | head -30
for f in dist/wallets/keplr/index.js dist/wallets/metamask/index.js dist/wallets/solflare/index.js; do
echo "--- $f"
git show "$rev:$f" 2>/dev/null | grep -n -E \
'getAccountAddressSchema|renameAccountSchema|addCustomNetworkSchema|addAccountSchema|^export' \
| tail -20 || true
done
echo "--- all exact schema names in dist"
git grep -n -E \
'getAccountAddressSchema|renameAccountSchema|addCustomNetworkSchema|addAccountSchema' \
"$rev" -- 'dist/**' 2>/dev/null || true
doneRepository: TruFin-io/chainwright
Length of output: 1881
🏁 Script executed:
#!/bin/bash
set -euo pipefail
for rev in HEAD^ HEAD; do
echo "=== $rev entry-point tails ==="
for f in dist/wallets/keplr/index.js dist/wallets/metamask/index.js dist/wallets/solflare/index.js; do
echo "--- $f"
git show "$rev:$f" 2>/dev/null | tail -25
done
done
echo '=== package release metadata ==='
fd -a -t f '' .changeset 2>/dev/null | head -20 | while read -r f; do
echo "--- $f"
cat "$f"
done
echo '=== package scripts and published files ==='
jq '{version,files,scripts,exports}' package.jsonRepository: TruFin-io/chainwright
Length of output: 50378
Preserve addCustomNetworkSchema in the chainwright/metamask API.
The previous declaration exported this named value, but the current declaration does not. This breaks TypeScript consumers that import it. Keplr and Solflare did not expose equivalent public named exports. Restore the Metamask export or release the removal as a major change.
📍 Affects 3 files
src/wallets/keplr/types.ts#L44-L58(this comment)src/wallets/metamask/types.ts#L20-L25src/wallets/solflare/types.ts#L13-L16
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/wallets/keplr/types.ts` around lines 44 - 58, Restore the public named
addCustomNetworkSchema export in src/wallets/metamask/types.ts at lines 20-25 so
existing chainwright/metamask TypeScript consumers can import it; no direct
change is required in src/wallets/keplr/types.ts lines 44-58 or
src/wallets/solflare/types.ts lines 13-16, which do not expose equivalent named
exports.
| if (textContent?.includes(accountName)) { | ||
| accountListButton = account; | ||
| break; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Reject an empty account name before the account search.
An empty accountName makes textContent?.includes(accountName) true for the first account. The action can then switch to an unintended account. Restore runtime validation before the loop.
Proposed fix
export async function switchAccount(page: Page, accountName: string) {
+ if (accountName.length === 0) {
+ throw new Error("Account name must not be empty.");
+ }
+
const openMenuButton = page.getByTestId(menuSelectors.openMenuButton);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/wallets/phantom/actions/switch-account.phantom.ts` around lines 15 - 18,
Validate that accountName is non-empty before entering the account search loop
in the account-switching action, rejecting invalid input before evaluating
textContent?.includes(accountName). Preserve the existing account matching and
accountListButton selection behavior for valid names.
Summary
0.11.0patch release and updated the changelog.5.9.3to fix the release build.globdependency with Node.js filesystem APIs.22.18.