Skip to content

Commit 141d417

Browse files
authored
Use correct target depending on the rust version. (#2022)
Also blocks rust 1.82 and 1.83 from from being used to build contracts.
1 parent fde43ec commit 141d417

File tree

47 files changed

+139
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+139
-98
lines changed

.github/workflows/bindings-ts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: sudo apt update && sudo apt install -y libdbus-1-dev libudev-dev
3838
if: runner.os == 'Linux'
3939
- run: cargo build
40-
- run: rustup target add wasm32-unknown-unknown
40+
- run: rustup target add wasm32v1-none
4141
- run: make build-test-wasms
4242
- run: npm ci && npm run test
4343
working-directory: cmd/crates/soroban-spec-typescript/ts-tests

.github/workflows/rpc-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ jobs:
4646
run: |
4747
gnome-keyring-daemon
4848
- run: cargo build --features additional-libs
49-
- run: rustup target add wasm32-unknown-unknown
49+
- run: rustup target add wasm32v1-none
5050
- run: make build-test-wasms
5151
- run: SOROBAN_PORT=8000 cargo test --features it --package soroban-test --test it -- integration --test-threads=1

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
- run: rustup update
9090
- run: cargo version
9191
- run: rustup target add ${{ matrix.sys.target }}
92-
- run: rustup target add wasm32-unknown-unknown
92+
- run: rustup target add wasm32v1-none
9393
- if: runner.os == 'Linux'
9494
run: sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libudev-dev libdbus-1-dev
9595
- run: cargo clippy --all-targets --target ${{ matrix.sys.target }}

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ build:
4040
cargo build
4141

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

4545
build-test: build-test-wasms install
4646

@@ -72,11 +72,11 @@ publish:
7272

7373
typescript-bindings-fixtures: build-test-wasms
7474
cargo run -- contract bindings typescript \
75-
--wasm ./target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm \
75+
--wasm ./target/wasm32v1-none/test-wasms/test_custom_types.wasm \
7676
--output-dir ./cmd/crates/soroban-spec-typescript/fixtures/test_custom_types \
7777
--overwrite && \
7878
cargo run -- contract bindings typescript \
79-
--wasm ./target/wasm32-unknown-unknown/test-wasms/test_constructor.wasm \
79+
--wasm ./target/wasm32v1-none/test-wasms/test_constructor.wasm \
8080
--output-dir ./cmd/crates/soroban-spec-typescript/fixtures/test_constructor \
8181
--overwrite
8282

cmd/crates/soroban-spec-json/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mod test {
7272
use super::generate;
7373

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

7777
#[test]
7878
fn example() {

cmd/crates/soroban-spec-tools/src/contract.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl Spec {
5959
} else {
6060
*out = Some(section.data().to_vec());
6161
}
62-
};
62+
}
6363
}
6464

6565
let mut env_meta_base64 = None;
@@ -179,7 +179,7 @@ impl Display for Spec {
179179

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

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

220220
fn write_struct(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtStructV0) -> std::fmt::Result {
221221
writeln!(f, " • Struct: {}", format_name(&udt.lib, &udt.name))?;
222-
if udt.doc.len() > 0 {
222+
if !udt.doc.is_empty() {
223223
writeln!(
224224
f,
225225
" Docs: {}",
@@ -234,7 +234,7 @@ fn write_struct(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtStructV0) -> std
234234
field.name.to_utf8_string_lossy(),
235235
indent(&format!("{:#?}", field.type_), 8).trim()
236236
)?;
237-
if field.doc.len() > 0 {
237+
if !field.doc.is_empty() {
238238
writeln!(f, "{}", indent(&format!("{:#?}", field.doc), 8))?;
239239
}
240240
}
@@ -244,7 +244,7 @@ fn write_struct(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtStructV0) -> std
244244

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

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

287287
fn format_name(lib: &StringM<80>, name: &StringM<60>) -> String {
288-
if lib.len() > 0 {
288+
if lib.is_empty() {
289+
name.to_utf8_string_lossy()
290+
} else {
289291
format!(
290292
"{}::{}",
291293
lib.to_utf8_string_lossy(),
292294
name.to_utf8_string_lossy()
293295
)
294-
} else {
295-
name.to_utf8_string_lossy()
296296
}
297297
}

cmd/crates/soroban-spec-tools/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![allow(clippy::missing_errors_doc, clippy::must_use_candidate)]
2+
use std::fmt::Write;
23
use std::str::FromStr;
34

45
use itertools::Itertools;
@@ -452,7 +453,7 @@ impl Spec {
452453
);
453454
}
454455
(ScSpecUdtUnionCaseV0::TupleV0(ScSpecUdtUnionCaseTupleV0 { .. }), Some(_)) => {}
455-
};
456+
}
456457
Ok(ScVal::Vec(Some(res.try_into().map_err(Error::Xdr)?)))
457458
}
458459

@@ -465,7 +466,7 @@ impl Spec {
465466
let ScSpecTypeTuple { value_types } = tuple;
466467
if items.len() != value_types.len() {
467468
return Err(Error::InvalidValue(Some(t.clone())));
468-
};
469+
}
469470
let parsed: Result<Vec<ScVal>, Error> = items
470471
.iter()
471472
.zip(value_types.iter())
@@ -1062,7 +1063,7 @@ fn sc_address_from_json(s: &str) -> Result<ScVal, Error> {
10621063
fn to_lower_hex(bytes: &[u8]) -> String {
10631064
let mut res = String::with_capacity(bytes.len());
10641065
for b in bytes {
1065-
res.push_str(&format!("{b:02x}"));
1066+
let _ = write!(res, "{b:02x}");
10661067
}
10671068
res
10681069
}

cmd/crates/soroban-spec-typescript/src/boilerplate.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,8 @@ mod test {
146146

147147
use super::*;
148148

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

153152
fn init(root: impl AsRef<Path>) -> std::io::Result<Project> {
154153
let spec = soroban_spec::read::from_wasm(EXAMPLE_WASM).unwrap();

cmd/crates/soroban-spec-typescript/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,11 @@ pub fn entry_to_method_type(entry: &Entry) -> String {
281281
Entry::Enum { doc, name, cases } => {
282282
let doc = doc_to_ts_doc(doc, None, 0);
283283
let cases = cases.iter().map(enum_case_to_ts).join("\n ");
284-
let name = (name == "Error")
285-
.then(|| format!("{name}s"))
286-
.unwrap_or(name.to_string());
284+
let name = if name == "Error" {
285+
format!("{name}s")
286+
} else {
287+
name.to_string()
288+
};
287289
format!(
288290
r"{doc}export enum {name} {{
289291
{cases}

0 commit comments

Comments
 (0)