Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `submitTimeout` bounds the polling loop only. Each individual request is still bounded by the `SorobanServer` HTTP timeouts.
- This applies to `submit`, `signAndSubmit`, `restoreFootprint`, and therefore to `ContractClient.invoke` when it submits.
- fix: always encode text as UTF-8 in `Scv.toString(String)`, `Sep10Challenge` (`web_auth_domain` / `client_domain`), `Util.paddedByteArray(String, int)`, and the `SorobanServer` request body. They used the JVM default charset, so non-ASCII text produced different bytes on JVMs where that is not UTF-8.
- chore: upgrade generated XDR definitions to Protocol 30.

## 5.0.0

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ xdr/Stellar-transaction.x \
xdr/Stellar-types.x

# stellar-xdr commit to use, see https://github.com/stellar/stellar-xdr
XDR_COMMIT=9c9c145953e80990d6ff1ae3a6a973a0ce6d0694
XDR_COMMIT=4f524bbac80c781c06e4fb5fc93a2d0d331d6705

.PHONY: xdr xdr-clean xdr-update xdr-generator-test xdr-generator-update-snapshots

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/stellar/sdk/contract/ContractSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public Optional<SCSpecEventV0> getEvent(String name) {
return Optional.empty();
}
for (SCSpecEventV0 event : getEvents()) {
if (name.equals(decodeSymbol(event.getName()))) {
if (name.equals(decodeString(event.getName()))) {
return Optional.of(event);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/stellar/sdk/xdr/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private Constants() {}
public static final int MAX_SIGNERS = 20;
public static final int SCSYMBOL_LIMIT = 32;
public static final int SC_SPEC_DOC_LIMIT = 1024;
public static final int SC_SPEC_TYPE_NAME_LIMIT = 1024;
public static final int TX_ADVERT_VECTOR_MAX_SIZE = 1000;
public static final int TX_DEMAND_VECTOR_MAX_SIZE = 1000;
}
85 changes: 83 additions & 2 deletions src/main/java/org/stellar/sdk/xdr/ContractCostType.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,25 @@
* // Cost of performing BN254 scalar element inversion
* Bn254FrInv = 84,
* // Cost of performing BN254 G1 multi-scalar multiplication (MSM)
* Bn254G1Msm = 85
* Bn254G1Msm = 85,
* // Cost of decoding and expanding an ML-DSA-44 verifying key
* MlDsa44DecodeVerifyingKey = 86,
* // Cost of decoding and expanding an ML-DSA-65 verifying key
* MlDsa65DecodeVerifyingKey = 87,
* // Cost of decoding and expanding an ML-DSA-87 verifying key
* MlDsa87DecodeVerifyingKey = 88,
* // Cost of decoding an ML-DSA-44 signature
* MlDsa44DecodeSignature = 89,
* // Cost of decoding an ML-DSA-65 signature
* MlDsa65DecodeSignature = 90,
* // Cost of decoding an ML-DSA-87 signature
* MlDsa87DecodeSignature = 91,
* // Cost of verifying an ML-DSA-44 signature, linear in message + context length
* VerifyMlDsa44Sig = 92,
* // Cost of verifying an ML-DSA-65 signature, linear in message + context length
* VerifyMlDsa65Sig = 93,
* // Cost of verifying an ML-DSA-87 signature, linear in message + context length
* VerifyMlDsa87Sig = 94
* };
* </pre>
*/
Expand Down Expand Up @@ -284,7 +302,16 @@ public enum ContractCostType implements XdrElement {
Bn254FrMul(82),
Bn254FrPow(83),
Bn254FrInv(84),
Bn254G1Msm(85);
Bn254G1Msm(85),
MlDsa44DecodeVerifyingKey(86),
MlDsa65DecodeVerifyingKey(87),
MlDsa87DecodeVerifyingKey(88),
MlDsa44DecodeSignature(89),
MlDsa65DecodeSignature(90),
MlDsa87DecodeSignature(91),
VerifyMlDsa44Sig(92),
VerifyMlDsa65Sig(93),
VerifyMlDsa87Sig(94);

private final int value;

Expand Down Expand Up @@ -473,6 +500,24 @@ public static ContractCostType decode(XdrDataInputStream stream, int maxDepth)
return Bn254FrInv;
case 85:
return Bn254G1Msm;
case 86:
return MlDsa44DecodeVerifyingKey;
case 87:
return MlDsa65DecodeVerifyingKey;
case 88:
return MlDsa87DecodeVerifyingKey;
case 89:
return MlDsa44DecodeSignature;
case 90:
return MlDsa65DecodeSignature;
case 91:
return MlDsa87DecodeSignature;
case 92:
return VerifyMlDsa44Sig;
case 93:
return VerifyMlDsa65Sig;
case 94:
return VerifyMlDsa87Sig;
default:
throw new IllegalArgumentException("Unknown enum value: " + value);
}
Expand Down Expand Up @@ -681,6 +726,24 @@ Object toJsonObject() {
return "bn254frinv";
case Bn254G1Msm:
return "bn254g1msm";
case MlDsa44DecodeVerifyingKey:
return "mldsa44decodeverifyingkey";
case MlDsa65DecodeVerifyingKey:
return "mldsa65decodeverifyingkey";
case MlDsa87DecodeVerifyingKey:
return "mldsa87decodeverifyingkey";
case MlDsa44DecodeSignature:
return "mldsa44decodesignature";
case MlDsa65DecodeSignature:
return "mldsa65decodesignature";
case MlDsa87DecodeSignature:
return "mldsa87decodesignature";
case VerifyMlDsa44Sig:
return "verifymldsa44sig";
case VerifyMlDsa65Sig:
return "verifymldsa65sig";
case VerifyMlDsa87Sig:
return "verifymldsa87sig";
default:
throw new IllegalArgumentException("Unknown enum value: " + this.value);
}
Expand Down Expand Up @@ -861,6 +924,24 @@ static ContractCostType fromJsonObject(Object json) {
return Bn254FrInv;
case "bn254g1msm":
return Bn254G1Msm;
case "mldsa44decodeverifyingkey":
return MlDsa44DecodeVerifyingKey;
case "mldsa65decodeverifyingkey":
return MlDsa65DecodeVerifyingKey;
case "mldsa87decodeverifyingkey":
return MlDsa87DecodeVerifyingKey;
case "mldsa44decodesignature":
return MlDsa44DecodeSignature;
case "mldsa65decodesignature":
return MlDsa65DecodeSignature;
case "mldsa87decodesignature":
return MlDsa87DecodeSignature;
case "verifymldsa44sig":
return VerifyMlDsa44Sig;
case "verifymldsa65sig":
return VerifyMlDsa65Sig;
case "verifymldsa87sig":
return VerifyMlDsa87Sig;
default:
throw new IllegalArgumentException("Unknown JSON value: " + value);
}
Expand Down
103 changes: 103 additions & 0 deletions src/main/java/org/stellar/sdk/xdr/MuxedContract.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten

package org.stellar.sdk.xdr;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.stellar.sdk.Base64Factory;

/**
* MuxedContract's original definition in the XDR file is:
*
* <pre>
* struct MuxedContract
* {
* uint64 id;
* ContractID contractId;
* };
* </pre>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
public class MuxedContract implements XdrElement {
/**
* Value of the {@code id} field.
*
* @param id the {@code id} field value
* @return the {@code id} field value
*/
private Uint64 id;

/**
* Value of the {@code contractId} field.
*
* @param contractId the {@code contractId} field value
* @return the {@code contractId} field value
*/
private ContractID contractId;

public void encode(XdrDataOutputStream stream) throws IOException {
id.encode(stream);
contractId.encode(stream);
}

public static MuxedContract decode(XdrDataInputStream stream, int maxDepth) throws IOException {
if (maxDepth <= 0) {
throw new IOException("Maximum decoding depth reached");
}
maxDepth -= 1;
MuxedContract decodedMuxedContract = new MuxedContract();
decodedMuxedContract.id = Uint64.decode(stream, maxDepth);
decodedMuxedContract.contractId = ContractID.decode(stream, maxDepth);
return decodedMuxedContract;
}

public static MuxedContract decode(XdrDataInputStream stream) throws IOException {
return decode(stream, XdrDataInputStream.DEFAULT_MAX_DEPTH);
}

public static MuxedContract fromXdrBase64(String xdr) throws IOException {
byte[] bytes = Base64Factory.getInstance().decode(xdr);
return fromXdrByteArray(bytes);
}

public static MuxedContract fromXdrByteArray(byte[] xdr) throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
xdrDataInputStream.setMaxInputLen(xdr.length);
return decode(xdrDataInputStream);
}

@Override
public String toJson() {
return XdrElement.gson.toJson(toJsonObject());
}

public static MuxedContract fromJson(String json) {
return fromJsonObject(XdrElement.gson.fromJson(json, Object.class));
}

Object toJsonObject() {
LinkedHashMap<String, Object> jsonMap = new LinkedHashMap<>();
jsonMap.put("id", id.toJsonObject());
jsonMap.put("contract_id", contractId.toJsonObject());
return jsonMap;
}

@SuppressWarnings("unchecked")
static MuxedContract fromJsonObject(Object json) {
java.util.Map<String, Object> jsonMap = (java.util.Map<String, Object>) json;
MuxedContract instance = new MuxedContract();
instance.id = Uint64.fromJsonObject(jsonMap.get("id"));
instance.contractId = ContractID.fromJsonObject(jsonMap.get("contract_id"));
return instance;
}
}
16 changes: 16 additions & 0 deletions src/main/java/org/stellar/sdk/xdr/SCAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* ClaimableBalanceID claimableBalanceId;
* case SC_ADDRESS_TYPE_LIQUIDITY_POOL:
* PoolID liquidityPoolId;
* case SC_ADDRESS_TYPE_MUXED_CONTRACT:
* MuxedContract muxedContract;
* };
* </pre>
*/
Expand Down Expand Up @@ -85,6 +87,14 @@ public class SCAddress implements XdrElement {
*/
private PoolID liquidityPoolId;

/**
* Value of the {@code muxedContract} field.
*
* @param muxedContract the {@code muxedContract} field value
* @return the {@code muxedContract} field value
*/
private MuxedContract muxedContract;

public void encode(XdrDataOutputStream stream) throws IOException {
stream.writeInt(discriminant.getValue());
switch (discriminant) {
Expand All @@ -103,6 +113,9 @@ public void encode(XdrDataOutputStream stream) throws IOException {
case SC_ADDRESS_TYPE_LIQUIDITY_POOL:
liquidityPoolId.encode(stream);
break;
case SC_ADDRESS_TYPE_MUXED_CONTRACT:
muxedContract.encode(stream);
break;
}
}

Expand Down Expand Up @@ -130,6 +143,9 @@ public static SCAddress decode(XdrDataInputStream stream, int maxDepth) throws I
case SC_ADDRESS_TYPE_LIQUIDITY_POOL:
decodedSCAddress.liquidityPoolId = PoolID.decode(stream, maxDepth);
break;
case SC_ADDRESS_TYPE_MUXED_CONTRACT:
decodedSCAddress.muxedContract = MuxedContract.decode(stream, maxDepth);
break;
default:
throw new IOException("Unknown discriminant value: " + discriminant);
}
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/stellar/sdk/xdr/SCAddressType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
* SC_ADDRESS_TYPE_CONTRACT = 1,
* SC_ADDRESS_TYPE_MUXED_ACCOUNT = 2,
* SC_ADDRESS_TYPE_CLAIMABLE_BALANCE = 3,
* SC_ADDRESS_TYPE_LIQUIDITY_POOL = 4
* SC_ADDRESS_TYPE_LIQUIDITY_POOL = 4,
* SC_ADDRESS_TYPE_MUXED_CONTRACT = 5
* };
* </pre>
*/
Expand All @@ -26,7 +27,8 @@ public enum SCAddressType implements XdrElement {
SC_ADDRESS_TYPE_CONTRACT(1),
SC_ADDRESS_TYPE_MUXED_ACCOUNT(2),
SC_ADDRESS_TYPE_CLAIMABLE_BALANCE(3),
SC_ADDRESS_TYPE_LIQUIDITY_POOL(4);
SC_ADDRESS_TYPE_LIQUIDITY_POOL(4),
SC_ADDRESS_TYPE_MUXED_CONTRACT(5);

private final int value;

Expand All @@ -52,6 +54,8 @@ public static SCAddressType decode(XdrDataInputStream stream, int maxDepth) thro
return SC_ADDRESS_TYPE_CLAIMABLE_BALANCE;
case 4:
return SC_ADDRESS_TYPE_LIQUIDITY_POOL;
case 5:
return SC_ADDRESS_TYPE_MUXED_CONTRACT;
default:
throw new IllegalArgumentException("Unknown enum value: " + value);
}
Expand Down Expand Up @@ -98,6 +102,8 @@ Object toJsonObject() {
return "claimable_balance";
case SC_ADDRESS_TYPE_LIQUIDITY_POOL:
return "liquidity_pool";
case SC_ADDRESS_TYPE_MUXED_CONTRACT:
return "muxed_contract";
default:
throw new IllegalArgumentException("Unknown enum value: " + this.value);
}
Expand All @@ -116,6 +122,8 @@ static SCAddressType fromJsonObject(Object json) {
return SC_ADDRESS_TYPE_CLAIMABLE_BALANCE;
case "liquidity_pool":
return SC_ADDRESS_TYPE_LIQUIDITY_POOL;
case "muxed_contract":
return SC_ADDRESS_TYPE_MUXED_CONTRACT;
default:
throw new IllegalArgumentException("Unknown JSON value: " + value);
}
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/org/stellar/sdk/xdr/SCSpecEventV0.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* {
* string doc&lt;SC_SPEC_DOC_LIMIT&gt;;
* string lib&lt;80&gt;;
* SCSymbol name;
* string name&lt;SC_SPEC_TYPE_NAME_LIMIT&gt;;
* SCSymbol prefixTopics&lt;2&gt;;
* SCSpecEventParamV0 params&lt;&gt;;
* SCSpecEventDataFormat dataFormat;
Expand Down Expand Up @@ -55,7 +55,7 @@ public class SCSpecEventV0 implements XdrElement {
* @param name the {@code name} field value
* @return the {@code name} field value
*/
private SCSymbol name;
private XdrString name;

/**
* Value of the {@code prefixTopics} field.
Expand Down Expand Up @@ -92,6 +92,10 @@ public void encode(XdrDataOutputStream stream) throws IOException {
throw new IOException("lib size " + libSize + " exceeds max size 80");
}
lib.encode(stream);
int nameSize = name.getBytes().length;
if (nameSize > 1024) {
throw new IOException("name size " + nameSize + " exceeds max size 1024");
}
name.encode(stream);
int prefixTopicsSize = getPrefixTopics().length;
if (prefixTopicsSize > 2) {
Expand All @@ -117,7 +121,8 @@ public static SCSpecEventV0 decode(XdrDataInputStream stream, int maxDepth) thro
SCSpecEventV0 decodedSCSpecEventV0 = new SCSpecEventV0();
decodedSCSpecEventV0.doc = XdrString.decode(stream, maxDepth, Constants.SC_SPEC_DOC_LIMIT);
decodedSCSpecEventV0.lib = XdrString.decode(stream, maxDepth, 80);
decodedSCSpecEventV0.name = SCSymbol.decode(stream, maxDepth);
decodedSCSpecEventV0.name =
XdrString.decode(stream, maxDepth, Constants.SC_SPEC_TYPE_NAME_LIMIT);
int prefixTopicsSize = stream.readInt();
if (prefixTopicsSize < 0) {
throw new IOException("prefixTopics size " + prefixTopicsSize + " is negative");
Expand Down Expand Up @@ -201,7 +206,7 @@ static SCSpecEventV0 fromJsonObject(Object json) {
SCSpecEventV0 instance = new SCSpecEventV0();
instance.doc = XdrString.fromJsonObject(jsonMap.get("doc"));
instance.lib = XdrString.fromJsonObject(jsonMap.get("lib"));
instance.name = SCSymbol.fromJsonObject(jsonMap.get("name"));
instance.name = XdrString.fromJsonObject(jsonMap.get("name"));
instance.prefixTopics =
XdrElement.jsonArrayToArray(
(List<Object>) jsonMap.get("prefix_topics"),
Expand Down
Loading
Loading