-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_openzeppelin_error.cjs
More file actions
51 lines (41 loc) · 1.46 KB
/
test_openzeppelin_error.cjs
File metadata and controls
51 lines (41 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { solidityCompiler } = require('@agnostico/browser-solidity-compiler');
async function testOpenZeppelinError() {
console.log('Testing OpenZeppelin compilation error...');
// This is the exact ERC20 template that causes the error
const contractBody = `// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract TokenTest1 is ERC20 {
constructor(
string memory name,
string memory symbol,
uint256 totalSupply,
uint8 decimals
) ERC20(name, symbol) {
_mint(msg.sender, totalSupply * 10**decimals);
}
}`;
console.log('Contract source code:');
console.log(contractBody);
console.log('\n--- Attempting compilation ---');
try {
const result = await solidityCompiler({
version: 'https://binaries.soliditylang.org/bin/soljson-v0.8.19+commit.7dd6d404.js',
contractBody,
options: {}
});
console.log('Compilation result:', JSON.stringify(result, null, 2));
if (result.errors && result.errors.length > 0) {
console.log('\n❌ COMPILATION FAILED AS EXPECTED');
console.log('Errors:');
result.errors.forEach((error, index) => {
console.log(`${index + 1}. ${error.formattedMessage || error.message}`);
});
} else {
console.log('\n✅ COMPILATION SUCCEEDED (unexpected)');
}
} catch (error) {
console.error('\n❌ COMPILATION ERROR:', error.message);
}
}
testOpenZeppelinError();