Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"workspaces": {
"packages": [
"packages/*",
"packages/connect-examples/shared-constants",
"packages/connect-examples/expo-example",
"packages/connect-examples/electron-example",
"packages/connect-examples/expo-playground"
Expand Down Expand Up @@ -79,15 +78,16 @@
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^16.0.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

Verify @rollup/plugin-node-resolve is needed at root level.

Check if this plugin is used by packages other than expo-example. If only expo-example needs it, move it there.


🏁 Script executed:

#!/bin/bash
# Search for rollup config files and @rollup/plugin-node-resolve usage

echo "=== Finding rollup config files ==="
fd -e js -e ts -e mjs "rollup.config" --type f

echo ""
echo "=== Searching for @rollup/plugin-node-resolve usage ==="
rg -n --type=js --type=ts "plugin-node-resolve" -C 2

echo ""
echo "=== Checking package.json files for rollup dependencies ==="
fd "package.json" --type f --exec grep -l "rollup" {}

Length of output: 624


🏁 Script executed:

#!/bin/bash
# Check for @rollup/plugin-node-resolve in all package.json files

echo "=== Checking root package.json ==="
grep -n "@rollup/plugin-node-resolve" ./package.json

echo ""
echo "=== Checking expo-example package.json ==="
grep -n "@rollup/plugin-node-resolve" ./packages/expo-example/package.json 2>/dev/null || echo "File not found or no match"

echo ""
echo "=== Searching all package.json files for @rollup/plugin-node-resolve ==="
fd "package.json" --type f --exec grep -l "@rollup/plugin-node-resolve" {}

echo ""
echo "=== Checking build scripts in root package.json ==="
grep -A 5 '"scripts"' ./package.json | head -20

Length of output: 514


🏁 Script executed:

#!/bin/bash
# Check which packages have rollup and how they use it

echo "=== Packages with rollup dependencies ==="
fd "package.json" --type f --exec grep -l "rollup" {} | xargs grep -l '"rollup"' | while read f; do
  echo "File: $f"
  grep -E '"rollup"|"@rollup' "$f" | head -3
  echo ""
done

echo ""
echo "=== Build scripts in packages with rollup ==="
fd "package.json" --type f -path "*/packages/*/package.json" --exec grep -l "rollup" {} | while read f; do
  echo "=== $f ==="
  grep -A 10 '"scripts"' "$f" 2>/dev/null | grep -E '"scripts"|build|rollup' || echo "No build script found"
  echo ""
done

Length of output: 396


🏁 Script executed:

#!/bin/bash
# Check build scripts that reference rollup

echo "=== Build scripts in root package.json ==="
grep -A 20 '"scripts"' ./package.json | grep -E 'rollup|build'

echo ""
echo "=== All package.json files mentioning rollup in scripts ==="
fd "package.json" -type f --exec grep -l "rollup" {} \; | while read f; do
  if grep -q '"scripts"' "$f"; then
    echo "=== $f ==="
    grep -A 30 '"scripts"' "$f" | grep -B 2 -A 2 "rollup"
  fi
done

echo ""
echo "=== Direct check: Does expo-example exist? ==="
ls -la packages/ | grep expo

Length of output: 609


🏁 Script executed:

#!/bin/bash
# Final verification: check for any indirect rollup usage

echo "=== Check for rollup in root devDependencies ==="
grep -A 100 '"devDependencies"' ./package.json | grep -E 'rollup|@rollup' | head -10

echo ""
echo "=== Look for rollup in any config files ==="
find . -maxdepth 2 -type f \( -name "*.config.js" -o -name "*.config.ts" -o -name "tsconfig.json" -o -name "webpack.config.js" \) 2>/dev/null | xargs grep -l "rollup" 2>/dev/null || echo "No rollup refs in config files"

echo ""
echo "=== Check if packages directory has expo-related packages ==="
ls -1 packages/ | grep -i expo || echo "No expo packages found"

echo ""
echo "=== List all packages ==="
ls -1 packages/

Length of output: 717


🏁 Script executed:

#!/bin/bash
# Verify rollup.config.js uses plugin-node-resolve

echo "=== Content of ./build/rollup.config.js ==="
cat ./build/rollup.config.js

Length of output: 620


Remove @rollup/plugin-node-resolve from root devDependencies—it's unused.

The plugin doesn't appear in ./build/rollup.config.js or anywhere else in the codebase. The rollup config only uses typescript, json, dts, and commonjs plugins. Also, expo-example doesn't exist as a package, so the original assumption was incorrect. This is dead code that should be removed.

🤖 Prompt for AI Agents
In package.json around line 81, the devDependency "@rollup/plugin-node-resolve"
is unused and should be removed; delete the entry from the root devDependencies,
run your package manager to update lockfile (npm install or yarn install) and
verify no references remain (search build/rollup.config.js and the repo) before
committing.

"@rollup/plugin-typescript": "^8.3.2",
"@types/bchaddrjs": "^0.4.3",
"@types/jest": "^27.5.1",
"@types/node": "^18.18.8",
"@types/shelljs": "^0.8.11",
"electron-builder": "^24.9.1",
"babel-jest": "^28.1.3",
"babel-loader": "^8.2.5",
"cross-env": "^7.0.3",
"electron-builder": "^24.9.1",
"eslint": "^8.4.1",
"eslint-config-wesbos": "3.2.3",
"eslint-plugin-jest": "^26.6.0",
Expand Down
1 change: 1 addition & 0 deletions packages/connect-examples/expo-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@tamagui/toast": "1.90.2",
"@ton/core": "^0.57.0",
"asyncstorage-down": "^4.2.0",
"axios": "1.12.2",
"bchaddrjs": "^0.5.2",
"bitcoinjs-lib": "^6.1.5",
"bn.js": "^5.2.1",
Expand Down
33 changes: 33 additions & 0 deletions packages/connect-examples/expo-example/shim-axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Axios wrapper to fix module.exports.default for rollup compatibility
// eslint-disable-next-line @typescript-eslint/no-var-requires
const axios = require('axios');

// Create a proper wrapper that satisfies rollup's _interopDefaultLegacy expectations
// The compiled code uses: axios__default["default"].interceptors.request.use()
// So we need to ensure that when webpack resolves this, it has the right structure

// Ensure axios has a .default property pointing to itself
if (!axios.default) {
axios.default = axios;
}

// Also ensure interceptors exist
if (!axios.interceptors) {
// This shouldn't happen, but just in case, create a mock
axios.interceptors = {
request: {
use: fn => {
console.warn('axios.interceptors.request.use mock called');
return 0;
},
},
response: {
use: fn => {
console.warn('axios.interceptors.response.use mock called');
return 0;
},
},
};
}
Comment on lines +14 to +31
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Mock interceptors hide real problems instead of failing fast.

If axios.interceptors is missing, something is broken. Mock functions return 0 and log warnings, but code expecting real interceptor behavior will fail silently.

Replace the mock with an error:

-// Also ensure interceptors exist
-if (!axios.interceptors) {
-  // This shouldn't happen, but just in case, create a mock
-  axios.interceptors = {
-    request: {
-      use: fn => {
-        console.warn('axios.interceptors.request.use mock called');
-        return 0;
-      },
-    },
-    response: {
-      use: fn => {
-        console.warn('axios.interceptors.response.use mock called');
-        return 0;
-      },
-    },
-  };
-}
+// Verify interceptors exist (they should always be present in real axios)
+if (!axios.interceptors) {
+  throw new Error('axios.interceptors is missing - axios module may be corrupted');
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Also ensure interceptors exist
if (!axios.interceptors) {
// This shouldn't happen, but just in case, create a mock
axios.interceptors = {
request: {
use: fn => {
console.warn('axios.interceptors.request.use mock called');
return 0;
},
},
response: {
use: fn => {
console.warn('axios.interceptors.response.use mock called');
return 0;
},
},
};
}
// Verify interceptors exist (they should always be present in real axios)
if (!axios.interceptors) {
throw new Error('axios.interceptors is missing - axios module may be corrupted');
}
🤖 Prompt for AI Agents
In packages/connect-examples/expo-example/shim-axios.js around lines 14 to 31,
the current code silently provides mock axios.interceptors that return 0 and log
warnings; this hides real failures — replace the mock with a fail-fast behavior
by removing the mock interceptor objects and instead throw a clear, descriptive
Error when axios.interceptors is missing (e.g., "axios.interceptors missing —
ensure axios is properly installed/initialized"), or at minimum log the problem
and immediately throw so callers cannot continue with broken behavior.


module.exports = axios;
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-relative-packages
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove orphaned eslint-disable comment.

No relative imports exist in this file. The comment serves no purpose.

-// eslint-disable-next-line import/no-relative-packages
-
 export const CONNECT_SRC = process.env.CONNECT_SRC || `https://jssdk.onekey.so/1.1.17/`;
🤖 Prompt for AI Agents
In packages/connect-examples/expo-example/src/constants/connect.ts around line
1, there is an orphaned ESLint disable comment "// eslint-disable-next-line
import/no-relative-packages" that is not needed because no relative-package
imports exist in this file; remove that comment line to clean up the code and
let ESLint rules apply normally.

import { getConnectSrc } from '@onekey-internal/shared-constants';

export const CONNECT_SRC = getConnectSrc();
export const CONNECT_SRC = process.env.CONNECT_SRC || `https://jssdk.onekey.so/1.1.17/`;
7 changes: 7 additions & 0 deletions packages/connect-examples/expo-example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ module.exports = async function (env, argv) {
});
});

// Force axios to use our wrapper which ensures .default exists
config.resolve.alias = {
...config.resolve.alias,
// Force all axios imports to use our wrapper (no $ to match all imports including from node_modules)
axios: require.resolve('./shim-axios.js'),
};

// 保持其他配置不变
config.resolve.fallback = {
crypto: require.resolve('./shim/crypto'),
Expand Down
12 changes: 0 additions & 12 deletions packages/connect-examples/shared-constants/constants.js

This file was deleted.

10 changes: 0 additions & 10 deletions packages/connect-examples/shared-constants/package.json

This file was deleted.

59 changes: 49 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6041,6 +6041,17 @@
dependencies:
"@rollup/pluginutils" "^3.0.8"

"@rollup/plugin-node-resolve@^16.0.3":
version "16.0.3"
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.3.tgz#0988e6f2cbb13316b0f5e7213f757bc9ed44928f"
integrity sha512-lUYM3UBGuM93CnMPG1YocWu7X802BrNF3jW2zny5gQyLQgRFJhV1Sq0Zi74+dh/6NBx1DxFC4b4GXg9wUCG5Qg==
dependencies:
"@rollup/pluginutils" "^5.0.1"
"@types/resolve" "1.20.2"
deepmerge "^4.2.2"
is-module "^1.0.0"
resolve "^1.22.1"

"@rollup/plugin-typescript@^8.3.2":
version "8.3.2"
resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.3.2.tgz#e1b719e2ed3e752bbc092001656c48378f2d15f0"
Expand All @@ -6058,6 +6069,15 @@
estree-walker "^1.0.1"
picomatch "^2.2.2"

"@rollup/pluginutils@^5.0.1":
version "5.3.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-5.3.0.tgz#57ba1b0cbda8e7a3c597a4853c807b156e21a7b4"
integrity sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==
dependencies:
"@types/estree" "^1.0.0"
estree-walker "^2.0.2"
picomatch "^4.0.2"

"@rtsao/scc@^1.1.0":
version "1.1.0"
resolved "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz#927dd2fae9bc3361403ac2c7a00c32ddce9ad7e8"
Expand Down Expand Up @@ -8283,6 +8303,11 @@
"@types/scheduler" "*"
csstype "^3.0.2"

"@types/[email protected]":
version "1.20.2"
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.20.2.tgz#97d26e00cd4a0423b4af620abecf3e6f442b7975"
integrity sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==

"@types/responselike@^1.0.0":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.3.tgz#cc29706f0a397cfe6df89debfe4bf5cea159db50"
Expand Down Expand Up @@ -11068,7 +11093,7 @@ ci-info@^3.7.0:

[email protected], cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3:
version "1.0.5"
resolved "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.5.tgz#749f80731c7821e9a5fabd51f6998b696f296686"
resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.5.tgz#749f80731c7821e9a5fabd51f6998b696f296686"
integrity sha512-xq7ICKB4TMHUx7Tz1L9O2SGKOhYMOTR32oir45Bq28/AQTpHogKgHcoYFSdRbMtddl+ozNXfXY9jWcgYKmde0w==
dependencies:
inherits "^2.0.4"
Expand Down Expand Up @@ -13827,7 +13852,7 @@ estree-walker@^1.0.1:
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==

estree-walker@^2.0.1:
estree-walker@^2.0.1, estree-walker@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==
Expand Down Expand Up @@ -14138,9 +14163,9 @@ expo@^50.0.20:
whatwg-url-without-unicode "8.0.0-3"

exponential-backoff@^3.1.1:
version "3.1.2"
resolved "https://registry.yarnpkg.com/exponential-backoff/-/exponential-backoff-3.1.2.tgz#a8f26adb96bf78e8cd8ad1037928d5e5c0679d91"
integrity sha512-8QxYTVXUkuy7fIIoitQkPwGonB8F3Zj8eEO8Sqg9Zv/bkI7RJAzowee4gr81Hak/dUTpA2Z7VfQgoijjPNlUZA==
version "3.1.3"
resolved "https://registry.yarnpkg.com/exponential-backoff/-/exponential-backoff-3.1.3.tgz#51cf92c1c0493c766053f9d3abee4434c244d2f6"
integrity sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA==

express@^4.17.3:
version "4.18.2"
Expand Down Expand Up @@ -15742,7 +15767,7 @@ http2-wrapper@^1.0.0-beta.5.2:

https-browserify@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
integrity sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg==

https-proxy-agent@^5.0.0, https-proxy-agent@^5.0.1:
Expand Down Expand Up @@ -16047,9 +16072,9 @@ invariant@^2.2.4:
loose-envify "^1.0.0"

ip-address@^10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/ip-address/-/ip-address-10.0.1.tgz#a8180b783ce7788777d796286d61bce4276818ed"
integrity sha512-NWv9YLW4PoW2B7xtzaS3NCot75m6nK7Icdv0o3lfMceJVRfSoQwqD4wEH5rLwoKJwUiZ/rfpiVBhnaF0FK4HoA==
version "10.1.0"
resolved "https://registry.yarnpkg.com/ip-address/-/ip-address-10.1.0.tgz#d8dcffb34d0e02eb241427444a6e23f5b0595aa4"
integrity sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==

ip-regex@^2.1.0:
version "2.1.0"
Expand Down Expand Up @@ -16374,6 +16399,11 @@ is-map@^2.0.3:
resolved "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz#ede96b7fe1e270b3c4465e3a465658764926d62e"
integrity sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==

is-module@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591"
integrity sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==

is-nan@^1.2.1:
version "1.3.2"
resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.2.tgz#043a54adea31748b55b6cd4e09aadafa69bd9e1d"
Expand Down Expand Up @@ -22495,6 +22525,15 @@ resolve@^1.1.7, resolve@^1.22.10, resolve@^1.22.8:
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"

resolve@^1.22.1:
version "1.22.11"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.11.tgz#aad857ce1ffb8bfa9b0b1ac29f1156383f68c262"
integrity sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==
dependencies:
is-core-module "^2.16.1"
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"

resolve@^2.0.0-next.4, resolve@^2.0.0-next.5:
version "2.0.0-next.5"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.5.tgz#6b0ec3107e671e52b68cd068ef327173b90dc03c"
Expand Down Expand Up @@ -23633,7 +23672,7 @@ [email protected]:

stream-http@^3.2.0:
version "3.2.0"
resolved "https://registry.npmjs.org/stream-http/-/stream-http-3.2.0.tgz#1872dfcf24cb15752677e40e5c3f9cc1926028b5"
resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-3.2.0.tgz#1872dfcf24cb15752677e40e5c3f9cc1926028b5"
integrity sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A==
dependencies:
builtin-status-codes "^3.0.0"
Expand Down
Loading