Skip to content

Commit

Permalink
Fixed paramter handling for smart contract invocations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Lai committed Feb 5, 2024
1 parent 779c0b4 commit 92aee44
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Introduced Cis2Client for interfacing with CIS2 compliant smart contracts.
- Support for deserializing contract update transactions.
- Fix a bug where contract invocations used wrong format for parameters.

## 6.1.0
- Purge remaining usages of V1 GRPC API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@ static com.concordium.grpc.v2.ReceiveName to(ReceiveName receiveName) {

static com.concordium.grpc.v2.Parameter to(Parameter parameter) {
return com.concordium.grpc.v2.Parameter.newBuilder()
.setValue(ByteString.copyFrom(parameter.getBytes()))
.setValue(ByteString.copyFrom(parameter.getBytesForContractInvocation()))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.concordium.sdk.transactions;

import com.concordium.sdk.requests.smartcontracts.InvokeInstanceRequest;
import com.concordium.sdk.responses.ProtocolVersion;
import com.concordium.sdk.transactions.smartcontracts.SchemaParameter;
import com.concordium.sdk.types.UInt16;
Expand Down Expand Up @@ -52,6 +53,18 @@ public byte[] getBytes() {
return buffer.array();
}

/**
* Get the parameter bytes for contract invocation i.e. off-chain operation.
* This differs from {@link Parameter#getBytes()} as this does not prepend the
* returned byte array with the length of the parameters.
*
* This function should be only be used for {@link com.concordium.sdk.ClientV2#invokeInstance(InvokeInstanceRequest)} calls.
* @return the parameters
*/
public byte[] getBytesForContractInvocation() {
return this.bytes;
}

/**
* Constructs a {@link Parameter} from the provided {@link SchemaParameter}.
* Provided {@link SchemaParameter} must be initialized using {@link SchemaParameter#initialize()} beforehand.
Expand Down

0 comments on commit 92aee44

Please sign in to comment.