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
2 changes: 1 addition & 1 deletion .github/workflows/bindings-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: sudo apt update && sudo apt install -y libdbus-1-dev libudev-dev
if: runner.os == 'Linux'
- run: cargo build
- run: rustup target add wasm32-unknown-unknown
- run: rustup target add wasm32v1-none
- run: make build-test-wasms
- run: npm ci && npm run test
working-directory: cmd/crates/soroban-spec-typescript/ts-tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rpc-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ jobs:
run: |
gnome-keyring-daemon
- run: cargo build --features additional-libs
- run: rustup target add wasm32-unknown-unknown
- run: rustup target add wasm32v1-none
- run: make build-test-wasms
- run: SOROBAN_PORT=8000 cargo test --features it --package soroban-test --test it -- integration --test-threads=1
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
- run: rustup update
- run: cargo version
- run: rustup target add ${{ matrix.sys.target }}
- run: rustup target add wasm32-unknown-unknown
- run: rustup target add wasm32v1-none
- if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libudev-dev libdbus-1-dev
- run: cargo clippy --all-targets --target ${{ matrix.sys.target }}
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ build:
cargo build

build-test-wasms:
cargo build --package 'test_*' --profile test-wasms --target wasm32-unknown-unknown
cargo build --package 'test_*' --profile test-wasms --target wasm32v1-none

build-test: build-test-wasms install

Expand Down Expand Up @@ -72,11 +72,11 @@ publish:

typescript-bindings-fixtures: build-test-wasms
cargo run -- contract bindings typescript \
--wasm ./target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm \
--wasm ./target/wasm32v1-none/test-wasms/test_custom_types.wasm \
--output-dir ./cmd/crates/soroban-spec-typescript/fixtures/test_custom_types \
--overwrite && \
cargo run -- contract bindings typescript \
--wasm ./target/wasm32-unknown-unknown/test-wasms/test_constructor.wasm \
--wasm ./target/wasm32v1-none/test-wasms/test_constructor.wasm \
--output-dir ./cmd/crates/soroban-spec-typescript/fixtures/test_constructor \
--overwrite

Expand Down
2 changes: 1 addition & 1 deletion cmd/crates/soroban-spec-json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mod test {
use super::generate;

const EXAMPLE_WASM: &[u8] =
include_bytes!("../../../../target/wasm32-unknown-unknown/test-wasms/test_udt.wasm");
include_bytes!("../../../../target/wasm32v1-none/test-wasms/test_udt.wasm");

#[test]
fn example() {
Expand Down
20 changes: 10 additions & 10 deletions cmd/crates/soroban-spec-tools/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Spec {
} else {
*out = Some(section.data().to_vec());
}
};
}
}

