Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
91 changes: 37 additions & 54 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,38 @@ version = "28.0.0"
[workspace.dependencies.soroban-env-host]
version = "28.0.0-rc.1"

# Dependencies from the rs-soroban-sdk repo:
# Dependencies from the rs-soroban-sdk repo, pinned to
# https://github.com/stellar/rs-soroban-sdk/pull/1970, which names user-defined
# types in contract specs by their fully qualified path:
[workspace.dependencies.soroban-spec]
version = "28.0.0-rc.1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "d131d67b5ebbf1346fabdc6e6a86141e25ece720"

[workspace.dependencies.soroban-spec-rust]
version = "28.0.0-rc.1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "d131d67b5ebbf1346fabdc6e6a86141e25ece720"

[workspace.dependencies.soroban-sdk]
version = "28.0.0-rc.1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "d131d67b5ebbf1346fabdc6e6a86141e25ece720"

[workspace.dependencies.soroban-token-sdk]
version = "28.0.0-rc.1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "d131d67b5ebbf1346fabdc6e6a86141e25ece720"

[workspace.dependencies.stellar-asset-spec]
version = "28.0.0-rc.1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "d131d67b5ebbf1346fabdc6e6a86141e25ece720"

[workspace.dependencies.soroban-ledger-snapshot]
version = "28.0.0-rc.1"
git = "https://github.com/stellar/rs-soroban-sdk"
rev = "d131d67b5ebbf1346fabdc6e6a86141e25ece720"

# Dependencies from the rs-stellar-rpc-client repo:
[workspace.dependencies.soroban-rpc]
Expand Down Expand Up @@ -121,6 +135,15 @@ testcontainers = "0.27.2"
httpmock = "0.7.0"
astral-tokio-tar = "0.6.0"

[patch.crates-io]
# Pinned to a rev of rs-stellar-xdr main, pending a release containing the const
# XDR encoding and the widened user-defined type name limit that a fully
# qualified type name needs. This has to be a patch rather than a git revision on
# the dependency itself, because stellar-rpc-client is published and so brings
# its own stellar-xdr from crates.io, which only a patch redirects onto the same
# copy the rest of the graph uses.
stellar-xdr = { git = "https://github.com/stellar/rs-stellar-xdr", rev = "e0d289adf4ad2483a10bcc8df743126974d77301" }

[profile.release]
overflow-checks = true

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build:
cargo build

build-test-wasms:
SOROBAN_SDK_BUILD_SYSTEM_SUPPORTS_SPEC_SHAKING_V2=1 cargo build --package 'test_*' --profile test-wasms --target wasm32v1-none
SOROBAN_SDK_BUILD_SYSTEM_SUPPORTS_SPEC_SHAKING_V2=1 SOROBAN_SDK_BUILD_SYSTEM_SUPPORTS_REDUCING_FULL_NAMES=1 cargo build --package 'test_*' --profile test-wasms --target wasm32v1-none

build-test: build-test-wasms build-fixtures install

Expand Down
2 changes: 1 addition & 1 deletion cmd/crates/soroban-spec-tools/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ fn indent(s: &str, n: usize) -> String {
.join("\n")
}

fn format_name(lib: &StringM<80>, name: &StringM<60>) -> String {
fn format_name(lib: &StringM<80>, name: &StringM<{ crate::UDT_NAME_LIMIT }>) -> String {
if lib.is_empty() {
sanitize(&name.to_utf8_string_lossy())
} else {
Expand Down
2 changes: 1 addition & 1 deletion cmd/crates/soroban-spec-tools/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ mod tests {
ScSpecEventV0 {
doc: StringM::default(),
lib: StringM::default(),
name: make_symbol(name),
name: name.try_into().unwrap(),
prefix_topics: prefix_topics
.into_iter()
.map(make_symbol)
Expand Down
18 changes: 14 additions & 4 deletions cmd/crates/soroban-spec-tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use stellar_xdr::{
ScSpecTypeTuple, ScSpecTypeUdt, ScSpecTypeVec, ScSpecUdtEnumV0, ScSpecUdtErrorEnumCaseV0,
ScSpecUdtErrorEnumV0, ScSpecUdtStructV0, ScSpecUdtUnionCaseTupleV0, ScSpecUdtUnionCaseV0,
ScSpecUdtUnionCaseVoidV0, ScSpecUdtUnionV0, ScString, ScSymbol, ScVal, ScVec, StringM,
UInt128Parts, UInt256Parts, Uint256, VecM,
UInt128Parts, UInt256Parts, Uint256, VecM, SC_SPEC_TYPE_NAME_LIMIT,
};

pub mod contract;
Expand All @@ -25,6 +25,12 @@ pub mod wasm;
pub use contract::sanitize;
pub use verify::SpecWarning;

/// The XDR limit on the length of a user-defined type name
/// ([`SC_SPEC_TYPE_NAME_LIMIT`]), as the `u32` that `StringM`'s const generic
/// expects.
#[allow(clippy::cast_possible_truncation)]
pub const UDT_NAME_LIMIT: u32 = SC_SPEC_TYPE_NAME_LIMIT as u32;

#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("an unknown error occurred")]
Expand Down Expand Up @@ -372,7 +378,7 @@ impl Spec {
Ok(val)
}

fn parse_udt(&self, name: &StringM<60>, value: &Value) -> Result<ScVal, Error> {
fn parse_udt(&self, name: &StringM<UDT_NAME_LIMIT>, value: &Value) -> Result<ScVal, Error> {
let name = &name.to_utf8_string_lossy();
match (self.find(name)?, value) {
(ScSpecEntry::UdtStructV0(strukt), Value::Object(map)) => {
Expand Down Expand Up @@ -649,7 +655,11 @@ impl Spec {
/// # Panics
///
/// May panic
pub fn udt_to_json(&self, name: &StringM<60>, sc_obj: &ScVal) -> Result<Value, Error> {
pub fn udt_to_json(
&self,
name: &StringM<UDT_NAME_LIMIT>,
sc_obj: &ScVal,
) -> Result<Value, Error> {
let name = &name.to_utf8_string_lossy();
let udt = self.find(name)?;
Ok(match (sc_obj, udt) {
Expand Down Expand Up @@ -2345,7 +2355,7 @@ mod tests {
ScSpecEventV0 {
doc: StringM::default(),
lib: StringM::default(),
name: ScSymbol(name.try_into().unwrap()),
name: name.try_into().unwrap(),
prefix_topics: VecM::default(),
params: VecM::default(),
data_format: stellar_xdr::ScSpecEventDataFormat::SingleValue,
Expand Down
Loading
Loading