Skip to content

Commit ea693e3

Browse files
committed
init
1 parent 3fb5b96 commit ea693e3

4 files changed

Lines changed: 130 additions & 5 deletions

File tree

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jest.config.js
2525
# Dependencies
2626
node_modules/**
2727
!node_modules/chokidar/**
28+
!node_modules/solc/**
2829

2930
# Development files
3031
**/*.ts

package-lock.json

Lines changed: 95 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
"commander": "^9.4.1",
295295
"glob": "^8.0.3",
296296
"js-sha3": "^0.8.0",
297+
"solc": "^0.8.33",
297298
"sqlite3": "^5.1.6"
298299
},
299300
"bin": {

src/features/solc-integration.ts

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,49 @@ export class SolcIntegration {
6969
* Find solc executable in system
7070
*/
7171
private findSolc(): string {
72+
// First, try to find bundled solcjs in node_modules (for extension packaging)
73+
const bundledSolcPaths = [
74+
path.join(__dirname, '../../node_modules/.bin/solcjs'),
75+
path.join(__dirname, '../../../node_modules/.bin/solcjs'),
76+
path.join(process.cwd(), 'node_modules/.bin/solcjs'),
77+
];
78+
79+
for (const p of bundledSolcPaths) {
80+
try {
81+
if (fs.existsSync(p)) {
82+
execSync(`${p} --version`, { stdio: 'ignore' });
83+
return p;
84+
}
85+
} catch (error) {
86+
continue;
87+
}
88+
}
89+
90+
try {
91+
// Try to find solcjs in PATH
92+
const result = execSync('which solcjs', { encoding: 'utf-8' }).trim();
93+
if (result) {
94+
return result;
95+
}
96+
} catch (error) {
97+
// Not found in PATH
98+
}
99+
72100
try {
73-
// Try to find solc in PATH
101+
// Try to find native solc in PATH
74102
const result = execSync('which solc', { encoding: 'utf-8' }).trim();
75103
if (result) {
76104
return result;
77105
}
78106
} catch (error) {
79-
// Not found in PATH - solc not available
107+
// Not found in PATH
80108
}
81109

82-
// Common installation paths
110+
// Common installation paths for native solc
83111
const commonPaths = [
84112
'/usr/local/bin/solc',
85113
'/usr/bin/solc',
114+
'solcjs', // Global install
86115
'solc', // Will work if in PATH
87116
];
88117

@@ -91,12 +120,11 @@ export class SolcIntegration {
91120
execSync(`${p} --version`, { stdio: 'ignore' });
92121
return p;
93122
} catch (error) {
94-
// This path doesn't work, try next
95123
continue;
96124
}
97125
}
98126

99-
return 'solc'; // Default, will fail if not available
127+
return 'solcjs'; // Default to solcjs, will fail if not available
100128
}
101129

102130
/**

0 commit comments

Comments
 (0)