let mut env_meta_base64 = None;
Expand Down Expand Up @@ -179,7 +179,7 @@ impl Display for Spec {

fn write_func(f: &mut std::fmt::Formatter<'_>, func: &ScSpecFunctionV0) -> std::fmt::Result {
writeln!(f, " • Function: {}", func.name.to_utf8_string_lossy())?;
if func.doc.len() > 0 {
if !func.doc.is_empty() {
writeln!(
f,
" Docs: {}",
Expand All @@ -202,7 +202,7 @@ fn write_func(f: &mut std::fmt::Formatter<'_>, func: &ScSpecFunctionV0) -> std::

fn write_union(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtUnionV0) -> std::fmt::Result {
writeln!(f, " • Union: {}", format_name(&udt.lib, &udt.name))?;
if udt.doc.len() > 0 {
if !udt.doc.is_empty() {
writeln!(
f,
" Docs: {}",
Expand All @@ -219,7 +219,7 @@ fn write_union(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtUnionV0) -> std::

fn write_struct(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtStructV0) -> std::fmt::Result {
writeln!(f, " • Struct: {}", format_name(&udt.lib, &udt.name))?;
if udt.doc.len() > 0 {
if !udt.doc.is_empty() {
writeln!(
f,
" Docs: {}",
Expand All @@ -234,7 +234,7 @@ fn write_struct(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtStructV0) -> std
field.name.to_utf8_string_lossy(),
indent(&format!("{:#?}", field.type_), 8).trim()
)?;
if field.doc.len() > 0 {
if !field.doc.is_empty() {
writeln!(f, "{}", indent(&format!("{:#?}", field.doc), 8))?;
}
}
Expand All @@ -244,7 +244,7 @@ fn write_struct(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtStructV0) -> std

fn write_enum(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtEnumV0) -> std::fmt::Result {
writeln!(f, " • Enum: {}", format_name(&udt.lib, &udt.name))?;
if udt.doc.len() > 0 {
if !udt.doc.is_empty() {
writeln!(
f,
" Docs: {}",
Expand All @@ -261,7 +261,7 @@ fn write_enum(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtEnumV0) -> std::fm

fn write_error(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtErrorEnumV0) -> std::fmt::Result {
writeln!(f, " • Error: {}", format_name(&udt.lib, &udt.name))?;
if udt.doc.len() > 0 {
if !udt.doc.is_empty() {
writeln!(
f,
" Docs: {}",
Expand All @@ -285,13 +285,13 @@ fn indent(s: &str, n: usize) -> String {
}

fn format_name(lib: &StringM<80>, name: &StringM<60>) -> String {
if lib.len() > 0 {
if lib.is_empty() {
name.to_utf8_string_lossy()
} else {
format!(
"{}::{}",
lib.to_utf8_string_lossy(),
name.to_utf8_string_lossy()
)
} else {
name.to_utf8_string_lossy()
}
}
7 changes: 4 additions & 3 deletions cmd/crates/soroban-spec-tools/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(clippy::missing_errors_doc, clippy::must_use_candidate)]
use std::fmt::Write;
use std::str::FromStr;

use itertools::Itertools;
Expand Down Expand Up @@ -452,7 +453,7 @@ impl Spec {
);
}
(ScSpecUdtUnionCaseV0::TupleV0(ScSpecUdtUnionCaseTupleV0 { .. }), Some(_)) => {}
};
}
Ok(ScVal::Vec(Some(res.try_into().map_err(Error::Xdr)?)))
}

Expand All @@ -465,7 +466,7 @@ impl Spec {
let ScSpecTypeTuple { value_types } = tuple;
if items.len() != value_types.len() {
return Err(Error::InvalidValue(Some(t.clone())));
};
}
let parsed: Result<Vec<ScVal>, Error> = items
.iter()
.zip(value_types.iter())
Expand Down Expand Up @@ -1062,7 +1063,7 @@ fn sc_address_from_json(s: &str) -> Result<ScVal, Error> {
fn to_lower_hex(bytes: &[u8]) -> String {
let mut res = String::with_capacity(bytes.len());
for b in bytes {
res.push_str(&format!("{b:02x}"));
let _ = write!(res, "{b:02x}");
}
res
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/crates/soroban-spec-typescript/src/boilerplate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@ mod test {

use super::*;

const EXAMPLE_WASM: &[u8] = include_bytes!(
"../../../../target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm"
);
const EXAMPLE_WASM: &[u8] =
include_bytes!("../../../../target/wasm32v1-none/test-wasms/test_custom_types.wasm");

fn init(root: impl AsRef<Path>) -> std::io::Result<Project> {
let spec = soroban_spec::read::from_wasm(EXAMPLE_WASM).unwrap();
Expand Down
8 changes: 5 additions & 3 deletions cmd/crates/soroban-spec-typescript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,11 @@ pub fn entry_to_method_type(entry: &Entry) -> String {
Entry::Enum { doc, name, cases } => {
let doc = doc_to_ts_doc(doc, None, 0);
let cases = cases.iter().map(enum_case_to_ts).join("\n ");
let name = (name == "Error")
.then(|| format!("{name}s"))
.unwrap_or(name.to_string());
let name = if name == "Error" {
format!("{name}s")
} else {
name.to_string()
};
format!(
r"{doc}export enum {name} {{
{cases}
Expand Down
4 changes: 2 additions & 2 deletions cmd/crates/soroban-spec-typescript/ts-tests/initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ function upload() {
exe eval "(./stellar contract $1 --quiet --source root --wasm $2 --ignore-checks) > $3"
}
function deploy_all() {
upload deploy ../../../../target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm contract-id-custom-types.txt
upload install ../../../../target/wasm32-unknown-unknown/test-wasms/test_constructor.wasm contract-wasm-hash-constructor.txt
upload deploy ../../../../target/wasm32v1-none/test-wasms/test_custom_types.wasm contract-id-custom-types.txt
upload install ../../../../target/wasm32v1-none/test-wasms/test_constructor.wasm contract-wasm-hash-constructor.txt
exe eval "./stellar contract asset deploy --asset native --source root"
}
function bind() {
Expand Down
14 changes: 7 additions & 7 deletions cmd/crates/soroban-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
//! - `TestEnv` is a test environment for running tests isolated from each other.
//! - `TestEnv::with_default` invokes a closure, which is passed a reference to a random `TestEnv`.
//! - `TestEnv::new_assert_cmd` creates an `assert_cmd::Command` for a given subcommand and sets the current
//! directory to be the same as `TestEnv`.
//! directory to be the same as `TestEnv`.
//! - `TestEnv::cmd` is a generic function which parses a command from a string.
//! Note, however, that it uses `shlex` to tokenize the string. This can cause issues
//! for commands which contain strings with `"`s. For example, `{"hello": "world"}` becomes
//! `{hello:world}`. For that reason it's recommended to use `TestEnv::cmd_arr` instead.
//! Note, however, that it uses `shlex` to tokenize the string. This can cause issues
//! for commands which contain strings with `"`s. For example, `{"hello": "world"}` becomes
//! `{hello:world}`. For that reason it's recommended to use `TestEnv::cmd_arr` instead.
//! - `TestEnv::cmd_arr` is a generic function which takes an array of `&str` which is passed directly to clap.
//! This is the preferred way since it ensures no string parsing footguns.
//! This is the preferred way since it ensures no string parsing footguns.
//! - `TestEnv::invoke` a convenience function for using the invoke command.
//!
#![allow(
Expand Down Expand Up @@ -109,7 +109,7 @@ impl TestEnv {
env.network.rpc_url = rpc_url.to_string();
if let Ok(network_passphrase) = std::env::var("STELLAR_NETWORK_PASSPHRASE") {
env.network.network_passphrase = network_passphrase;
};
}
env.generate_account("test", None).assert().success();
env
}
Expand All @@ -120,7 +120,7 @@ impl TestEnv {
env.network.rpc_headers = rpc_headers;
if let Ok(network_passphrase) = std::env::var("STELLAR_NETWORK_PASSPHRASE") {
env.network.network_passphrase = network_passphrase;
};
}
env.generate_account("test", None).assert().success();
env
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crates/soroban-test/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Wasm<'_> {
///
/// # if not found
pub fn path(&self) -> PathBuf {
let path = find_target_dir().unwrap().join("wasm32-unknown-unknown");
let path = find_target_dir().unwrap().join("wasm32v1-none");
let mut path = match self {
Wasm::Release(name) => path.join("release").join(name),
Wasm::Custom(profile, name) => path.join(profile).join(name),
Expand Down
2 changes: 1 addition & 1 deletion cmd/crates/soroban-test/tests/fixtures/eth_abi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test: build

build:
stellar contract build
@ls -l target/wasm32-unknown-unknown/release/*.wasm
@ls -l target/wasm32v1-none/release/*.wasm

fmt:
cargo fmt --all
Expand Down
30 changes: 22 additions & 8 deletions cmd/crates/soroban-test/tests/it/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ fn build_all() {
let sandbox = TestEnv::default();
let cargo_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let fixture_path = cargo_dir.join("tests/fixtures/workspace/");
let expected = format!("cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32-unknown-unknown --release
cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32-unknown-unknown --release
cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32-unknown-unknown --release", add_path(), call_path(), add2_path());
let expected = format!(
"cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32v1-none --release
cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32v1-none --release
cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32v1-none --release",
add_path(),
call_path(),
add2_path()
);
sandbox
.new_assert_cmd("contract")
.current_dir(fixture_path)
Expand All @@ -31,7 +36,10 @@ fn build_package_by_name() {
let sandbox = TestEnv::default();
let cargo_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let fixture_path = cargo_dir.join("tests/fixtures/workspace/");
let expected = format!("cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32-unknown-unknown --release", add_path());
let expected = format!(
"cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32v1-none --release",
add_path()
);
sandbox
.new_assert_cmd("contract")
.current_dir(fixture_path)
Expand All @@ -56,7 +64,7 @@ fn build_package_by_current_dir() {
.assert()
.success()
.stdout(predicate::eq(
with_flags("cargo rustc --manifest-path=Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release"),
with_flags("cargo rustc --manifest-path=Cargo.toml --crate-type=cdylib --target=wasm32v1-none --release"),
));
}

Expand Down Expand Up @@ -85,7 +93,10 @@ fn build_all_when_in_non_package_directory() {
let sandbox = TestEnv::default();
let cargo_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let fixture_path = cargo_dir.join("tests/fixtures/workspace/contracts/add/src/");
let expected = format!("cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32-unknown-unknown --release", parent_path());
let expected = format!(
"cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32v1-none --release",
parent_path()
);

sandbox
.new_assert_cmd("contract")
Expand All @@ -102,7 +113,10 @@ fn build_default_members() {
let sandbox = TestEnv::default();
let cargo_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let fixture_path = cargo_dir.join("tests/fixtures/workspace-with-default-members/");
let expected = format!("cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32-unknown-unknown --release", add_path());
let expected = format!(
"cargo rustc --manifest-path={} --crate-type=cdylib --target=wasm32v1-none --release",
add_path()
);

sandbox
.new_assert_cmd("contract")
Expand Down Expand Up @@ -336,7 +350,7 @@ fn remap_absolute_paths() {
.success();

let wasm_path = manifest_path
.join("target/wasm32-unknown-unknown/release")
.join("target/wasm32v1-none/release")
.join(format!("{contract_name}.wasm"));

let cargo_home = home::cargo_home().unwrap();
Expand Down
4 changes: 1 addition & 3 deletions cmd/crates/soroban-test/tests/it/integration/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ fn init_and_deploy() {
.assert()
.success();

let target_dir = sandbox
.dir()
.join("project/target/wasm32-unknown-unknown/release");
let target_dir = sandbox.dir().join("project/target/wasm32v1-none/release");
assert!(target_dir.exists());

let assert = sandbox
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ zeroize = "1.8.1"
keyring = { version = "3", features = ["apple-native", "windows-native", "sync-secret-service"], optional = true }
whoami = "1.5.2"
serde_with = "3.11.0"
rustc_version = "0.4.1"


[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/assembled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Assembled {
}
if let Some(log) = log_events {
log(footprint, &[self.auth_entries()], &self.sim_res.events()?);
};
}
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/cache/actionlog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Cmd {
match self {
Cmd::Ls(cmd) => cmd.run()?,
Cmd::Read(cmd) => cmd.run()?,
};
}
Ok(())
}
}
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Cmd {
Cmd::Clean(cmd) => cmd.run()?,
Cmd::Path(cmd) => cmd.run()?,
Cmd::Actionlog(cmd) => cmd.run()?,
};
}
Ok(())
}
}
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/alias/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Cmd {
contract,
});
}
};
}

print.infoln(format!(
"Contract alias '{alias}' will reference {contract} on network '{network_passphrase}'",
Expand Down
Loading
Loading