Skip to content

Commit

Permalink
Add getResult function to ContractFunctionParameters; added integ…
Browse files Browse the repository at this point in the history
…ration tests for arrays and updated array tests in `ContractFunctionParametersIntegrationTest`

Signed-off-by: Nikita Lebedev <nikita.lebedev@limechain.tech>
  • Loading branch information
thenswan committed Aug 3, 2023
1 parent 45c4e17 commit 45ca0fd
Show file tree
Hide file tree
Showing 3 changed files with 1,076 additions and 31 deletions.
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies {

implementation "com.google.code.gson:gson:2.10.1"
implementation 'javax.annotation:javax.annotation-api:1.3.2'
implementation "com.esaulpaugh:headlong:9.3.0"
implementation 'com.esaulpaugh:headlong:9.3.0'

testImplementation "org.assertj:assertj-core:3.24.2"
testImplementation "io.github.json-snapshot:json-snapshot:1.0.17"
Expand Down
1,088 changes: 1,063 additions & 25 deletions sdk/src/integrationTest/java/ContractFunctionParametersIntegrationTest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@
*/
package com.hedera.hashgraph.sdk;

import com.esaulpaugh.headlong.abi.Tuple;
import com.esaulpaugh.headlong.abi.TupleType;
import com.google.common.base.MoreObjects;
import com.google.protobuf.ByteString;
import com.google.protobuf.BytesValue;
import com.hedera.hashgraph.sdk.proto.ContractFunctionResultOrBuilder;
import org.bouncycastle.util.encoders.Hex;

import javax.annotation.Nullable;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;
import org.bouncycastle.util.encoders.Hex;

/**
* Result of invoking a contract via {@link ContractCallQuery}, or {@link ContractExecuteTransaction}, or the result of
Expand Down Expand Up @@ -111,8 +112,9 @@ public final class ContractFunctionResult {
@Nullable
public final AccountId senderAccountId;
/**
* A list of updated contract account nonces containing the new nonce value for each contract account.
* This is always empty in a ContractCallLocalResponse#ContractFunctionResult message, since no internal creations can happen in a static EVM call.
* A list of updated contract account nonces containing the new nonce value for each contract account. This is
* always empty in a ContractCallLocalResponse#ContractFunctionResult message, since no internal creations can
* happen in a static EVM call.
*/
public final List<ContractNonceInfo> contractNonces;
private final ByteString rawResult;
Expand Down Expand Up @@ -474,4 +476,9 @@ public String toString() {
.add("contractNonces", contractNonces)
.toString();
}

public Tuple getResult(String types) {
TupleType tupleType = TupleType.parse(types);
return tupleType.decode(rawResult.toByteArray());
}
}

0 comments on commit 45ca0fd

Please sign in to comment.