diff --git a/contract-module/base/contract-base/src/main/java/io/nuls/contract/service/impl/ContractServiceImpl.java b/contract-module/base/contract-base/src/main/java/io/nuls/contract/service/impl/ContractServiceImpl.java index 78e244fea..69997f890 100644 --- a/contract-module/base/contract-base/src/main/java/io/nuls/contract/service/impl/ContractServiceImpl.java +++ b/contract-module/base/contract-base/src/main/java/io/nuls/contract/service/impl/ContractServiceImpl.java @@ -1262,7 +1262,9 @@ private byte[] handleContractTransferTxs(CallContractTransaction tx, ContractRes // 如果合约转账(从合约转出)出现错误,整笔合约交易视作合约执行失败 if (!isCorrectContractTransfer) { - Log.error("contract transfer execution failed, reason: {}", contractResult.getErrorMessage()); + if(Log.isDebugEnabled()) { + Log.debug("contract transfer execution failed, reason: {}", contractResult.getErrorMessage()); + } // 执行合约产生的状态根回滚到上一个世界状态 stateRoot = preStateRoot; contractResult.setStateRoot(stateRoot); diff --git a/contract-module/base/contract-rpc/src/main/java/io/nuls/contract/rpc/model/ContractTransactionCreatedReturnInfo.java b/contract-module/base/contract-rpc/src/main/java/io/nuls/contract/rpc/model/ContractTransactionCreatedReturnInfo.java new file mode 100644 index 000000000..823f1f9fc --- /dev/null +++ b/contract-module/base/contract-rpc/src/main/java/io/nuls/contract/rpc/model/ContractTransactionCreatedReturnInfo.java @@ -0,0 +1,49 @@ +/** + * MIT License + *

+ * Copyright (c) 2017-2018 nuls.io + *

+ * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + *

+ * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + *

+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package io.nuls.contract.rpc.model; + + +import io.nuls.accout.ledger.rpc.dto.TransactionCreatedReturnInfo; + +/** + * @author: PierreLuo + * @date: 2018/11/22 + */ +public class ContractTransactionCreatedReturnInfo extends TransactionCreatedReturnInfo { + + private String contractAddress; + + public ContractTransactionCreatedReturnInfo(TransactionCreatedReturnInfo info, String contractAddress) { + super(info.getHash(), info.getTxHex(), info.getInputs(), info.getOutputs()); + this.contractAddress = contractAddress; + } + + public String getContractAddress() { + return contractAddress; + } + + public void setContractAddress(String contractAddress) { + this.contractAddress = contractAddress; + } +} diff --git a/contract-module/base/contract-rpc/src/main/java/io/nuls/contract/rpc/resource/ContractSdkResource.java b/contract-module/base/contract-rpc/src/main/java/io/nuls/contract/rpc/resource/ContractSdkResource.java index 755bd4286..582576936 100644 --- a/contract-module/base/contract-rpc/src/main/java/io/nuls/contract/rpc/resource/ContractSdkResource.java +++ b/contract-module/base/contract-rpc/src/main/java/io/nuls/contract/rpc/resource/ContractSdkResource.java @@ -40,6 +40,7 @@ import io.nuls.contract.rpc.form.transaction.CallContractTx; import io.nuls.contract.rpc.form.transaction.CreateContractTx; import io.nuls.contract.rpc.form.transaction.DeleteContractTx; +import io.nuls.contract.rpc.model.ContractTransactionCreatedReturnInfo; import io.nuls.contract.util.ContractUtil; import io.nuls.core.tools.calc.LongUtils; import io.nuls.core.tools.crypto.Hex; @@ -63,6 +64,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -170,7 +172,7 @@ public RpcClientResult createContractTx( return Result.getFailed(TransactionErrorCode.DATA_SIZE_ERROR).toRpcClientResult(); } - return this.buildReturnInfo(tx); + return this.buildReturnInfo(tx, AddressTool.getStringAddressByBytes(contractAddressBytes)); } @POST @@ -272,7 +274,7 @@ public RpcClientResult callContractTx( return Result.getFailed(TransactionErrorCode.DATA_SIZE_ERROR).toRpcClientResult(); } - return this.buildReturnInfo(tx); + return this.buildReturnInfo(tx, contractAddress); } @@ -340,14 +342,14 @@ public RpcClientResult deleteContractTx( return Result.getFailed(TransactionErrorCode.DATA_SIZE_ERROR).toRpcClientResult(); } - return this.buildReturnInfo(tx); + return this.buildReturnInfo(tx, contractAddress); } - private RpcClientResult buildReturnInfo(Transaction tx) { + private RpcClientResult buildReturnInfo(Transaction tx, String contractAddress) { try { TransactionCreatedReturnInfo returnInfo = LedgerRpcUtil.makeReturnInfo(tx); - Map data = new HashMap<>(); - data.put("value", returnInfo); + Map data = new LinkedHashMap<>(); + data.put("value", new ContractTransactionCreatedReturnInfo(returnInfo, contractAddress)); return Result.getSuccess().setData(data).toRpcClientResult(); } catch (IOException e) { Log.error(e); diff --git a/contract-module/base/contract-storage/src/main/java/io/nuls/contract/storage/service/impl/ContractUtxoStorageServiceImpl.java b/contract-module/base/contract-storage/src/main/java/io/nuls/contract/storage/service/impl/ContractUtxoStorageServiceImpl.java index 4c0728d56..c991c1ae6 100644 --- a/contract-module/base/contract-storage/src/main/java/io/nuls/contract/storage/service/impl/ContractUtxoStorageServiceImpl.java +++ b/contract-module/base/contract-storage/src/main/java/io/nuls/contract/storage/service/impl/ContractUtxoStorageServiceImpl.java @@ -87,11 +87,6 @@ public Result>> batchSaveAndDeleteUTXO(List(key, deleteUtxo)); - }*/ batch.delete(key); } }