Skip to content

Commit

Permalink
hotfix: fix triggercontract abi check
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghang8612 committed Jun 21, 2021
1 parent 9943694 commit 3e24edc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions framework/src/main/java/org/tron/core/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -2471,15 +2471,20 @@ public Transaction triggerContract(TriggerSmartContract
Return.Builder retBuilder)
throws ContractValidateException, ContractExeException, HeaderNotFound, VMIllegalException {

AbiStore abiStore = chainBaseManager.getAbiStore();
byte[] contractAddress = triggerSmartContract.getContractAddress()
.toByteArray();
AbiCapsule abiCapsule = abiStore.get(contractAddress);
if (abiCapsule == null) {
ContractCapsule contractCapsule = chainBaseManager.getContractStore().get(contractAddress);
if (contractCapsule == null) {
throw new ContractValidateException(
"No contract or not a valid smart contract");
}
SmartContract.ABI abi = abiCapsule.getInstance();
AbiCapsule abiCapsule = chainBaseManager.getAbiStore().get(contractAddress);
SmartContract.ABI abi;
if (abiCapsule == null || abiCapsule.getData() == null) {
abi = SmartContract.ABI.getDefaultInstance();
} else {
abi = abiCapsule.getInstance();
}

byte[] selector = WalletUtil.getSelector(
triggerSmartContract.getData().toByteArray());
Expand Down Expand Up @@ -2580,7 +2585,7 @@ public SmartContract getContract(GrpcAPI.BytesMessage bytesMessage) {
ContractCapsule contractCapsule = chainBaseManager.getContractStore().get(address);
if (Objects.nonNull(contractCapsule)) {
AbiCapsule abiCapsule = chainBaseManager.getAbiStore().get(address);
if (Objects.nonNull(abiCapsule)) {
if (abiCapsule != null && abiCapsule.getInstance() != null) {
contractCapsule = new ContractCapsule(
contractCapsule.getInstance().toBuilder().setAbi(abiCapsule.getInstance()).build());
}
Expand Down Expand Up @@ -2609,7 +2614,7 @@ public SmartContractDataWrapper getContractInfo(GrpcAPI.BytesMessage bytesMessag
ContractCapsule contractCapsule = chainBaseManager.getContractStore().get(address);
if (Objects.nonNull(contractCapsule)) {
AbiCapsule abiCapsule = chainBaseManager.getAbiStore().get(address);
if (Objects.nonNull(abiCapsule)) {
if (abiCapsule != null && abiCapsule.getInstance() != null) {
contractCapsule = new ContractCapsule(
contractCapsule.getInstance().toBuilder().setAbi(abiCapsule.getInstance()).build());
}
Expand Down

0 comments on commit 3e24edc

Please sign in to comment.