From ff70bcf6901c18c19b5a2231a563b8e2e3ee38e0 Mon Sep 17 00:00:00 2001 From: Jun Luo <4catcode@gmail.com> Date: Sat, 24 Oct 2026 23:12:34 +0800 Subject: [PATCH] chore: upgrade generated XDR definitions to Protocol 30. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2^10 🎉 --- CHANGELOG.md | 1 + Makefile | 2 +- .../stellar/sdk/contract/ContractSpec.java | 2 +- .../java/org/stellar/sdk/xdr/Constants.java | 1 + .../org/stellar/sdk/xdr/ContractCostType.java | 85 ++++- .../org/stellar/sdk/xdr/MuxedContract.java | 103 ++++++ .../java/org/stellar/sdk/xdr/SCAddress.java | 16 + .../org/stellar/sdk/xdr/SCAddressType.java | 12 +- .../org/stellar/sdk/xdr/SCSpecEventV0.java | 13 +- .../org/stellar/sdk/xdr/SCSpecTypeUDT.java | 9 +- .../org/stellar/sdk/xdr/SCSpecUDTEnumV0.java | 9 +- .../stellar/sdk/xdr/SCSpecUDTErrorEnumV0.java | 9 +- .../stellar/sdk/xdr/SCSpecUDTStructV0.java | 9 +- .../org/stellar/sdk/xdr/SCSpecUDTUnionV0.java | 9 +- .../org/stellar/sdk/xdr/StellarValue.java | 311 ++++++++++++++++++ .../org/stellar/sdk/xdr/StellarValueType.java | 20 +- .../java/org/stellar/sdk/xdr/TimePointMs.java | 80 +++++ .../stellar/sdk/contract/ContractSpecTest.kt | 2 +- xdr/Stellar-contract-config-setting.x | 20 +- xdr/Stellar-contract-spec.x | 14 +- xdr/Stellar-contract.x | 11 +- xdr/Stellar-ledger.x | 19 +- xdr/Stellar-types.x | 2 + 23 files changed, 717 insertions(+), 42 deletions(-) create mode 100644 src/main/java/org/stellar/sdk/xdr/MuxedContract.java create mode 100644 src/main/java/org/stellar/sdk/xdr/TimePointMs.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af1dcd22..79f59f26e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Makefile b/Makefile index b2d4fb201..bb392550c 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/src/main/java/org/stellar/sdk/contract/ContractSpec.java b/src/main/java/org/stellar/sdk/contract/ContractSpec.java index 1d30c5033..e3d7f7baf 100644 --- a/src/main/java/org/stellar/sdk/contract/ContractSpec.java +++ b/src/main/java/org/stellar/sdk/contract/ContractSpec.java @@ -183,7 +183,7 @@ public Optional 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); } } diff --git a/src/main/java/org/stellar/sdk/xdr/Constants.java b/src/main/java/org/stellar/sdk/xdr/Constants.java index e0f8f7110..22d72cf6c 100644 --- a/src/main/java/org/stellar/sdk/xdr/Constants.java +++ b/src/main/java/org/stellar/sdk/xdr/Constants.java @@ -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; } diff --git a/src/main/java/org/stellar/sdk/xdr/ContractCostType.java b/src/main/java/org/stellar/sdk/xdr/ContractCostType.java index 0a6b8816a..69d7dab4d 100644 --- a/src/main/java/org/stellar/sdk/xdr/ContractCostType.java +++ b/src/main/java/org/stellar/sdk/xdr/ContractCostType.java @@ -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 * }; * */ @@ -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; @@ -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); } @@ -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); } @@ -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); } diff --git a/src/main/java/org/stellar/sdk/xdr/MuxedContract.java b/src/main/java/org/stellar/sdk/xdr/MuxedContract.java new file mode 100644 index 000000000..659ee6252 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/MuxedContract.java @@ -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: + * + *
+ * struct MuxedContract
+ * {
+ *     uint64 id;
+ *     ContractID contractId;
+ * };
+ * 
+ */ +@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 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 jsonMap = (java.util.Map) json; + MuxedContract instance = new MuxedContract(); + instance.id = Uint64.fromJsonObject(jsonMap.get("id")); + instance.contractId = ContractID.fromJsonObject(jsonMap.get("contract_id")); + return instance; + } +} diff --git a/src/main/java/org/stellar/sdk/xdr/SCAddress.java b/src/main/java/org/stellar/sdk/xdr/SCAddress.java index 76b0f874f..8a4ab6428 100644 --- a/src/main/java/org/stellar/sdk/xdr/SCAddress.java +++ b/src/main/java/org/stellar/sdk/xdr/SCAddress.java @@ -29,6 +29,8 @@ * ClaimableBalanceID claimableBalanceId; * case SC_ADDRESS_TYPE_LIQUIDITY_POOL: * PoolID liquidityPoolId; + * case SC_ADDRESS_TYPE_MUXED_CONTRACT: + * MuxedContract muxedContract; * }; * */ @@ -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) { @@ -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; } } @@ -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); } diff --git a/src/main/java/org/stellar/sdk/xdr/SCAddressType.java b/src/main/java/org/stellar/sdk/xdr/SCAddressType.java index ab54450d7..872871e4f 100644 --- a/src/main/java/org/stellar/sdk/xdr/SCAddressType.java +++ b/src/main/java/org/stellar/sdk/xdr/SCAddressType.java @@ -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 * }; * */ @@ -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; @@ -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); } @@ -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); } @@ -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); } diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecEventV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecEventV0.java index 96e7a9162..f9e3ad93d 100644 --- a/src/main/java/org/stellar/sdk/xdr/SCSpecEventV0.java +++ b/src/main/java/org/stellar/sdk/xdr/SCSpecEventV0.java @@ -21,7 +21,7 @@ * { * string doc<SC_SPEC_DOC_LIMIT>; * string lib<80>; - * SCSymbol name; + * string name<SC_SPEC_TYPE_NAME_LIMIT>; * SCSymbol prefixTopics<2>; * SCSpecEventParamV0 params<>; * SCSpecEventDataFormat dataFormat; @@ -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. @@ -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) { @@ -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"); @@ -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) jsonMap.get("prefix_topics"), diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecTypeUDT.java b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeUDT.java index e0eedac3c..8f97f6b84 100644 --- a/src/main/java/org/stellar/sdk/xdr/SCSpecTypeUDT.java +++ b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeUDT.java @@ -18,7 +18,7 @@ *
  * struct SCSpecTypeUDT
  * {
- *     string name<60>;
+ *     string name<SC_SPEC_TYPE_NAME_LIMIT>;
  * };
  * 
*/ @@ -37,8 +37,8 @@ public class SCSpecTypeUDT implements XdrElement { public void encode(XdrDataOutputStream stream) throws IOException { int nameSize = name.getBytes().length; - if (nameSize > 60) { - throw new IOException("name size " + nameSize + " exceeds max size 60"); + if (nameSize > 1024) { + throw new IOException("name size " + nameSize + " exceeds max size 1024"); } name.encode(stream); } @@ -49,7 +49,8 @@ public static SCSpecTypeUDT decode(XdrDataInputStream stream, int maxDepth) thro } maxDepth -= 1; SCSpecTypeUDT decodedSCSpecTypeUDT = new SCSpecTypeUDT(); - decodedSCSpecTypeUDT.name = XdrString.decode(stream, maxDepth, 60); + decodedSCSpecTypeUDT.name = + XdrString.decode(stream, maxDepth, Constants.SC_SPEC_TYPE_NAME_LIMIT); return decodedSCSpecTypeUDT; } diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTEnumV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTEnumV0.java index 0b870bb4c..085f3b248 100644 --- a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTEnumV0.java +++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTEnumV0.java @@ -21,7 +21,7 @@ * { * string doc<SC_SPEC_DOC_LIMIT>; * string lib<80>; - * string name<60>; + * string name<SC_SPEC_TYPE_NAME_LIMIT>; * SCSpecUDTEnumCaseV0 cases<>; * }; * @@ -75,8 +75,8 @@ public void encode(XdrDataOutputStream stream) throws IOException { } lib.encode(stream); int nameSize = name.getBytes().length; - if (nameSize > 60) { - throw new IOException("name size " + nameSize + " exceeds max size 60"); + if (nameSize > 1024) { + throw new IOException("name size " + nameSize + " exceeds max size 1024"); } name.encode(stream); int casesSize = getCases().length; @@ -94,7 +94,8 @@ public static SCSpecUDTEnumV0 decode(XdrDataInputStream stream, int maxDepth) th SCSpecUDTEnumV0 decodedSCSpecUDTEnumV0 = new SCSpecUDTEnumV0(); decodedSCSpecUDTEnumV0.doc = XdrString.decode(stream, maxDepth, Constants.SC_SPEC_DOC_LIMIT); decodedSCSpecUDTEnumV0.lib = XdrString.decode(stream, maxDepth, 80); - decodedSCSpecUDTEnumV0.name = XdrString.decode(stream, maxDepth, 60); + decodedSCSpecUDTEnumV0.name = + XdrString.decode(stream, maxDepth, Constants.SC_SPEC_TYPE_NAME_LIMIT); int casesSize = stream.readInt(); if (casesSize < 0) { throw new IOException("cases size " + casesSize + " is negative"); diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTErrorEnumV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTErrorEnumV0.java index e962762c5..87e9c4b45 100644 --- a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTErrorEnumV0.java +++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTErrorEnumV0.java @@ -21,7 +21,7 @@ * { * string doc<SC_SPEC_DOC_LIMIT>; * string lib<80>; - * string name<60>; + * string name<SC_SPEC_TYPE_NAME_LIMIT>; * SCSpecUDTErrorEnumCaseV0 cases<>; * }; * @@ -75,8 +75,8 @@ public void encode(XdrDataOutputStream stream) throws IOException { } lib.encode(stream); int nameSize = name.getBytes().length; - if (nameSize > 60) { - throw new IOException("name size " + nameSize + " exceeds max size 60"); + if (nameSize > 1024) { + throw new IOException("name size " + nameSize + " exceeds max size 1024"); } name.encode(stream); int casesSize = getCases().length; @@ -96,7 +96,8 @@ public static SCSpecUDTErrorEnumV0 decode(XdrDataInputStream stream, int maxDept decodedSCSpecUDTErrorEnumV0.doc = XdrString.decode(stream, maxDepth, Constants.SC_SPEC_DOC_LIMIT); decodedSCSpecUDTErrorEnumV0.lib = XdrString.decode(stream, maxDepth, 80); - decodedSCSpecUDTErrorEnumV0.name = XdrString.decode(stream, maxDepth, 60); + decodedSCSpecUDTErrorEnumV0.name = + XdrString.decode(stream, maxDepth, Constants.SC_SPEC_TYPE_NAME_LIMIT); int casesSize = stream.readInt(); if (casesSize < 0) { throw new IOException("cases size " + casesSize + " is negative"); diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTStructV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTStructV0.java index d17f8b562..8193b37ce 100644 --- a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTStructV0.java +++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTStructV0.java @@ -21,7 +21,7 @@ * { * string doc<SC_SPEC_DOC_LIMIT>; * string lib<80>; - * string name<60>; + * string name<SC_SPEC_TYPE_NAME_LIMIT>; * SCSpecUDTStructFieldV0 fields<>; * }; * @@ -75,8 +75,8 @@ public void encode(XdrDataOutputStream stream) throws IOException { } lib.encode(stream); int nameSize = name.getBytes().length; - if (nameSize > 60) { - throw new IOException("name size " + nameSize + " exceeds max size 60"); + if (nameSize > 1024) { + throw new IOException("name size " + nameSize + " exceeds max size 1024"); } name.encode(stream); int fieldsSize = getFields().length; @@ -95,7 +95,8 @@ public static SCSpecUDTStructV0 decode(XdrDataInputStream stream, int maxDepth) SCSpecUDTStructV0 decodedSCSpecUDTStructV0 = new SCSpecUDTStructV0(); decodedSCSpecUDTStructV0.doc = XdrString.decode(stream, maxDepth, Constants.SC_SPEC_DOC_LIMIT); decodedSCSpecUDTStructV0.lib = XdrString.decode(stream, maxDepth, 80); - decodedSCSpecUDTStructV0.name = XdrString.decode(stream, maxDepth, 60); + decodedSCSpecUDTStructV0.name = + XdrString.decode(stream, maxDepth, Constants.SC_SPEC_TYPE_NAME_LIMIT); int fieldsSize = stream.readInt(); if (fieldsSize < 0) { throw new IOException("fields size " + fieldsSize + " is negative"); diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionV0.java index a39b89676..676dc2317 100644 --- a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionV0.java +++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionV0.java @@ -21,7 +21,7 @@ * { * string doc<SC_SPEC_DOC_LIMIT>; * string lib<80>; - * string name<60>; + * string name<SC_SPEC_TYPE_NAME_LIMIT>; * SCSpecUDTUnionCaseV0 cases<>; * }; * @@ -75,8 +75,8 @@ public void encode(XdrDataOutputStream stream) throws IOException { } lib.encode(stream); int nameSize = name.getBytes().length; - if (nameSize > 60) { - throw new IOException("name size " + nameSize + " exceeds max size 60"); + if (nameSize > 1024) { + throw new IOException("name size " + nameSize + " exceeds max size 1024"); } name.encode(stream); int casesSize = getCases().length; @@ -95,7 +95,8 @@ public static SCSpecUDTUnionV0 decode(XdrDataInputStream stream, int maxDepth) SCSpecUDTUnionV0 decodedSCSpecUDTUnionV0 = new SCSpecUDTUnionV0(); decodedSCSpecUDTUnionV0.doc = XdrString.decode(stream, maxDepth, Constants.SC_SPEC_DOC_LIMIT); decodedSCSpecUDTUnionV0.lib = XdrString.decode(stream, maxDepth, 80); - decodedSCSpecUDTUnionV0.name = XdrString.decode(stream, maxDepth, 60); + decodedSCSpecUDTUnionV0.name = + XdrString.decode(stream, maxDepth, Constants.SC_SPEC_TYPE_NAME_LIMIT); int casesSize = stream.readInt(); if (casesSize < 0) { throw new IOException("cases size " + casesSize + " is negative"); diff --git a/src/main/java/org/stellar/sdk/xdr/StellarValue.java b/src/main/java/org/stellar/sdk/xdr/StellarValue.java index 3b2d3fe8f..d185568d8 100644 --- a/src/main/java/org/stellar/sdk/xdr/StellarValue.java +++ b/src/main/java/org/stellar/sdk/xdr/StellarValue.java @@ -44,6 +44,21 @@ * uint32 previousLedgerVersion; * LedgerCloseValueSignature lcValueSignature; * } proposedValue; + * case STELLAR_VALUE_SIGNED_MS: + * struct + * { + * TimePointMs closeTimeMs; // closeTime == closeTimeMs / 1000 + * LedgerCloseValueSignature lcValueSignature; + * } signedMsValue; + * case STELLAR_VALUE_EMPTY_TX_SET_MS: + * struct + * { + * TimePointMs closeTimeMs; // closeTime == closeTimeMs / 1000 + * Hash txSetHash; + * Hash previousLedgerHash; + * uint32 previousLedgerVersion; + * LedgerCloseValueSignature lcValueSignature; + * } proposedMsValue; * } * ext; * }; @@ -198,6 +213,21 @@ static StellarValue fromJsonObject(Object json) { * uint32 previousLedgerVersion; * LedgerCloseValueSignature lcValueSignature; * } proposedValue; + * case STELLAR_VALUE_SIGNED_MS: + * struct + * { + * TimePointMs closeTimeMs; // closeTime == closeTimeMs / 1000 + * LedgerCloseValueSignature lcValueSignature; + * } signedMsValue; + * case STELLAR_VALUE_EMPTY_TX_SET_MS: + * struct + * { + * TimePointMs closeTimeMs; // closeTime == closeTimeMs / 1000 + * Hash txSetHash; + * Hash previousLedgerHash; + * uint32 previousLedgerVersion; + * LedgerCloseValueSignature lcValueSignature; + * } proposedMsValue; * } * */ @@ -230,6 +260,22 @@ public static class StellarValueExt implements XdrElement { */ private StellarValueProposedValue proposedValue; + /** + * Value of the {@code signedMsValue} field. + * + * @param signedMsValue the {@code signedMsValue} field value + * @return the {@code signedMsValue} field value + */ + private StellarValueSignedMsValue signedMsValue; + + /** + * Value of the {@code proposedMsValue} field. + * + * @param proposedMsValue the {@code proposedMsValue} field value + * @return the {@code proposedMsValue} field value + */ + private StellarValueProposedMsValue proposedMsValue; + public void encode(XdrDataOutputStream stream) throws IOException { stream.writeInt(discriminant.getValue()); switch (discriminant) { @@ -241,6 +287,12 @@ public void encode(XdrDataOutputStream stream) throws IOException { case STELLAR_VALUE_EMPTY_TX_SET: proposedValue.encode(stream); break; + case STELLAR_VALUE_SIGNED_MS: + signedMsValue.encode(stream); + break; + case STELLAR_VALUE_EMPTY_TX_SET_MS: + proposedMsValue.encode(stream); + break; } } @@ -263,6 +315,13 @@ public static StellarValueExt decode(XdrDataInputStream stream, int maxDepth) case STELLAR_VALUE_EMPTY_TX_SET: decodedStellarValueExt.proposedValue = StellarValueProposedValue.decode(stream, maxDepth); break; + case STELLAR_VALUE_SIGNED_MS: + decodedStellarValueExt.signedMsValue = StellarValueSignedMsValue.decode(stream, maxDepth); + break; + case STELLAR_VALUE_EMPTY_TX_SET_MS: + decodedStellarValueExt.proposedMsValue = + StellarValueProposedMsValue.decode(stream, maxDepth); + break; default: throw new IOException("Unknown discriminant value: " + discriminant); } @@ -308,6 +367,16 @@ Object toJsonObject() { jsonMap.put("empty_tx_set", proposedValue.toJsonObject()); return jsonMap; } + if (discriminant == StellarValueType.STELLAR_VALUE_SIGNED_MS) { + LinkedHashMap jsonMap = new LinkedHashMap<>(); + jsonMap.put("signed_ms", signedMsValue.toJsonObject()); + return jsonMap; + } + if (discriminant == StellarValueType.STELLAR_VALUE_EMPTY_TX_SET_MS) { + LinkedHashMap jsonMap = new LinkedHashMap<>(); + jsonMap.put("empty_tx_set_ms", proposedMsValue.toJsonObject()); + return jsonMap; + } throw new IllegalArgumentException("Unknown discriminant: " + discriminant); } @@ -347,6 +416,19 @@ static StellarValueExt fromJsonObject(Object json) { StellarValueProposedValue.fromJsonObject(jsonMap.get("empty_tx_set")); return instance; } + if (key.equals("signed_ms")) { + StellarValueExt instance = new StellarValueExt(); + instance.discriminant = discriminant; + instance.signedMsValue = StellarValueSignedMsValue.fromJsonObject(jsonMap.get("signed_ms")); + return instance; + } + if (key.equals("empty_tx_set_ms")) { + StellarValueExt instance = new StellarValueExt(); + instance.discriminant = discriminant; + instance.proposedMsValue = + StellarValueProposedMsValue.fromJsonObject(jsonMap.get("empty_tx_set_ms")); + return instance; + } throw new IllegalArgumentException("Unknown key '" + key + "' for StellarValueExt"); } @@ -470,5 +552,234 @@ static StellarValueProposedValue fromJsonObject(Object json) { return instance; } } + + /** + * StellarValueSignedMsValue's original definition in the XDR file is: + * + *
+     * struct
+     *         {
+     *             TimePointMs closeTimeMs; // closeTime == closeTimeMs / 1000
+     *             LedgerCloseValueSignature lcValueSignature;
+     *         }
+     * 
+ */ + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder(toBuilder = true) + public static class StellarValueSignedMsValue implements XdrElement { + /** + * Value of the {@code closeTimeMs} field. + * + * @param closeTimeMs the {@code closeTimeMs} field value + * @return the {@code closeTimeMs} field value + */ + private TimePointMs closeTimeMs; + + /** + * Value of the {@code lcValueSignature} field. + * + * @param lcValueSignature the {@code lcValueSignature} field value + * @return the {@code lcValueSignature} field value + */ + private LedgerCloseValueSignature lcValueSignature; + + public void encode(XdrDataOutputStream stream) throws IOException { + closeTimeMs.encode(stream); + lcValueSignature.encode(stream); + } + + public static StellarValueSignedMsValue decode(XdrDataInputStream stream, int maxDepth) + throws IOException { + if (maxDepth <= 0) { + throw new IOException("Maximum decoding depth reached"); + } + maxDepth -= 1; + StellarValueSignedMsValue decodedStellarValueSignedMsValue = + new StellarValueSignedMsValue(); + decodedStellarValueSignedMsValue.closeTimeMs = TimePointMs.decode(stream, maxDepth); + decodedStellarValueSignedMsValue.lcValueSignature = + LedgerCloseValueSignature.decode(stream, maxDepth); + return decodedStellarValueSignedMsValue; + } + + public static StellarValueSignedMsValue decode(XdrDataInputStream stream) throws IOException { + return decode(stream, XdrDataInputStream.DEFAULT_MAX_DEPTH); + } + + public static StellarValueSignedMsValue fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static StellarValueSignedMsValue 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 StellarValueSignedMsValue fromJson(String json) { + return fromJsonObject(XdrElement.gson.fromJson(json, Object.class)); + } + + Object toJsonObject() { + LinkedHashMap jsonMap = new LinkedHashMap<>(); + jsonMap.put("close_time_ms", closeTimeMs.toJsonObject()); + jsonMap.put("lc_value_signature", lcValueSignature.toJsonObject()); + return jsonMap; + } + + @SuppressWarnings("unchecked") + static StellarValueSignedMsValue fromJsonObject(Object json) { + java.util.Map jsonMap = (java.util.Map) json; + StellarValueSignedMsValue instance = new StellarValueSignedMsValue(); + instance.closeTimeMs = TimePointMs.fromJsonObject(jsonMap.get("close_time_ms")); + instance.lcValueSignature = + LedgerCloseValueSignature.fromJsonObject(jsonMap.get("lc_value_signature")); + return instance; + } + } + + /** + * StellarValueProposedMsValue's original definition in the XDR file is: + * + *
+     * struct
+     *         {
+     *             TimePointMs closeTimeMs; // closeTime == closeTimeMs / 1000
+     *             Hash txSetHash;
+     *             Hash previousLedgerHash;
+     *             uint32 previousLedgerVersion;
+     *             LedgerCloseValueSignature lcValueSignature;
+     *         }
+     * 
+ */ + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder(toBuilder = true) + public static class StellarValueProposedMsValue implements XdrElement { + /** + * Value of the {@code closeTimeMs} field. + * + * @param closeTimeMs the {@code closeTimeMs} field value + * @return the {@code closeTimeMs} field value + */ + private TimePointMs closeTimeMs; + + /** + * Value of the {@code txSetHash} field. + * + * @param txSetHash the {@code txSetHash} field value + * @return the {@code txSetHash} field value + */ + private Hash txSetHash; + + /** + * Value of the {@code previousLedgerHash} field. + * + * @param previousLedgerHash the {@code previousLedgerHash} field value + * @return the {@code previousLedgerHash} field value + */ + private Hash previousLedgerHash; + + /** + * Value of the {@code previousLedgerVersion} field. + * + * @param previousLedgerVersion the {@code previousLedgerVersion} field value + * @return the {@code previousLedgerVersion} field value + */ + private Uint32 previousLedgerVersion; + + /** + * Value of the {@code lcValueSignature} field. + * + * @param lcValueSignature the {@code lcValueSignature} field value + * @return the {@code lcValueSignature} field value + */ + private LedgerCloseValueSignature lcValueSignature; + + public void encode(XdrDataOutputStream stream) throws IOException { + closeTimeMs.encode(stream); + txSetHash.encode(stream); + previousLedgerHash.encode(stream); + previousLedgerVersion.encode(stream); + lcValueSignature.encode(stream); + } + + public static StellarValueProposedMsValue decode(XdrDataInputStream stream, int maxDepth) + throws IOException { + if (maxDepth <= 0) { + throw new IOException("Maximum decoding depth reached"); + } + maxDepth -= 1; + StellarValueProposedMsValue decodedStellarValueProposedMsValue = + new StellarValueProposedMsValue(); + decodedStellarValueProposedMsValue.closeTimeMs = TimePointMs.decode(stream, maxDepth); + decodedStellarValueProposedMsValue.txSetHash = Hash.decode(stream, maxDepth); + decodedStellarValueProposedMsValue.previousLedgerHash = Hash.decode(stream, maxDepth); + decodedStellarValueProposedMsValue.previousLedgerVersion = Uint32.decode(stream, maxDepth); + decodedStellarValueProposedMsValue.lcValueSignature = + LedgerCloseValueSignature.decode(stream, maxDepth); + return decodedStellarValueProposedMsValue; + } + + public static StellarValueProposedMsValue decode(XdrDataInputStream stream) + throws IOException { + return decode(stream, XdrDataInputStream.DEFAULT_MAX_DEPTH); + } + + public static StellarValueProposedMsValue fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static StellarValueProposedMsValue 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 StellarValueProposedMsValue fromJson(String json) { + return fromJsonObject(XdrElement.gson.fromJson(json, Object.class)); + } + + Object toJsonObject() { + LinkedHashMap jsonMap = new LinkedHashMap<>(); + jsonMap.put("close_time_ms", closeTimeMs.toJsonObject()); + jsonMap.put("tx_set_hash", txSetHash.toJsonObject()); + jsonMap.put("previous_ledger_hash", previousLedgerHash.toJsonObject()); + jsonMap.put("previous_ledger_version", previousLedgerVersion.toJsonObject()); + jsonMap.put("lc_value_signature", lcValueSignature.toJsonObject()); + return jsonMap; + } + + @SuppressWarnings("unchecked") + static StellarValueProposedMsValue fromJsonObject(Object json) { + java.util.Map jsonMap = (java.util.Map) json; + StellarValueProposedMsValue instance = new StellarValueProposedMsValue(); + instance.closeTimeMs = TimePointMs.fromJsonObject(jsonMap.get("close_time_ms")); + instance.txSetHash = Hash.fromJsonObject(jsonMap.get("tx_set_hash")); + instance.previousLedgerHash = Hash.fromJsonObject(jsonMap.get("previous_ledger_hash")); + instance.previousLedgerVersion = + Uint32.fromJsonObject(jsonMap.get("previous_ledger_version")); + instance.lcValueSignature = + LedgerCloseValueSignature.fromJsonObject(jsonMap.get("lc_value_signature")); + return instance; + } + } } } diff --git a/src/main/java/org/stellar/sdk/xdr/StellarValueType.java b/src/main/java/org/stellar/sdk/xdr/StellarValueType.java index 04007dd20..eee8a4b1f 100644 --- a/src/main/java/org/stellar/sdk/xdr/StellarValueType.java +++ b/src/main/java/org/stellar/sdk/xdr/StellarValueType.java @@ -15,14 +15,18 @@ * { * STELLAR_VALUE_BASIC = 0, * STELLAR_VALUE_SIGNED = 1, - * STELLAR_VALUE_EMPTY_TX_SET = 2 + * STELLAR_VALUE_EMPTY_TX_SET = 2, + * STELLAR_VALUE_SIGNED_MS = 3, + * STELLAR_VALUE_EMPTY_TX_SET_MS = 4 * }; * */ public enum StellarValueType implements XdrElement { STELLAR_VALUE_BASIC(0), STELLAR_VALUE_SIGNED(1), - STELLAR_VALUE_EMPTY_TX_SET(2); + STELLAR_VALUE_EMPTY_TX_SET(2), + STELLAR_VALUE_SIGNED_MS(3), + STELLAR_VALUE_EMPTY_TX_SET_MS(4); private final int value; @@ -45,6 +49,10 @@ public static StellarValueType decode(XdrDataInputStream stream, int maxDepth) return STELLAR_VALUE_SIGNED; case 2: return STELLAR_VALUE_EMPTY_TX_SET; + case 3: + return STELLAR_VALUE_SIGNED_MS; + case 4: + return STELLAR_VALUE_EMPTY_TX_SET_MS; default: throw new IllegalArgumentException("Unknown enum value: " + value); } @@ -87,6 +95,10 @@ Object toJsonObject() { return "signed"; case STELLAR_VALUE_EMPTY_TX_SET: return "empty_tx_set"; + case STELLAR_VALUE_SIGNED_MS: + return "signed_ms"; + case STELLAR_VALUE_EMPTY_TX_SET_MS: + return "empty_tx_set_ms"; default: throw new IllegalArgumentException("Unknown enum value: " + this.value); } @@ -101,6 +113,10 @@ static StellarValueType fromJsonObject(Object json) { return STELLAR_VALUE_SIGNED; case "empty_tx_set": return STELLAR_VALUE_EMPTY_TX_SET; + case "signed_ms": + return STELLAR_VALUE_SIGNED_MS; + case "empty_tx_set_ms": + return STELLAR_VALUE_EMPTY_TX_SET_MS; default: throw new IllegalArgumentException("Unknown JSON value: " + value); } diff --git a/src/main/java/org/stellar/sdk/xdr/TimePointMs.java b/src/main/java/org/stellar/sdk/xdr/TimePointMs.java new file mode 100644 index 000000000..f97f4c4e0 --- /dev/null +++ b/src/main/java/org/stellar/sdk/xdr/TimePointMs.java @@ -0,0 +1,80 @@ +// 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 lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.stellar.sdk.Base64Factory; + +/** + * TimePointMs's original definition in the XDR file is: + * + *
+ * typedef uint64 TimePointMs;
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TimePointMs implements XdrElement { + /** + * Value of the {@code TimePointMs} field. + * + * @param TimePointMs the {@code TimePointMs} field value + * @return the {@code TimePointMs} field value + */ + private Uint64 TimePointMs; + + public void encode(XdrDataOutputStream stream) throws IOException { + TimePointMs.encode(stream); + } + + public static TimePointMs decode(XdrDataInputStream stream, int maxDepth) throws IOException { + if (maxDepth <= 0) { + throw new IOException("Maximum decoding depth reached"); + } + maxDepth -= 1; + TimePointMs decodedTimePointMs = new TimePointMs(); + decodedTimePointMs.TimePointMs = Uint64.decode(stream, maxDepth); + return decodedTimePointMs; + } + + public static TimePointMs decode(XdrDataInputStream stream) throws IOException { + return decode(stream, XdrDataInputStream.DEFAULT_MAX_DEPTH); + } + + public static TimePointMs fromXdrBase64(String xdr) throws IOException { + byte[] bytes = Base64Factory.getInstance().decode(xdr); + return fromXdrByteArray(bytes); + } + + public static TimePointMs 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 TimePointMs fromJson(String json) { + return fromJsonObject(XdrElement.gson.fromJson(json, Object.class)); + } + + Object toJsonObject() { + return TimePointMs.toJsonObject(); + } + + static TimePointMs fromJsonObject(Object json) { + TimePointMs instance = new TimePointMs(); + instance.TimePointMs = Uint64.fromJsonObject(json); + return instance; + } +} diff --git a/src/test/kotlin/org/stellar/sdk/contract/ContractSpecTest.kt b/src/test/kotlin/org/stellar/sdk/contract/ContractSpecTest.kt index ffd5d8cab..f444f510c 100644 --- a/src/test/kotlin/org/stellar/sdk/contract/ContractSpecTest.kt +++ b/src/test/kotlin/org/stellar/sdk/contract/ContractSpecTest.kt @@ -49,7 +49,7 @@ private fun eventEntry(name: String): SCSpecEntry { SCSpecEventV0().apply { doc = XdrString(ByteArray(0)) lib = XdrString(ByteArray(0)) - this.name = symbol(name) + this.name = XdrString(name.toByteArray(Charsets.UTF_8)) prefixTopics = arrayOf() params = arrayOf() dataFormat = SCSpecEventDataFormat.values().first() diff --git a/xdr/Stellar-contract-config-setting.x b/xdr/Stellar-contract-config-setting.x index 80c0d7fcf..bab260a98 100644 --- a/xdr/Stellar-contract-config-setting.x +++ b/xdr/Stellar-contract-config-setting.x @@ -296,7 +296,25 @@ enum ContractCostType { // 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 }; struct ContractCostParamEntry { diff --git a/xdr/Stellar-contract-spec.x b/xdr/Stellar-contract-spec.x index 33c4cec1e..d87e643e4 100644 --- a/xdr/Stellar-contract-spec.x +++ b/xdr/Stellar-contract-spec.x @@ -12,6 +12,8 @@ namespace stellar const SC_SPEC_DOC_LIMIT = 1024; +const SC_SPEC_TYPE_NAME_LIMIT = 1024; + enum SCSpecType { SC_SPEC_TYPE_VAL = 0, @@ -82,7 +84,7 @@ struct SCSpecTypeBytesN struct SCSpecTypeUDT { - string name<60>; + string name; }; union SCSpecTypeDef switch (SCSpecType type) @@ -134,7 +136,7 @@ struct SCSpecUDTStructV0 { string doc; string lib<80>; - string name<60>; + string name; SCSpecUDTStructFieldV0 fields<>; }; @@ -169,7 +171,7 @@ struct SCSpecUDTUnionV0 { string doc; string lib<80>; - string name<60>; + string name; SCSpecUDTUnionCaseV0 cases<>; }; @@ -184,7 +186,7 @@ struct SCSpecUDTEnumV0 { string doc; string lib<80>; - string name<60>; + string name; SCSpecUDTEnumCaseV0 cases<>; }; @@ -199,7 +201,7 @@ struct SCSpecUDTErrorEnumV0 { string doc; string lib<80>; - string name<60>; + string name; SCSpecUDTErrorEnumCaseV0 cases<>; }; @@ -243,7 +245,7 @@ struct SCSpecEventV0 { string doc; string lib<80>; - SCSymbol name; + string name; SCSymbol prefixTopics<2>; SCSpecEventParamV0 params<>; SCSpecEventDataFormat dataFormat; diff --git a/xdr/Stellar-contract.x b/xdr/Stellar-contract.x index 727517311..ad04b1bc3 100644 --- a/xdr/Stellar-contract.x +++ b/xdr/Stellar-contract.x @@ -182,7 +182,8 @@ enum SCAddressType 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 }; struct MuxedEd25519Account @@ -191,6 +192,12 @@ struct MuxedEd25519Account uint256 ed25519; }; +struct MuxedContract +{ + uint64 id; + ContractID contractId; +}; + union SCAddress switch (SCAddressType type) { case SC_ADDRESS_TYPE_ACCOUNT: @@ -203,6 +210,8 @@ case SC_ADDRESS_TYPE_CLAIMABLE_BALANCE: ClaimableBalanceID claimableBalanceId; case SC_ADDRESS_TYPE_LIQUIDITY_POOL: PoolID liquidityPoolId; +case SC_ADDRESS_TYPE_MUXED_CONTRACT: + MuxedContract muxedContract; }; struct ContractExecutableExternalRef { diff --git a/xdr/Stellar-ledger.x b/xdr/Stellar-ledger.x index 9acf1d773..47726e3fa 100644 --- a/xdr/Stellar-ledger.x +++ b/xdr/Stellar-ledger.x @@ -14,7 +14,9 @@ enum StellarValueType { STELLAR_VALUE_BASIC = 0, STELLAR_VALUE_SIGNED = 1, - STELLAR_VALUE_EMPTY_TX_SET = 2 + STELLAR_VALUE_EMPTY_TX_SET = 2, + STELLAR_VALUE_SIGNED_MS = 3, + STELLAR_VALUE_EMPTY_TX_SET_MS = 4 }; struct LedgerCloseValueSignature @@ -52,6 +54,21 @@ struct StellarValue uint32 previousLedgerVersion; LedgerCloseValueSignature lcValueSignature; } proposedValue; + case STELLAR_VALUE_SIGNED_MS: + struct + { + TimePointMs closeTimeMs; // closeTime == closeTimeMs / 1000 + LedgerCloseValueSignature lcValueSignature; + } signedMsValue; + case STELLAR_VALUE_EMPTY_TX_SET_MS: + struct + { + TimePointMs closeTimeMs; // closeTime == closeTimeMs / 1000 + Hash txSetHash; + Hash previousLedgerHash; + uint32 previousLedgerVersion; + LedgerCloseValueSignature lcValueSignature; + } proposedMsValue; } ext; }; diff --git a/xdr/Stellar-types.x b/xdr/Stellar-types.x index 4b5914e44..017f45d3c 100644 --- a/xdr/Stellar-types.x +++ b/xdr/Stellar-types.x @@ -16,6 +16,8 @@ typedef hyper int64; typedef uint64 TimePoint; typedef uint64 Duration; +// Milliseconds since the Unix epoch. TimePoint is whole seconds. +typedef uint64 TimePointMs; // An ExtensionPoint is always marshaled as a 32-bit 0 value. At a // later point, it can be replaced by a different union so as to