Skip to content

Get the latest Chainwright changes - #9

Merged
11 commits merged into
mainfrom
tobe/get-latest
Aug 10, 2026
Merged

11 commits merged into
mainfrom
tobe/get-latest

Conversation

@ghost

@ghost ghost commented Aug 10, 2026

Copy link
Copy Markdown
  • [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 method

Summary

  • Upgraded Playwright and core dependencies.
  • Prepared the 0.11.0 patch release and updated the changelog.
  • Reverted TypeScript to 5.9.3 to fix the release build.
  • Replaced the glob dependency with Node.js filesystem APIs.
  • Removed Zod runtime validation and replaced it with explicit TypeScript types.
  • Added a root package export and increased the minimum Node.js version to 22.18.
  • Updated setup-file tests to use temporary filesystem fixtures.

@ghost
ghost requested a review from mgiagante August 10, 2026 15:28
@ghost ghost self-assigned this Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The 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.

Changes

Runtime and validation changes

Layer / File(s) Summary
Package and runtime wiring
package.json, pnpm-workspace.yaml, src/cli/index.ts, tsconfig.json, tsup.config.ts, CHANGELOG.md
The package now targets version 0.11.0, exports the core module, requires Node.js 22.18 or newer, updates tooling, and removes obsolete runtime dependencies.
Setup-file discovery
src/core/get-setup-function.ts, src/core/test/get-setup-function.test.ts
Setup discovery uses Node.js globSync, supports .mjs, excludes directories, and returns sorted paths. Tests create and remove temporary setup directories.
TypeScript wallet contracts
src/wallets/keplr/types.ts, src/wallets/metamask/types.ts, src/wallets/solflare/types.ts, src/utils/wallets/get-wallet-extension-id-from-browser.ts
Selected Zod schemas were replaced with explicit TypeScript types or direct type assertions.
Wallet action integration
src/wallets/keplr/actions/*, src/wallets/metamask/actions/*, src/wallets/petra/actions/*, src/wallets/phantom/actions/*, src/wallets/solflare/actions/*
Wallet actions now use supplied argument values without schema parsing or trimming.

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is generic and does not identify the main changes, such as dependency updates, the TypeScript rollback, or the glob replacement. Use a specific title that names the primary change, such as dependency updates and replacing glob with Node.js filesystem APIs.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@ghost
ghost merged commit 1c429de into main Aug 10, 2026
5 of 6 checks passed
@ghost
ghost deleted the tobe/get-latest branch August 10, 2026 15:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/core/test/get-setup-function.test.ts (1)

42-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for .setup.mjs discovery.

The production pattern now includes .setup.mjs, but this suite does not exercise that extension. Add a fixture with a .setup.mjs filename and assert that getSetupFunction imports 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

📥 Commits

Reviewing files that changed from the base of the PR and between e264449 and 3f81c41.

⛔ Files ignored due to path filters (11)
  • dist/cli/index.d.ts is excluded by !**/dist/**
  • dist/cli/index.js is excluded by !**/dist/**
  • dist/wallets/keplr/index.d.ts is excluded by !**/dist/**
  • dist/wallets/keplr/index.js is excluded by !**/dist/**
  • dist/wallets/metamask/index.d.ts is excluded by !**/dist/**
  • dist/wallets/metamask/index.js is excluded by !**/dist/**
  • dist/wallets/petra/index.js is excluded by !**/dist/**
  • dist/wallets/phantom/index.js is excluded by !**/dist/**
  • dist/wallets/solflare/index.d.ts is excluded by !**/dist/**
  • dist/wallets/solflare/index.js is excluded by !**/dist/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (20)
  • CHANGELOG.md
  • package.json
  • pnpm-workspace.yaml
  • src/cli/index.ts
  • src/core/get-setup-function.ts
  • src/core/test/get-setup-function.test.ts
  • src/utils/wallets/get-wallet-extension-id-from-browser.ts
  • src/wallets/keplr/actions/get-account-address.keplr.ts
  • src/wallets/keplr/actions/rename-account.keplr.ts
  • src/wallets/keplr/types.ts
  • src/wallets/metamask/actions/add-account.metamask.ts
  • src/wallets/metamask/actions/add-custom-network.metamask.ts
  • src/wallets/metamask/types.ts
  • src/wallets/petra/actions/rename-account.petra.ts
  • src/wallets/phantom/actions/get-account-address.phantom.ts
  • src/wallets/phantom/actions/switch-account.phantom.ts
  • src/wallets/solflare/actions/add-account.solflare.ts
  • src/wallets/solflare/types.ts
  • tsconfig.json
  • tsup.config.ts
💤 Files with no reviewable changes (1)
  • tsconfig.json

Comment thread CHANGELOG.md
Comment on lines +3 to +7
## 0.11.0

### Minor Changes

- [Core] - Replace the 'glob' package with Node.js internal method

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

Comment on lines +8 to +35
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 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.

Comment on lines +44 to +58
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;
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.md

Repository: 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.json

Repository: 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
done

Repository: 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
fi

Repository: 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
done

Repository: 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
done

Repository: 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.json

Repository: 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-L25
  • src/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.

Comment on lines +15 to 18
if (textContent?.includes(accountName)) {
accountListButton = account;
break;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant