Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
wenlinlee committed Jun 27, 2024
1 parent a79bb1b commit d657b54
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/console/common/ConsoleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ public static void main(String[] args) {
String LIBS_OPTION = "libraries";

String SOL_VERSION_OPTION = "sol-version";
Version DEFAULT_SOL_VERSION = Version.V0_8_26;
Version DEFAULT_SOL_VERSION = Version.V0_8_11;

String BIN_OPTION = "bin";
String SM_BIN_OPTION = "sm-bin";
Expand Down
27 changes: 24 additions & 3 deletions src/main/java/console/contract/ConsoleContractImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,18 @@ public TransactionResponse deploySolidity(
throws ConsoleMessageException {
try {
boolean isContractParallelAnalysis = false;
Version version = Version.V0_8_26;
Version version = Version.V0_8_11;
try {
String flag =
client.getSystemConfigByKey("feature_evm_cancun")
.getSystemConfig()
.getValue();
if (Integer.parseInt(flag) == 1) {
version = Version.V0_8_26;
}
} catch (Exception e) {
version = Version.V0_8_11;
}
if (!inputParams.isEmpty()) {
int lastIndexOf = inputParams.lastIndexOf("-p");
if (lastIndexOf != -1) {
Expand Down Expand Up @@ -1077,10 +1088,20 @@ private String getSolidityAbi(String contractFileName) throws Exception {

List<SolidityCompiler.Option> defaultOptions = Arrays.asList(ABI, BIN, METADATA);
List<SolidityCompiler.Option> options = new ArrayList<>(defaultOptions);
Version version = Version.V0_8_11;
try {
String flag =
client.getSystemConfigByKey("feature_evm_cancun").getSystemConfig().getValue();
if (Integer.parseInt(flag) == 1) {
version = Version.V0_8_26;
}
} catch (Exception e) {
version = Version.V0_8_11;
}

logger.debug(
"compileSolToBinAndAbi, solc version:{} ,basePath: {}",
Version.V0_8_26,
version,
solFile.getParentFile().getCanonicalPath());
SolidityCompiler.Option basePath =
new SolidityCompiler.CustomOption(
Expand All @@ -1093,7 +1114,7 @@ private String getSolidityAbi(String contractFileName) throws Exception {
solFile,
(client.getCryptoType() == CryptoType.SM_TYPE),
true,
Version.V0_8_26,
version,
options.toArray(new SolidityCompiler.Option[0]));

if (logger.isDebugEnabled()) {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/contract/solidity/HelloWorld.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pragma solidity >=0.6.10 <=0.8.26;

contract HelloWorld {
string name;
Expand Down

0 comments on commit d657b54

Please sign in to comment.