diff --git a/.github/actions/build-and-test/action.yml b/.github/actions/build-and-test/action.yml index fb2f921879..eac22cf73b 100644 --- a/.github/actions/build-and-test/action.yml +++ b/.github/actions/build-and-test/action.yml @@ -30,6 +30,12 @@ runs: - 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 shell: bash + - run: make build-test-wasms + shell: bash + env: + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc + CARGO_BUILD_TARGET: ${{ inputs.target }} + CI_TESTS: true - run: cargo clippy --all-targets --target ${{ inputs.target }} shell: bash - run: make test diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index dea1ea4830..e0b92aedee 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -113,7 +113,6 @@ stellar keys address test # Test key operations The project uses GitHub Actions with workflows in `.github/workflows/`: - `rust.yml`: Main CI pipeline with formatting, linting, building, and testing -- `e2e.yml`: End-to-end system tests - `binaries.yml`: Multi-platform binary builds Always run `make fmt` and `make check` locally before pushing to ensure CI passes. diff --git a/.github/workflows/bindings-ts.yml b/.github/workflows/bindings-ts.yml index cbd17064c8..0327c68246 100644 --- a/.github/workflows/bindings-ts.yml +++ b/.github/workflows/bindings-ts.yml @@ -19,10 +19,9 @@ jobs: # Apple Intel (this runner has better support to nested virtualization) - macos-15-large exclude: - # Only run Linux x64 tests on pull request to save some time - - sys: - ${{ github.event_name != 'push' && 'ubuntu-jammy-8-cores-arm64' }} - - sys: ${{ github.event_name != 'push' && 'macos-15-large' }} + # Only run Linux x64 on non-release PRs to save CI minutes + - sys: ${{ github.event_name != 'push' && !startsWith(github.ref_name, 'release/') && 'ubuntu-jammy-8-cores-arm64' }} + - sys: ${{ github.event_name != 'push' && !startsWith(github.ref_name, 'release/') && 'macos-15-large' }} runs-on: ${{ matrix.sys }} steps: - uses: stellar/quickstart@main diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index fc720cb8b5..0000000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -name: Soroban Tools e2e - -on: - push: - branches: [main, release/**] - pull_request: - -concurrency: - group: - ${{ github.workflow }}-${{ github.ref_protected == 'true' && github.sha || - github.ref }} - cancel-in-progress: true - -jobs: - systems-test: - if: github.event_name == 'push' - strategy: - fail-fast: false - matrix: - sys: - # x64 - - os: ubuntu-latest-8-cores - # ARM - - os: ubuntu-jammy-8-cores-arm64 - # Apple Silicon - - os: macos-15 - # Apple Intel - - os: macos-15-intel - # Windows is not yet supported due to issues with running quickstart image - # - os: windows-latest-8-cores - uses: stellar/system-test/.github/workflows/test.yml@master - with: - js-stellar-sdk-npm-version: v14.0.0-rc.1 - stellar-cli-ref: ${{ github.ref }} - test-filter: "^TestDappDevelop$/^.*$" - runner: ${{ matrix.sys.os }} - quickstart-tag: "testing" - systems-test-linux: - if: github.event_name != 'push' - uses: stellar/system-test/.github/workflows/test.yml@master - with: - js-stellar-sdk-npm-version: v14.2.0 - stellar-cli-ref: ${{ github.ref }} - test-filter: "^TestDappDevelop$/^.*$" - runner: "ubuntu-latest" - quickstart-tag: "testing" diff --git a/.github/workflows/ledger-emulator.yml b/.github/workflows/ledger-emulator.yml index 77f68fe288..2ef100c3ab 100644 --- a/.github/workflows/ledger-emulator.yml +++ b/.github/workflows/ledger-emulator.yml @@ -26,9 +26,9 @@ jobs: # Apple Large Intel (this runner has better support to nested virtualization) # - macos-15-large (temporarily until the runner becomes more reliable. To be re-enabled in https://github.com/stellar/stellar-cli/issues/2299) exclude: - # Only run Linux x64 tests on pull request to save some time - - sys: ${{ github.event_name != 'push' && 'ubuntu-jammy-8-cores-arm64' }} - - sys: ${{ github.event_name != 'push' && 'macos-15-large' }} + # Only run Linux x64 on non-release PRs to save CI minutes + - sys: ${{ github.event_name != 'push' && !startsWith(github.ref_name, 'release/') && 'ubuntu-jammy-8-cores-arm64' }} + - sys: ${{ github.event_name != 'push' && !startsWith(github.ref_name, 'release/') && 'macos-15-large' }} runs-on: ${{ matrix.sys }} env: CI_TESTS: true diff --git a/.github/workflows/rpc-tests.yml b/.github/workflows/rpc-tests.yml index 5dbf12ba22..f8942e959e 100644 --- a/.github/workflows/rpc-tests.yml +++ b/.github/workflows/rpc-tests.yml @@ -24,17 +24,17 @@ jobs: # Apple Intel (this runner has better support to nested virtualization) - macos-15-large exclude: - # Only run Linux x64 tests on pull request to save some time - - sys: - ${{ github.event_name != 'push' && 'ubuntu-jammy-8-cores-arm64' }} - - sys: ${{ github.event_name != 'push' && 'macos-15-large' }} + # Only run Linux x64 on non-release PRs to save CI minutes + - sys: ${{ github.event_name != 'push' && !startsWith(github.ref_name, 'release/') && 'ubuntu-jammy-8-cores-arm64' }} + - sys: ${{ github.event_name != 'push' && !startsWith(github.ref_name, 'release/') && 'macos-15-large' }} runs-on: ${{ matrix.sys }} env: - TEST_THREADS: ${{ contains(matrix.sys, 'macos') && '--test-threads=1' || '' }} # macOS has limited resources, so we run tests (that rely on `testcontainers`) with 1 thread + TEST_THREADS: ${{ contains(matrix.sys, 'macos') && '2' || '4' }} # macOS has limited resources steps: - uses: stellar/quickstart@main with: tag: future + enable: core,rpc - uses: actions/checkout@v5 - uses: stellar/actions/rust-cache@main - run: rustup update @@ -49,15 +49,10 @@ jobs: # the login password doesn't matter, but the keyring must be unlocked for the tests to work # this is based on the ci workflow in the keyring crate repo run: - gnome-keyring-daemon --components=secrets --daemonize --unlock <<< - 'foobar' - - name: Check GNOME Keyring - if: runner.os == 'Linux' - run: | - gnome-keyring-daemon + gnome-keyring-daemon --components=secrets --daemonize --unlock <<< 'foobar' - run: cargo build --features additional-libs - run: rustup target add wasm32v1-none - run: make build-test-wasms - run: RUST_BACKTRACE=1 cargo test --features it --package soroban-test --test it -- - integration $TEST_THREADS + integration --test-threads=$TEST_THREADS diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8b34a3c9bc..ac80fc4fc1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -64,6 +64,7 @@ jobs: - run: sudo apt update && sudo apt install -y libudev-dev libdbus-1-dev - run: rustup update - run: npm install + - run: make build-test-wasms - run: make check build-and-test: diff --git a/Makefile b/Makefile index 5a0b99a28d..3d033115d5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: check build test +all: build-test-wasms check build test REPOSITORY_COMMIT_HASH := "$(shell git rev-parse HEAD)" @@ -52,8 +52,9 @@ test: build-test cargo test --workspace --exclude soroban-test --features additional-libs cargo test -p soroban-test -- --skip integration:: -e2e-test: - cargo test --features it --test it -- integration +# expects a quickstart container running with the rpc exposed at localhost:SOROBAN_PORT +rpc-test: + cargo test --features it --test it -- integration --test-threads=4 check: cargo clippy --all-targets @@ -85,4 +86,4 @@ typescript-bindings-fixtures: build-test-wasms # PHONY lists all the targets that aren't file names, so that make would skip the timestamp based check. -.PHONY: publish clean fmt watch check e2e-test test build-test-wasms install build build-snapshot typescript-bindings-fixtures +.PHONY: publish clean fmt watch check rpc-test test build-test-wasms install build build-snapshot typescript-bindings-fixtures diff --git a/cmd/crates/soroban-spec-tools/src/lib.rs b/cmd/crates/soroban-spec-tools/src/lib.rs index 1039c18527..e4dd8c659d 100644 --- a/cmd/crates/soroban-spec-tools/src/lib.rs +++ b/cmd/crates/soroban-spec-tools/src/lib.rs @@ -1432,54 +1432,353 @@ impl Spec { #[cfg(test)] mod tests { use super::*; + use stellar_xdr::curr::{Duration, ScMap, ScSpecTypeBytesN, TimePoint}; - use stellar_xdr::curr::ScSpecTypeBytesN; + const CUSTOM_TYPES_WASM: &[u8] = + include_bytes!("../../../../target/wasm32v1-none/test-wasms/test_custom_types.wasm"); + + fn get_custom_types_spec() -> Spec { + Spec::from_wasm(CUSTOM_TYPES_WASM).unwrap() + } #[test] - fn from_json_primitives_bytesn() { - // TODO: Add test for parsing addresses + fn test_bool_conversion() { + let as_str = "true"; + let parsed = from_string_primitive(as_str, &ScType::Bool).unwrap(); + let expected = ScVal::Bool(true); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } - // Check it parses hex-encoded bytes - let b = from_json_primitives( - &Value::String("beefface".to_string()), - &ScType::BytesN(ScSpecTypeBytesN { n: 4 }), + #[test] + fn test_null_conversion() { + let as_str = "null"; + let parsed = from_string_primitive( + as_str, + &ScType::Option(Box::new(ScSpecTypeOption { + value_type: Box::new(ScType::Bool), + })), ) .unwrap(); - assert_eq!( - b, - ScVal::Bytes(ScBytes(vec![0xbe, 0xef, 0xfa, 0xce].try_into().unwrap())) - ); - - // Check it parses hex-encoded bytes when they are all numbers. Normally the json would - // interpret the CLI arg as a number, so we need a special case there. - let b = from_json_primitives( - &Value::Number(4554.into()), - &ScType::BytesN(ScSpecTypeBytesN { n: 2 }), + let expected = ScVal::Void; + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_u32_conversion() { + let as_str = "42"; + let parsed = from_string_primitive(as_str, &ScType::U32).unwrap(); + let expected = ScVal::U32(42); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_i32_conversion() { + let as_str = "-42"; + let parsed = from_string_primitive(as_str, &ScType::I32).unwrap(); + let expected = ScVal::I32(-42); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_u64_conversion() { + let as_str = "42000000000"; + let parsed = from_string_primitive(as_str, &ScType::U64).unwrap(); + let expected = ScVal::U64(42_000_000_000); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + #[allow(clippy::cast_possible_truncation)] + fn test_u128_conversion() { + let as_str = "340000000000000000000000000000000000000"; + let parsed = from_string_primitive(as_str, &ScType::U128).unwrap(); + let b = 340_000_000_000_000_000_000_000_000_000_000_000_000u128; + let expected = ScVal::U128(UInt128Parts { + hi: (b >> 64) as u64, + lo: b as u64, + }); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("\"{as_str}\"")); + } + + #[test] + #[allow(clippy::cast_possible_truncation)] + fn test_u256_conversion() { + let as_str = "340000000000000000000000000000000000000"; + let parsed = from_string_primitive(as_str, &ScType::U256).unwrap(); + let b = 340_000_000_000_000_000_000_000_000_000_000_000_000u128; + let expected = ScVal::U256(UInt256Parts { + hi_hi: 0, + hi_lo: 0, + lo_hi: (b >> 64) as u64, + lo_lo: b as u64, + }); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("\"{as_str}\"")); + } + + #[test] + #[allow(clippy::cast_possible_truncation)] + #[allow(clippy::cast_sign_loss)] + fn test_i128_conversion() { + let as_str = "-170000000000000000000000000000000000000"; + let parsed = from_string_primitive(as_str, &ScType::I128).unwrap(); + let b = -170_000_000_000_000_000_000_000_000_000_000_000_000i128; + let expected = ScVal::I128(Int128Parts { + hi: (b >> 64) as i64, + lo: b as u64, + }); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("\"{as_str}\"")); + } + + #[test] + #[allow(clippy::cast_possible_truncation)] + #[allow(clippy::cast_sign_loss)] + fn test_i256_conversion() { + let as_str = "-170000000000000000000000000000000000000"; + let parsed = from_string_primitive(as_str, &ScType::I256).unwrap(); + let b = -170_000_000_000_000_000_000_000_000_000_000_000_000i128; + let expected = ScVal::I256(Int256Parts { + hi_hi: -1, + hi_lo: u64::MAX, + lo_hi: (b >> 64) as u64, + lo_lo: b as u64, + }); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("\"{as_str}\"")); + } + + #[test] + fn test_bytes_conversion() { + let as_str = "beefface"; + let parsed = from_string_primitive(as_str, &ScType::Bytes).unwrap(); + let expected = ScVal::Bytes(ScBytes(vec![0xbe, 0xef, 0xfa, 0xce].try_into().unwrap())); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("\"{as_str}\"")); + } + + #[test] + fn test_bytes_conversion_when_hex_is_all_numbers() { + let as_str = "4554"; + let parsed = from_string_primitive(as_str, &ScType::Bytes).unwrap(); + let expected = ScVal::Bytes(ScBytes(vec![0x45, 0x54].try_into().unwrap())); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("\"{as_str}\"")); + } + + #[test] + fn test_bytesn_conversion() { + let as_str = "beefface"; + let parsed = + from_string_primitive(as_str, &ScType::BytesN(ScSpecTypeBytesN { n: 4 })).unwrap(); + let expected = ScVal::Bytes(ScBytes(vec![0xbe, 0xef, 0xfa, 0xce].try_into().unwrap())); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("\"{as_str}\"")); + } + + #[test] + fn test_bytesn_conversion_when_hex_is_all_numbers() { + let as_str = "4554"; + let parsed = + from_string_primitive(as_str, &ScType::BytesN(ScSpecTypeBytesN { n: 2 })).unwrap(); + let expected = ScVal::Bytes(ScBytes(vec![0x45, 0x54].try_into().unwrap())); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("\"{as_str}\"")); + } + + #[test] + fn test_bytesn_32_conversion() { + let as_str = "9af73e7070f88107cf6a03d8410caecf25fd9da24521edc076c25d559e6b4c87"; + let parsed = + from_string_primitive(as_str, &ScType::BytesN(ScSpecTypeBytesN { n: 32 })).unwrap(); + let expected = ScVal::Bytes(ScBytes( + vec![ + 0x9a, 0xf7, 0x3e, 0x70, 0x70, 0xf8, 0x81, 0x07, 0xcf, 0x6a, 0x03, 0xd8, 0x41, 0x0c, + 0xae, 0xcf, 0x25, 0xfd, 0x9d, 0xa2, 0x45, 0x21, 0xed, 0xc0, 0x76, 0xc2, 0x5d, 0x55, + 0x9e, 0x6b, 0x4c, 0x87, + ] + .try_into() + .unwrap(), + )); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("\"{as_str}\"")); + } + + #[test] + fn test_timepoint_conversion() { + let as_str = "1760501234"; + let parsed = from_string_primitive(as_str, &ScType::Timepoint).unwrap(); + let expected = ScVal::Timepoint(TimePoint::from(1_760_501_234u64)); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_duration_conversion() { + let as_str = "1234567"; + let parsed = from_string_primitive(as_str, &ScType::Duration).unwrap(); + let expected = ScVal::Duration(Duration::from(1_234_567u64)); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_address_conversion() { + let as_str = "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4"; + let parsed = from_string_primitive(as_str, &ScType::Address).unwrap(); + let expected = ScVal::Address(ScAddress::Contract(ContractId(Hash([0; 32])))); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("\"{as_str}\"")); + } + + #[test] + fn test_symbol_conversion() { + let as_str = "hello"; + let parsed = from_string_primitive(&format!("\"{as_str}\""), &ScType::Symbol).unwrap(); + let expected = ScVal::Symbol("hello".try_into().unwrap()); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_symbol_conversion_with_no_quotation_marks() { + let as_str = "hello"; + let parsed = from_string_primitive(as_str, &ScType::Symbol).unwrap(); + let expected = ScVal::Symbol("hello".try_into().unwrap()); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_optional_symbol_conversion_with_no_quotation_marks() { + let as_str = "hello"; + let parsed = from_string_primitive( + as_str, + &ScType::Option(Box::new(ScSpecTypeOption { + value_type: Box::new(ScType::Symbol), + })), + ) + .unwrap(); + let expected = ScVal::Symbol("hello".try_into().unwrap()); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_optional_bool_conversion() { + let as_str = "true"; + let parsed = from_string_primitive( + as_str, + &ScType::Option(Box::new(ScSpecTypeOption { + value_type: Box::new(ScType::Bool), + })), + ) + .unwrap(); + let expected = ScVal::Bool(true); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_vec_conversion() { + let as_str = "[12345,67890,42000000000]"; + let parsed = from_string_primitive( + as_str, + &ScType::Vec(Box::new(ScSpecTypeVec { + element_type: Box::new(ScType::U64), + })), ) .unwrap(); - assert_eq!( - b, - ScVal::Bytes(ScBytes(vec![0x45, 0x54].try_into().unwrap())) - ); + let expected = ScVal::Vec(Some(ScVec::from( + VecM::try_from(vec![ + ScVal::U64(12345), + ScVal::U64(67890), + ScVal::U64(42_000_000_000), + ]) + .unwrap(), + ))); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_tuple_conversion() { + let as_str = r#"["hello",1]"#; + let parsed = from_string_primitive( + as_str, + &ScType::Tuple(Box::new(ScSpecTypeTuple { + value_types: VecM::try_from(vec![ScType::Symbol, ScType::U64]).unwrap(), + })), + ) + .unwrap(); + let expected = ScVal::Vec(Some(ScVec::from( + VecM::try_from(vec![ + ScVal::Symbol("hello".try_into().unwrap()), + ScVal::U64(1), + ]) + .unwrap(), + ))); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_udt_struct_conversion() { + let spec = get_custom_types_spec(); + let type_ = &spec.find_function("strukt").unwrap().inputs[0].type_; + let as_str = r#"{"a":42,"b":false,"c":"world"}"#; + let parsed = spec.from_string(as_str, type_).unwrap(); + let expected = ScVal::Map(Some( + ScMap::sorted_from(vec![ + ScMapEntry { + key: ScVal::Symbol("a".try_into().unwrap()), + val: ScVal::U32(42), + }, + ScMapEntry { + key: ScVal::Symbol("b".try_into().unwrap()), + val: ScVal::Bool(false), + }, + ScMapEntry { + key: ScVal::Symbol("c".try_into().unwrap()), + val: ScVal::Symbol("world".try_into().unwrap()), + }, + ]) + .unwrap(), + )); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), as_str); + } + + #[test] + fn test_udt_enum_conversion() { + let spec = get_custom_types_spec(); + let type_ = &spec.find_function("simple").unwrap().inputs[0].type_; + let as_str = "Second"; + let parsed = spec.from_string(as_str, type_).unwrap(); + let expected = ScVal::Vec(Some(ScVec::from( + VecM::try_from(vec![ScVal::Symbol("Second".try_into().unwrap())]).unwrap(), + ))); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("[\"{as_str}\"]")); } #[test] - fn from_json_primitives_bytes() { - // Check it parses hex-encoded bytes - let b = - from_json_primitives(&Value::String("beefface".to_string()), &ScType::Bytes).unwrap(); - assert_eq!( - b, - ScVal::Bytes(ScBytes(vec![0xbe, 0xef, 0xfa, 0xce].try_into().unwrap())) - ); - - // Check it parses hex-encoded bytes when they are all numbers. Normally the json would - // interpret the CLI arg as a number, so we need a special case there. - let b = from_json_primitives(&Value::Number(4554.into()), &ScType::Bytes).unwrap(); - assert_eq!( - b, - ScVal::Bytes(ScBytes(vec![0x45, 0x54].try_into().unwrap())) - ); + fn parse_udt_const_enum_conversion() { + let spec = get_custom_types_spec(); + let type_ = &spec.find_function("simple").unwrap().inputs[0].type_; + let as_str = "Second"; + let parsed = spec.from_string(as_str, type_).unwrap(); + let expected = ScVal::Vec(Some(ScVec::from( + VecM::try_from(vec![ScVal::Symbol("Second".try_into().unwrap())]).unwrap(), + ))); + assert_eq!(parsed, expected); + assert_eq!(to_string(&parsed).unwrap(), format!("[\"{as_str}\"]")); } #[test] @@ -1772,40 +2071,6 @@ mod tests { assert!(result.is_err()); } - #[test] - fn test_basic_numeric_conversions() { - // Test U32 - let val = 42u32; - let json_val = Value::Number(val.into()); - let scval = from_json_primitives(&json_val, &ScType::U32).unwrap(); - assert_eq!(to_json(&scval).unwrap(), json_val); - - // Test I32 - let val = -42i32; - let json_val = Value::Number(val.into()); - let scval = from_json_primitives(&json_val, &ScType::I32).unwrap(); - assert_eq!(to_json(&scval).unwrap(), json_val); - - // Test U64 - let val = 42u64; - let json_val = Value::Number(val.into()); - let scval = from_json_primitives(&json_val, &ScType::U64).unwrap(); - assert_eq!(to_json(&scval).unwrap(), json_val); - - // Test I64 - let val = -42i64; - let json_val = Value::Number(val.into()); - let scval = from_json_primitives(&json_val, &ScType::I64).unwrap(); - assert_eq!(to_json(&scval).unwrap(), json_val); - - // Test boolean - let scval = from_json_primitives(&Value::Bool(true), &ScType::Bool).unwrap(); - assert_eq!(to_json(&scval).unwrap(), Value::Bool(true)); - - let scval = from_json_primitives(&Value::Bool(false), &ScType::Bool).unwrap(); - assert_eq!(to_json(&scval).unwrap(), Value::Bool(false)); - } - #[test] fn test_numeric_extremes() { // Test U32 maximum @@ -1842,41 +2107,4 @@ mod tests { let scval = from_json_primitives(&json_val, &ScType::I64).unwrap(); assert_eq!(to_json(&scval).unwrap(), json_val); } - - #[test] - fn test_string_primitive_integration() { - // Test that from_string_primitive works with various types - // U128 - let val = "42"; - let scval = from_string_primitive(val, &ScType::U128).unwrap(); - assert_eq!(to_string(&scval).unwrap(), "\"42\""); - - // I128 - let val = "-42"; - let scval = from_string_primitive(val, &ScType::I128).unwrap(); - assert_eq!(to_string(&scval).unwrap(), "\"-42\""); - - // U256 - let val = "12345678901234567890123456789012345678901234567890"; - let scval = from_string_primitive(val, &ScType::U256).unwrap(); - assert_eq!( - to_string(&scval).unwrap(), - "\"12345678901234567890123456789012345678901234567890\"" - ); - - // I256 - let val = "-12345678901234567890123456789012345678901234567890"; - let scval = from_string_primitive(val, &ScType::I256).unwrap(); - assert_eq!( - to_string(&scval).unwrap(), - "\"-12345678901234567890123456789012345678901234567890\"" - ); - - // Boolean - let scval = from_string_primitive("true", &ScType::Bool).unwrap(); - assert_eq!(to_string(&scval).unwrap(), "true"); - - let scval = from_string_primitive("false", &ScType::Bool).unwrap(); - assert_eq!(to_string(&scval).unwrap(), "false"); - } } diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_constructor/src/index.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_constructor/src/index.ts index 4bca55e969..0faae6273f 100644 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_constructor/src/index.ts +++ b/cmd/crates/soroban-spec-typescript/fixtures/test_constructor/src/index.ts @@ -1,5 +1,5 @@ import { Buffer } from "buffer"; -import { Address } from '@stellar/stellar-sdk'; +import { Address } from "@stellar/stellar-sdk"; import { AssembledTransaction, Client as ContractClient, @@ -7,7 +7,7 @@ import { MethodOptions, Result, Spec as ContractSpec, -} from '@stellar/stellar-sdk/contract'; +} from "@stellar/stellar-sdk/contract"; import type { u32, i32, @@ -18,14 +18,14 @@ import type { u256, i256, Option, - Typepoint, + Timepoint, Duration, -} from '@stellar/stellar-sdk/contract'; -export * from '@stellar/stellar-sdk' -export * as contract from '@stellar/stellar-sdk/contract' -export * as rpc from '@stellar/stellar-sdk/rpc' +} from "@stellar/stellar-sdk/contract"; +export * from "@stellar/stellar-sdk"; +export * as contract from "@stellar/stellar-sdk/contract"; +export * as rpc from "@stellar/stellar-sdk/rpc"; -if (typeof window !== 'undefined') { +if (typeof window !== "undefined") { //@ts-ignore Buffer exists window.Buffer = window.Buffer || Buffer; } @@ -61,8 +61,8 @@ export class Client extends ContractClient { } constructor(public readonly options: ContractClientOptions) { super( - new ContractSpec([ "AAAAAAAAABNFeGFtcGxlIGNvbnN0cnVjdG9yAAAAAA1fX2NvbnN0cnVjdG9yAAAAAAAAAQAAAAAAAAAHY291bnRlcgAAAAAEAAAAAA==", - "AAAAAAAAAA1Db3VudGVyIHZhbHVlAAAAAAAAB2NvdW50ZXIAAAAAAAAAAAEAAAAE" ]), + new ContractSpec([ "AAAAAAAAAA1Db3VudGVyIHZhbHVlAAAAAAAAB2NvdW50ZXIAAAAAAAAAAAEAAAAE", + "AAAAAAAAABNFeGFtcGxlIGNvbnN0cnVjdG9yAAAAAA1fX2NvbnN0cnVjdG9yAAAAAAAAAQAAAAAAAAAHY291bnRlcgAAAAAEAAAAAA==" ]), options ) } diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/index.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/index.ts index def0f6a01f..80a58203e1 100644 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/index.ts +++ b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/index.ts @@ -1,5 +1,5 @@ import { Buffer } from "buffer"; -import { Address } from '@stellar/stellar-sdk'; +import { Address } from "@stellar/stellar-sdk"; import { AssembledTransaction, Client as ContractClient, @@ -7,7 +7,7 @@ import { MethodOptions, Result, Spec as ContractSpec, -} from '@stellar/stellar-sdk/contract'; +} from "@stellar/stellar-sdk/contract"; import type { u32, i32, @@ -18,14 +18,14 @@ import type { u256, i256, Option, - Typepoint, + Timepoint, Duration, -} from '@stellar/stellar-sdk/contract'; -export * from '@stellar/stellar-sdk' -export * as contract from '@stellar/stellar-sdk/contract' -export * as rpc from '@stellar/stellar-sdk/rpc' +} from "@stellar/stellar-sdk/contract"; +export * from "@stellar/stellar-sdk"; +export * as contract from "@stellar/stellar-sdk/contract"; +export * as rpc from "@stellar/stellar-sdk/rpc"; -if (typeof window !== 'undefined') { +if (typeof window !== "undefined") { //@ts-ignore Buffer exists window.Buffer = window.Buffer || Buffer; } @@ -43,20 +43,6 @@ export interface Test { c: string; } -export type SimpleEnum = {tag: "First", values: void} | {tag: "Second", values: void} | {tag: "Third", values: void}; - -export enum RoyalCard { - Jack = 11, - Queen = 12, - King = 13, -} - -export type TupleStruct = readonly [Test, SimpleEnum]; - -export type ComplexEnum = {tag: "Struct", values: readonly [Test]} | {tag: "Tuple", values: readonly [TupleStruct]} | {tag: "Enum", values: readonly [SimpleEnum]} | {tag: "Asset", values: readonly [string, i128]} | {tag: "Void", values: void}; - -export type RecursiveEnum = {tag: "List", values: readonly [Array]} | {tag: "Void", values: void}; - export const Errors = { /** * Please provide an odd number @@ -72,16 +58,31 @@ export const Erroneous = { 100: {message:"HowCouldYou"} } +export enum RoyalCard { + Jack = 11, + Queen = 12, + King = 13, +} + +export type SimpleEnum = {tag: "First", values: void} | {tag: "Second", values: void} | {tag: "Third", values: void}; + +export type ComplexEnum = {tag: "Struct", values: readonly [Test]} | {tag: "Tuple", values: readonly [TupleStruct]} | {tag: "Enum", values: readonly [SimpleEnum]} | {tag: "Asset", values: readonly [string, i128]} | {tag: "Void", values: void}; + +export type TupleStruct = readonly [Test, SimpleEnum]; + +export type RecursiveEnum = {tag: "List", values: readonly [Array]} | {tag: "Void", values: void}; + export interface Client { /** - * Construct and simulate a hello transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a map transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - hello: ({hello}: {hello: string}, options?: MethodOptions) => Promise> + map: ({map}: {map: Map}, options?: MethodOptions) => Promise>> /** - * Construct and simulate a woid transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a not transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Negates a boolean value */ - woid: (options?: MethodOptions) => Promise> + not: ({boolean}: {boolean: boolean}, options?: MethodOptions) => Promise> /** * Construct and simulate a val transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. @@ -89,55 +90,54 @@ export interface Client { val: (options?: MethodOptions) => Promise> /** - * Construct and simulate a u32_fail_on_even transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a vec transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - u32_fail_on_even: ({u32_}: {u32_: u32}, options?: MethodOptions) => Promise>> + vec: ({vec}: {vec: Array}, options?: MethodOptions) => Promise>> /** - * Construct and simulate a u32_ transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a card transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - u32_: ({u32_}: {u32_: u32}, options?: MethodOptions) => Promise> + card: ({card}: {card: RoyalCard}, options?: MethodOptions) => Promise> /** - * Construct and simulate a i32_ transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a i128 transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - i32_: ({i32_}: {i32_: i32}, options?: MethodOptions) => Promise> + i128: ({i128}: {i128: i128}, options?: MethodOptions) => Promise> /** - * Construct and simulate a i64_ transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a i256 transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - i64_: ({i64_}: {i64_: i64}, options?: MethodOptions) => Promise> + i256: ({i256}: {i256: i256}, options?: MethodOptions) => Promise> /** - * Construct and simulate a strukt_hel transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. - * Example contract method which takes a struct + * Construct and simulate a i32_ transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - strukt_hel: ({strukt}: {strukt: Test}, options?: MethodOptions) => Promise>> + i32_: ({i32_}: {i32_: i32}, options?: MethodOptions) => Promise> /** - * Construct and simulate a strukt transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a i64_ transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - strukt: ({strukt}: {strukt: Test}, options?: MethodOptions) => Promise> + i64_: ({i64_}: {i64_: i64}, options?: MethodOptions) => Promise> /** - * Construct and simulate a simple transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a u128 transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - simple: ({simple}: {simple: SimpleEnum}, options?: MethodOptions) => Promise> + u128: ({u128}: {u128: u128}, options?: MethodOptions) => Promise> /** - * Construct and simulate a complex transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a u256 transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - complex: ({complex}: {complex: ComplexEnum}, options?: MethodOptions) => Promise> + u256: ({u256}: {u256: u256}, options?: MethodOptions) => Promise> /** - * Construct and simulate a recursive_enum transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a u32_ transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - recursive_enum: ({recursive}: {recursive: RecursiveEnum}, options?: MethodOptions) => Promise> + u32_: ({u32_}: {u32_: u32}, options?: MethodOptions) => Promise> /** - * Construct and simulate a addresse transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a woid transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - addresse: ({addresse}: {addresse: string}, options?: MethodOptions) => Promise> + woid: (options?: MethodOptions) => Promise> /** * Construct and simulate a bytes transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. @@ -145,82 +145,92 @@ export interface Client { bytes: ({bytes}: {bytes: Buffer}, options?: MethodOptions) => Promise> /** - * Construct and simulate a bytes_n transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a hello transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - bytes_n: ({bytes_n}: {bytes_n: Buffer}, options?: MethodOptions) => Promise> + hello: ({hello}: {hello: string}, options?: MethodOptions) => Promise> /** - * Construct and simulate a card transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a tuple transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - card: ({card}: {card: RoyalCard}, options?: MethodOptions) => Promise> + tuple: ({tuple}: {tuple: readonly [string, u32]}, options?: MethodOptions) => Promise> /** - * Construct and simulate a boolean transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a option transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Example of an optional argument */ - boolean: ({boolean}: {boolean: boolean}, options?: MethodOptions) => Promise> + option: ({option}: {option: Option}, options?: MethodOptions) => Promise>> /** - * Construct and simulate a not transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. - * Negates a boolean value + * Construct and simulate a simple transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - not: ({boolean}: {boolean: boolean}, options?: MethodOptions) => Promise> + simple: ({simple}: {simple: SimpleEnum}, options?: MethodOptions) => Promise> /** - * Construct and simulate a i128 transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a string transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - i128: ({i128}: {i128: i128}, options?: MethodOptions) => Promise> + string: ({string}: {string: string}, options?: MethodOptions) => Promise> /** - * Construct and simulate a u128 transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a strukt transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - u128: ({u128}: {u128: u128}, options?: MethodOptions) => Promise> + strukt: ({strukt}: {strukt: Test}, options?: MethodOptions) => Promise> /** - * Construct and simulate a multi_args transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a boolean transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - multi_args: ({a, b}: {a: u32, b: boolean}, options?: MethodOptions) => Promise> + boolean: ({boolean}: {boolean: boolean}, options?: MethodOptions) => Promise> /** - * Construct and simulate a map transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a bytes_n transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - map: ({map}: {map: Map}, options?: MethodOptions) => Promise>> + bytes_n: ({bytes_n}: {bytes_n: Buffer}, options?: MethodOptions) => Promise> /** - * Construct and simulate a vec transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a complex transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - vec: ({vec}: {vec: Array}, options?: MethodOptions) => Promise>> + complex: ({complex}: {complex: ComplexEnum}, options?: MethodOptions) => Promise> /** - * Construct and simulate a tuple transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a addresse transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - tuple: ({tuple}: {tuple: readonly [string, u32]}, options?: MethodOptions) => Promise> + addresse: ({addresse}: {addresse: string}, options?: MethodOptions) => Promise> /** - * Construct and simulate a option transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. - * Example of an optional argument + * Construct and simulate a duration transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - option: ({option}: {option: Option}, options?: MethodOptions) => Promise>> + duration: ({duration}: {duration: Duration}, options?: MethodOptions) => Promise> /** - * Construct and simulate a u256 transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a timepoint transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - u256: ({u256}: {u256: u256}, options?: MethodOptions) => Promise> + timepoint: ({timepoint}: {timepoint: Timepoint}, options?: MethodOptions) => Promise> /** - * Construct and simulate a i256 transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a multi_args transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ - i256: ({i256}: {i256: i256}, options?: MethodOptions) => Promise> + multi_args: ({a, b}: {a: u32, b: boolean}, options?: MethodOptions) => Promise> /** - * Construct and simulate a string transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Construct and simulate a strukt_hel transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Example contract method which takes a struct */ - string: ({string}: {string: string}, options?: MethodOptions) => Promise> + strukt_hel: ({strukt}: {strukt: Test}, options?: MethodOptions) => Promise>> /** * Construct and simulate a tuple_strukt transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ tuple_strukt: ({tuple_strukt}: {tuple_strukt: TupleStruct}, options?: MethodOptions) => Promise> + /** + * Construct and simulate a recursive_enum transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + recursive_enum: ({recursive}: {recursive: RecursiveEnum}, options?: MethodOptions) => Promise> + + /** + * Construct and simulate a u32_fail_on_even transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + u32_fail_on_even: ({u32_}: {u32_: u32}, options?: MethodOptions) => Promise>> + } export class Client extends ContractClient { static async deploy( @@ -240,74 +250,78 @@ export class Client extends ContractClient { constructor(public readonly options: ContractClientOptions) { super( new ContractSpec([ "AAAAAQAAAC9U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"AAAAAAAAAAAAAAAKbXVsdGlfYXJncwAAAAAAAgAAAAAAAAABYQAAAAAAAAQAAAAAAAAAAWIAAAAAAAABAAAAAQAAAAQ=", + "AAAAAAAAACxFeGFtcGxlIGNvbnRyYWN0IG1ldGhvZCB3aGljaCB0YWtlcyBhIHN0cnVjdAAAAApzdHJ1a3RfaGVsAAAAAAABAAAAAAAAAAZzdHJ1a3QAAAAAB9AAAAAEVGVzdAAAAAEAAAPqAAAAEQ==", + "AAAAAgAAAAAAAAAAAAAADVJlY3Vyc2l2ZUVudW0AAAAAAAACAAAAAQAAAAAAAAAETGlzdAAAAAEAAAPqAAAH0AAAAA1SZWN1cnNpdmVFbnVtAAAAAAAAAAAAAAAAAAAEVm9pZA==", + "AAAAAAAAAAAAAAAMdHVwbGVfc3RydWt0AAAAAQAAAAAAAAAMdHVwbGVfc3RydWt0AAAH0AAAAAtUdXBsZVN0cnVjdAAAAAABAAAH0AAAAAtUdXBsZVN0cnVjdAA=", + "AAAAAAAAAAAAAAAOcmVjdXJzaXZlX2VudW0AAAAAAAEAAAAAAAAACXJlY3Vyc2l2ZQAAAAAAB9AAAAANUmVjdXJzaXZlRW51bQAAAAAAAAEAAAfQAAAADVJlY3Vyc2l2ZUVudW0AAAA=", + "AAAAAAAAAAAAAAAQdTMyX2ZhaWxfb25fZXZlbgAAAAEAAAAAAAAABHUzMl8AAAAEAAAAAQAAA+kAAAAEAAAAAw==" ]), options ) } public readonly fromJSON = { - hello: this.txFromJSON, - woid: this.txFromJSON, + map: this.txFromJSON>, + not: this.txFromJSON, val: this.txFromJSON, - u32_fail_on_even: this.txFromJSON>, - u32_: this.txFromJSON, - i32_: this.txFromJSON, - i64_: this.txFromJSON, - strukt_hel: this.txFromJSON>, - strukt: this.txFromJSON, - simple: this.txFromJSON, - complex: this.txFromJSON, - recursive_enum: this.txFromJSON, - addresse: this.txFromJSON, - bytes: this.txFromJSON, - bytes_n: this.txFromJSON, + vec: this.txFromJSON>, card: this.txFromJSON, - boolean: this.txFromJSON, - not: this.txFromJSON, i128: this.txFromJSON, + i256: this.txFromJSON, + i32_: this.txFromJSON, + i64_: this.txFromJSON, u128: this.txFromJSON, - multi_args: this.txFromJSON, - map: this.txFromJSON>, - vec: this.txFromJSON>, + u256: this.txFromJSON, + u32_: this.txFromJSON, + woid: this.txFromJSON, + bytes: this.txFromJSON, + hello: this.txFromJSON, tuple: this.txFromJSON, option: this.txFromJSON>, - u256: this.txFromJSON, - i256: this.txFromJSON, + simple: this.txFromJSON, string: this.txFromJSON, - tuple_strukt: this.txFromJSON + strukt: this.txFromJSON, + boolean: this.txFromJSON, + bytes_n: this.txFromJSON, + complex: this.txFromJSON, + addresse: this.txFromJSON, + duration: this.txFromJSON, + timepoint: this.txFromJSON, + multi_args: this.txFromJSON, + strukt_hel: this.txFromJSON>, + tuple_strukt: this.txFromJSON, + recursive_enum: this.txFromJSON, + u32_fail_on_even: this.txFromJSON> } } \ No newline at end of file diff --git a/cmd/crates/soroban-spec-typescript/src/project_template/src/index.ts b/cmd/crates/soroban-spec-typescript/src/project_template/src/index.ts index b344a1c60f..279e0e7272 100644 --- a/cmd/crates/soroban-spec-typescript/src/project_template/src/index.ts +++ b/cmd/crates/soroban-spec-typescript/src/project_template/src/index.ts @@ -1,5 +1,5 @@ import { Buffer } from "buffer"; -import { Address } from '@stellar/stellar-sdk'; +import { Address } from "@stellar/stellar-sdk"; import { AssembledTransaction, Client as ContractClient, @@ -7,7 +7,7 @@ import { MethodOptions, Result, Spec as ContractSpec, -} from '@stellar/stellar-sdk/contract'; +} from "@stellar/stellar-sdk/contract"; import type { u32, i32, @@ -18,14 +18,14 @@ import type { u256, i256, Option, - Typepoint, + Timepoint, Duration, -} from '@stellar/stellar-sdk/contract'; -export * from '@stellar/stellar-sdk' -export * as contract from '@stellar/stellar-sdk/contract' -export * as rpc from '@stellar/stellar-sdk/rpc' +} from "@stellar/stellar-sdk/contract"; +export * from "@stellar/stellar-sdk"; +export * as contract from "@stellar/stellar-sdk/contract"; +export * as rpc from "@stellar/stellar-sdk/rpc"; -if (typeof window !== 'undefined') { +if (typeof window !== "undefined") { //@ts-ignore Buffer exists window.Buffer = window.Buffer || Buffer; } diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json b/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json index 48475cf58a..4fa8a20e42 100644 --- a/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json +++ b/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json @@ -4,11 +4,10 @@ "requires": true, "packages": { "": { - "name": "ts-tests", "hasInstallScript": true, "devDependencies": { "@ava/typescript": "^4.1.0", - "@stellar/stellar-sdk": "^14.0.0-rc.3", + "@stellar/stellar-sdk": "^14.4.0", "@types/node": "^20.4.9", "@typescript-eslint/eslint-plugin": "^6.10.0", "@typescript-eslint/parser": "^6.10.0", @@ -26,6 +25,7 @@ "resolved": "https://registry.npmjs.org/@ava/typescript/-/typescript-4.1.0.tgz", "integrity": "sha512-1iWZQ/nr9iflhLK9VN8H+1oDZqe93qxNnyYUz+jTzkYPAHc5fdZXBrqmNIgIfFhWYXK5OaQ5YtC7OmLeTNhVEg==", "dev": true, + "peer": true, "dependencies": { "escape-string-regexp": "^5.0.0", "execa": "^7.1.1" @@ -170,10 +170,11 @@ "dev": true }, "node_modules/@noble/curves": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.4.tgz", - "integrity": "sha512-2bKONnuM53lINoDrSmK8qP8W271ms7pygDhZt4SiLOoLwBtoHqeCFi6RG42V8zd3mLHuJFhU/Bmaqo4nX0/kBw==", + "version": "1.9.7", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", + "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", "dev": true, + "license": "MIT", "dependencies": { "@noble/hashes": "1.8.0" }, @@ -189,6 +190,7 @@ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", "dev": true, + "license": "MIT", "engines": { "node": "^14.21.3 || >=16" }, @@ -235,33 +237,37 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/@stellar/js-xdr/-/js-xdr-3.1.2.tgz", "integrity": "sha512-VVolPL5goVEIsvuGqDc5uiKxV03lzfWdvYg1KikvwheDmTBO68CKDji3bAZ/kppZrx5iTA8z3Ld5yuytcvhvOQ==", - "dev": true + "dev": true, + "license": "Apache-2.0" }, "node_modules/@stellar/stellar-base": { - "version": "14.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@stellar/stellar-base/-/stellar-base-14.0.0-rc.2.tgz", - "integrity": "sha512-jzDJANrh8hcW3yWikS0At6MWOmf2dCD2cwWS1o0nZLRDj3tFMCrIcOGmw9uB7Widomdu4DzKHetpgn+XB1prpg==", + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/@stellar/stellar-base/-/stellar-base-14.0.3.tgz", + "integrity": "sha512-mBxNArxWq4wKNJATPJpXB2vIRQ3vUzIvjMCloSsGbfKRrSy96ie8yy7DWh9vSOHV6tNwe85hd3v+p/shlyosqA==", "dev": true, + "license": "Apache-2.0", "dependencies": { - "@noble/curves": "^1.9.2", + "@noble/curves": "^1.9.6", "@stellar/js-xdr": "^3.1.2", "base32.js": "^0.1.0", - "bignumber.js": "^9.3.0", + "bignumber.js": "^9.3.1", "buffer": "^6.0.3", - "sha.js": "^2.3.6" + "sha.js": "^2.4.12" }, "engines": { "node": ">=20.0.0" } }, "node_modules/@stellar/stellar-sdk": { - "version": "14.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-14.0.0-rc.3.tgz", - "integrity": "sha512-RI+8uPYAHvauuwmGNbofv9e6Q2LnUjdqUwRCBSN7ZCEWH48DA/bAL6u+X7+WcF13PHsZPeNlp5bHZ5xHbzXdYA==", + "version": "14.4.0", + "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-14.4.0.tgz", + "integrity": "sha512-YsWbcjdEMi8HsA9l5Sr+V3ajSrrM/ZXNyIGGGmpGH+IUfo6uskczGuOmN/fQ0xhuajuMrbitnuaXmsVb7pjKjg==", "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", "dependencies": { - "@stellar/stellar-base": "^14.0.0-rc.2", - "axios": "^1.8.4", + "@stellar/stellar-base": "^14.0.3", + "axios": "^1.12.2", "bignumber.js": "^9.3.1", "eventsource": "^2.0.2", "feaxios": "^0.0.23", @@ -334,6 +340,7 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.21.0.tgz", "integrity": "sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==", "dev": true, + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "6.21.0", "@typescript-eslint/types": "6.21.0", @@ -495,6 +502,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true, + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -742,6 +750,7 @@ "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", "dev": true, + "license": "MIT", "dependencies": { "possible-typed-array-names": "^1.0.0" }, @@ -753,14 +762,14 @@ } }, "node_modules/axios": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.9.0.tgz", - "integrity": "sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz", + "integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==", "dev": true, "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", + "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, @@ -775,6 +784,7 @@ "resolved": "https://registry.npmjs.org/base32.js/-/base32.js-0.1.0.tgz", "integrity": "sha512-n3TkB02ixgBOhTvANakDb4xaMXnYUVkNoRFJjQflcqMQhyEKxEHdj3E6N8t8sUQ0mjH/3/JxzlXuz3ul/J90pQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -804,6 +814,7 @@ "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz", "integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==", "dev": true, + "license": "MIT", "engines": { "node": "*" } @@ -877,6 +888,7 @@ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", "dev": true, + "license": "MIT", "dependencies": { "call-bind-apply-helpers": "^1.0.0", "es-define-property": "^1.0.0", @@ -909,6 +921,7 @@ "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", "dev": true, + "license": "MIT", "dependencies": { "call-bind-apply-helpers": "^1.0.2", "get-intrinsic": "^1.3.0" @@ -1267,6 +1280,7 @@ "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dev": true, + "license": "MIT", "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", @@ -1439,6 +1453,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", "dev": true, + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -1856,9 +1871,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", - "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", "dev": true, "funding": [ { @@ -1881,6 +1896,7 @@ "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", "dev": true, + "license": "MIT", "dependencies": { "is-callable": "^1.2.7" }, @@ -1892,9 +1908,9 @@ } }, "node_modules/form-data": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", - "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", "dev": true, "license": "MIT", "dependencies": { @@ -2121,6 +2137,7 @@ "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dev": true, + "license": "MIT", "dependencies": { "es-define-property": "^1.0.0" }, @@ -2296,6 +2313,7 @@ "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -2405,6 +2423,7 @@ "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.15.tgz", "integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==", "dev": true, + "license": "MIT", "dependencies": { "which-typed-array": "^1.1.16" }, @@ -2431,7 +2450,8 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/isexe": { "version": "2.0.0", @@ -3061,6 +3081,7 @@ "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" } @@ -3297,6 +3318,7 @@ "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", "dev": true, + "license": "MIT", "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", @@ -3314,6 +3336,7 @@ "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.12.tgz", "integrity": "sha512-8LzC5+bvI45BjpfXU8V5fdU2mfeKiQe1D1gIMn7XUlF3OTUrpdJpPPH4EMAnF0DsHHdSZqCdSss5qCmJKuiO3w==", "dev": true, + "license": "(MIT AND BSD-3-Clause)", "dependencies": { "inherits": "^2.0.4", "safe-buffer": "^5.2.1", @@ -3538,10 +3561,11 @@ } }, "node_modules/to-buffer": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.2.1.tgz", - "integrity": "sha512-tB82LpAIWjhLYbqjx3X4zEeHN6M8CiuOEy2JY8SEQVdYRe3CCHOFaqrBW1doLDrfpWhplcW7BL+bO3/6S3pcDQ==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.2.2.tgz", + "integrity": "sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw==", "dev": true, + "license": "MIT", "dependencies": { "isarray": "^2.0.5", "safe-buffer": "^5.2.1", @@ -3610,6 +3634,7 @@ "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", "integrity": "sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==", "dev": true, + "license": "MIT", "dependencies": { "call-bound": "^1.0.3", "es-errors": "^1.3.0", @@ -3625,6 +3650,7 @@ "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -3683,6 +3709,7 @@ "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz", "integrity": "sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==", "dev": true, + "license": "MIT", "dependencies": { "available-typed-arrays": "^1.0.7", "call-bind": "^1.0.8", diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/package.json b/cmd/crates/soroban-spec-typescript/ts-tests/package.json index 759e8cedd6..20216d43e8 100644 --- a/cmd/crates/soroban-spec-typescript/ts-tests/package.json +++ b/cmd/crates/soroban-spec-typescript/ts-tests/package.json @@ -8,7 +8,7 @@ }, "devDependencies": { "@ava/typescript": "^4.1.0", - "@stellar/stellar-sdk": "^14.0.0-rc.3", + "@stellar/stellar-sdk": "^14.4.0", "@types/node": "^20.4.9", "@typescript-eslint/eslint-plugin": "^6.10.0", "@typescript-eslint/parser": "^6.10.0", diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/src/test-custom-types.ts b/cmd/crates/soroban-spec-typescript/ts-tests/src/test-custom-types.ts index 444e9e9973..765a368b43 100644 --- a/cmd/crates/soroban-spec-typescript/ts-tests/src/test-custom-types.ts +++ b/cmd/crates/soroban-spec-typescript/ts-tests/src/test-custom-types.ts @@ -1,6 +1,10 @@ -import test from 'ava' -import { root, rpcUrl, signer } from './util.js' -import { Client, networks, contract as ContractClient } from 'test-custom-types' +import test from "ava"; +import { root, rpcUrl, signer } from "./util.js"; +import { + Client, + networks, + contract as ContractClient, +} from "test-custom-types"; const publicKey = root.keypair.publicKey(); @@ -12,180 +16,214 @@ const contract = new Client({ ...signer, }); -test('hello', async t => { - const { result } = await contract.hello({ hello: 'tests' }) - t.is(result, 'tests') -}) +test("hello", async (t) => { + const { result } = await contract.hello({ hello: "tests" }); + t.is(result, "tests"); +}); -test('woid', async t => { - t.is((await contract.woid()).result, null) -}) +test("woid", async (t) => { + t.is((await contract.woid()).result, null); +}); -test('u32_fail_on_even', async t => { +test("u32_fail_on_even", async (t) => { t.deepEqual( (await contract.u32_fail_on_even({ u32_: 1 })).result, - new ContractClient.Ok(1) - ) + new ContractClient.Ok(1), + ); t.deepEqual( (await contract.u32_fail_on_even({ u32_: 0 })).result, - new ContractClient.Err({ message: "Please provide an odd number" }) - ) -}) + new ContractClient.Err({ message: "Please provide an odd number" }), + ); +}); -test('u32_', async t => { - t.is((await contract.u32_({ u32_: 1 })).result, 1) -}) +test("u32_", async (t) => { + t.is((await contract.u32_({ u32_: 1 })).result, 1); +}); -test('i32_', async t => { - t.is((await contract.i32_({ i32_: 1 })).result, 1) -}) +test("i32_", async (t) => { + t.is((await contract.i32_({ i32_: 1 })).result, 1); +}); -test('i64_', async t => { - t.is((await contract.i64_({ i64_: 1n })).result, 1n) -}) +test("i64_", async (t) => { + t.is((await contract.i64_({ i64_: 1n })).result, 1n); +}); test("strukt_hel", async (t) => { - const test = { a: 0, b: true, c: "world" } - t.deepEqual((await contract.strukt_hel({ strukt: test })).result, ["Hello", "world"]) -}) + const test = { a: 0, b: true, c: "world" }; + t.deepEqual((await contract.strukt_hel({ strukt: test })).result, [ + "Hello", + "world", + ]); +}); test("strukt", async (t) => { - const test = { a: 0, b: true, c: "hello" } - t.deepEqual((await contract.strukt({ strukt: test })).result, test) -}) - -test('simple first', async t => { - const arg = { tag: 'First', values: undefined } as const - const ret = { tag: 'First' } - t.deepEqual((await contract.simple({ simple: arg })).result, ret) -}) - -test('simple second', async t => { - const arg = { tag: 'Second', values: undefined } as const - const ret = { tag: 'Second' } - t.deepEqual((await contract.simple({ simple: arg })).result, ret) -}) - -test('simple third', async t => { - const arg = { tag: 'Third', values: undefined } as const - const ret = { tag: 'Third' } - t.deepEqual((await contract.simple({ simple: arg })).result, ret) -}) - -test('complex with struct', async t => { - const arg = { tag: 'Struct', values: [{ a: 0, b: true, c: 'hello' }] } as const - const ret = { tag: 'Struct', values: [{ a: 0, b: true, c: 'hello' }] } - t.deepEqual((await contract.complex({ complex: arg })).result, ret) -}) - -test('complex with tuple', async t => { - const arg = { tag: 'Tuple', values: [[{ a: 0, b: true, c: 'hello' }, { tag: 'First', values: undefined }]] } as const - const ret = { tag: 'Tuple', values: [[{ a: 0, b: true, c: 'hello' }, { tag: 'First' }]] } - t.deepEqual((await contract.complex({ complex: arg })).result, ret) -}) - -test('complex with enum', async t => { - const arg = { tag: 'Enum', values: [{ tag: 'First', values: undefined }] } as const - const ret = { tag: 'Enum', values: [{ tag: 'First' }] } - t.deepEqual((await contract.complex({ complex: arg })).result, ret) -}) - -test('complex with asset', async t => { - const arg = { tag: 'Asset', values: [publicKey, 1n] } as const - const ret = { tag: 'Asset', values: [publicKey, 1n] } - t.deepEqual((await contract.complex({ complex: arg })).result, ret) -}) - -test('complex with void', async t => { - const arg = { tag: 'Void', values: undefined } as const - const ret = { tag: 'Void' } - t.deepEqual((await contract.complex({ complex: arg })).result, ret) -}) - -test('addresse', async t => { - t.deepEqual((await contract.addresse({ addresse: publicKey })).result, publicKey) -}) - -test('bytes', async t => { - const bytes = Buffer.from('hello') - t.deepEqual((await contract.bytes({ bytes })).result, bytes) -}) - -test('bytes_n', async t => { - const bytes_n = Buffer.from('123456789') // what's the correct way to construct bytes_n? - t.deepEqual((await contract.bytes_n({ bytes_n })).result, bytes_n) -}) - -test('card', async t => { - const card = 11 - t.is((await contract.card({ card })).result, card) -}) - -test('boolean', async t => { - t.is((await contract.boolean({ boolean: true })).result, true) -}) - -test('not', async t => { - t.is((await contract.not({ boolean: true })).result, false) -}) - -test('i128', async t => { - t.is((await contract.i128({ i128: -1n })).result, -1n) -}) - -test('u128', async t => { - t.is((await contract.u128({ u128: 1n })).result, 1n) -}) - -test('multi_args', async t => { - t.is((await contract.multi_args({ a: 1, b: true })).result, 1) - t.is((await contract.multi_args({ a: 1, b: false })).result, 0) -}) - -test('map', async t => { - const map = new Map() - map.set(1, true) - map.set(2, false) + const test = { a: 0, b: true, c: "hello" }; + t.deepEqual((await contract.strukt({ strukt: test })).result, test); +}); + +test("simple first", async (t) => { + const arg = { tag: "First", values: undefined } as const; + const ret = { tag: "First" }; + t.deepEqual((await contract.simple({ simple: arg })).result, ret); +}); + +test("simple second", async (t) => { + const arg = { tag: "Second", values: undefined } as const; + const ret = { tag: "Second" }; + t.deepEqual((await contract.simple({ simple: arg })).result, ret); +}); + +test("simple third", async (t) => { + const arg = { tag: "Third", values: undefined } as const; + const ret = { tag: "Third" }; + t.deepEqual((await contract.simple({ simple: arg })).result, ret); +}); + +test("complex with struct", async (t) => { + const arg = { + tag: "Struct", + values: [{ a: 0, b: true, c: "hello" }], + } as const; + const ret = { tag: "Struct", values: [{ a: 0, b: true, c: "hello" }] }; + t.deepEqual((await contract.complex({ complex: arg })).result, ret); +}); + +test("complex with tuple", async (t) => { + const arg = { + tag: "Tuple", + values: [ + [ + { a: 0, b: true, c: "hello" }, + { tag: "First", values: undefined }, + ], + ], + } as const; + const ret = { + tag: "Tuple", + values: [[{ a: 0, b: true, c: "hello" }, { tag: "First" }]], + }; + t.deepEqual((await contract.complex({ complex: arg })).result, ret); +}); + +test("complex with enum", async (t) => { + const arg = { + tag: "Enum", + values: [{ tag: "First", values: undefined }], + } as const; + const ret = { tag: "Enum", values: [{ tag: "First" }] }; + t.deepEqual((await contract.complex({ complex: arg })).result, ret); +}); + +test("complex with asset", async (t) => { + const arg = { tag: "Asset", values: [publicKey, 1n] } as const; + const ret = { tag: "Asset", values: [publicKey, 1n] }; + t.deepEqual((await contract.complex({ complex: arg })).result, ret); +}); + +test("complex with void", async (t) => { + const arg = { tag: "Void", values: undefined } as const; + const ret = { tag: "Void" }; + t.deepEqual((await contract.complex({ complex: arg })).result, ret); +}); + +test("addresse", async (t) => { + t.deepEqual( + (await contract.addresse({ addresse: publicKey })).result, + publicKey, + ); +}); + +test("bytes", async (t) => { + const bytes = Buffer.from("hello"); + t.deepEqual((await contract.bytes({ bytes })).result, bytes); +}); + +test("bytes_n", async (t) => { + const bytes_n = Buffer.from("123456789"); // what's the correct way to construct bytes_n? + t.deepEqual((await contract.bytes_n({ bytes_n })).result, bytes_n); +}); + +test("card", async (t) => { + const card = 11; + t.is((await contract.card({ card })).result, card); +}); + +test("boolean", async (t) => { + t.is((await contract.boolean({ boolean: true })).result, true); +}); + +test("not", async (t) => { + t.is((await contract.not({ boolean: true })).result, false); +}); + +test("i128", async (t) => { + t.is((await contract.i128({ i128: -1n })).result, -1n); +}); + +test("u128", async (t) => { + t.is((await contract.u128({ u128: 1n })).result, 1n); +}); + +test("multi_args", async (t) => { + t.is((await contract.multi_args({ a: 1, b: true })).result, 1); + t.is((await contract.multi_args({ a: 1, b: false })).result, 0); +}); + +test("map", async (t) => { + const map = new Map(); + map.set(1, true); + map.set(2, false); // map.set(3, 'hahaha') // should throw an error - const ret = Array.from(map.entries()) - t.deepEqual((await contract.map({ map })).result, ret) -}) + const ret = Array.from(map.entries()); + t.deepEqual((await contract.map({ map })).result, ret); +}); -test('vec', async t => { - const vec = [1, 2, 3] - t.deepEqual((await contract.vec({ vec })).result, vec) -}) +test("vec", async (t) => { + const vec = [1, 2, 3]; + t.deepEqual((await contract.vec({ vec })).result, vec); +}); -test('tuple', async t => { - const tuple = ['hello', 1] as const - t.deepEqual((await contract.tuple({ tuple })).result, tuple) -}) +test("tuple", async (t) => { + const tuple = ["hello", 1] as const; + t.deepEqual((await contract.tuple({ tuple })).result, tuple); +}); -test('option', async t => { - t.deepEqual((await contract.option({ option: 1 })).result, 1) +test("option", async (t) => { + t.deepEqual((await contract.option({ option: 1 })).result, 1); - t.deepEqual((await contract.option({ option: undefined })).result, null) + t.deepEqual((await contract.option({ option: undefined })).result, null); // this is the behavior we probably want, but fails // t.deepEqual(await contract.option(), undefined) // typing and implementation require the object // t.deepEqual((await contract.option({})).result, undefined) // typing requires argument; implementation would be fine with this // t.deepEqual((await contract.option({ option: undefined })).result, undefined) -}) +}); + +test("u256", async (t) => { + t.is((await contract.u256({ u256: 1n })).result, 1n); +}); -test('u256', async t => { - t.is((await contract.u256({ u256: 1n })).result, 1n) -}) +test("i256", async (t) => { + t.is((await contract.i256({ i256: -1n })).result, -1n); +}); -test('i256', async t => { - t.is((await contract.i256({ i256: -1n })).result, -1n) -}) +test("string", async (t) => { + t.is((await contract.string({ string: "hello" })).result, "hello"); +}); -test('string', async t => { - t.is((await contract.string({ string: 'hello' })).result, 'hello') -}) +test("tuple_strukt", async (t) => { + const arg = [ + { a: 0, b: true, c: "hello" }, + { tag: "First", values: undefined }, + ] as const; + const res = [{ a: 0, b: true, c: "hello" }, { tag: "First" }]; + t.deepEqual((await contract.tuple_strukt({ tuple_strukt: arg })).result, res); +}); -test('tuple_strukt', async t => { - const arg = [{ a: 0, b: true, c: 'hello' }, { tag: 'First', values: undefined }] as const - const res = [{ a: 0, b: true, c: 'hello' }, { tag: 'First' }] - t.deepEqual((await contract.tuple_strukt({ tuple_strukt: arg })).result, res) -}) +test("timepoint", async (t) => { + t.is((await contract.timepoint({ timepoint: 1n })).result, 1n); +}); + +test("duration", async (t) => { + t.is((await contract.duration({ duration: 1n })).result, 1n); +}); diff --git a/cmd/crates/soroban-test/src/lib.rs b/cmd/crates/soroban-test/src/lib.rs index da46b86b8f..b1381be806 100644 --- a/cmd/crates/soroban-test/src/lib.rs +++ b/cmd/crates/soroban-test/src/lib.rs @@ -392,6 +392,7 @@ impl AssertExt for Assert { .to_owned() } } + pub trait CommandExt { fn json_arg(&mut self, j: A) -> &mut Self where diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/src/lib.rs b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/src/lib.rs index d1477018c3..4ca43b0146 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/src/lib.rs +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/src/lib.rs @@ -1,7 +1,7 @@ #![no_std] use soroban_sdk::{ contract, contracterror, contractimpl, contracttype, symbol_short, vec, Address, Bytes, BytesN, - Env, Map, String, Symbol, Val, Vec, I256, U256, + Duration, Env, Map, String, Symbol, Timepoint, Val, Vec, I256, U256, }; #[contract] @@ -197,11 +197,11 @@ impl Contract { tuple_strukt } - // pub fn timepoint(_env: Env, timepoint: TimePoint) -> TimePoint { - // timepoint - // } + pub fn timepoint(_env: Env, timepoint: Timepoint) -> Timepoint { + timepoint + } - // pub fn duration(_env: Env, duration: Duration) -> Duration { - // duration - // } + pub fn duration(_env: Env, duration: Duration) -> Duration { + duration + } } diff --git a/cmd/crates/soroban-test/tests/it/arg_parsing.rs b/cmd/crates/soroban-test/tests/it/arg_parsing.rs deleted file mode 100644 index 12baf26092..0000000000 --- a/cmd/crates/soroban-test/tests/it/arg_parsing.rs +++ /dev/null @@ -1,240 +0,0 @@ -use crate::util::CUSTOM_TYPES; -use serde_json::json; -use soroban_cli::xdr::{ - Duration, Int128Parts, Int256Parts, ScBytes, ScSpecTypeBytesN, ScSpecTypeDef, ScSpecTypeOption, - ScSpecTypeUdt, ScVal, TimePoint, UInt128Parts, UInt256Parts, -}; -use soroban_spec_tools::{from_string_primitive, Spec}; - -#[test] -fn parse_bool() { - let parsed = from_string_primitive("true", &ScSpecTypeDef::Bool).unwrap(); - assert!(parsed == ScVal::Bool(true)); -} - -#[test] -fn parse_null() { - let parsed = from_string_primitive( - "null", - &ScSpecTypeDef::Option(Box::new(ScSpecTypeOption { - value_type: Box::new(ScSpecTypeDef::Bool), - })), - ) - .unwrap(); - assert!(parsed == ScVal::Void); -} - -#[test] -fn parse_u32() { - let u32_ = 42u32; - let res = &format!("{u32_}"); - let parsed = from_string_primitive(res, &ScSpecTypeDef::U32).unwrap(); - assert!(parsed == ScVal::U32(u32_)); -} - -#[test] -fn parse_i32() { - let i32_ = -42_i32; - let res = &format!("{i32_}"); - let parsed = from_string_primitive(res, &ScSpecTypeDef::I32).unwrap(); - assert!(parsed == ScVal::I32(i32_)); -} - -#[test] -fn parse_u64() { - let b = 42_000_000_000u64; - let res = &format!("{b}"); - let parsed = from_string_primitive(res, &ScSpecTypeDef::U64).unwrap(); - assert!(parsed == ScVal::U64(b)); -} - -#[test] -#[allow(clippy::cast_possible_truncation)] -fn parse_u128() { - let b = 340_000_000_000_000_000_000_000_000_000_000_000_000u128; - let res = &format!("{b}"); - let lo = b as u64; - let hi = (b >> 64) as u64; - let parsed = from_string_primitive(res, &ScSpecTypeDef::U128).unwrap(); - assert!(parsed == ScVal::U128(UInt128Parts { hi, lo })); -} - -#[test] -#[allow(clippy::cast_possible_truncation)] -fn parse_u256() { - let b = 340_000_000_000_000_000_000_000_000_000_000_000_000u128; - let res = &format!("{b}"); - let lo_lo = b as u64; - let lo_hi = (b >> 64) as u64; - let hi_lo = 0u64; - let hi_hi = 0u64; - let parsed = from_string_primitive(res, &ScSpecTypeDef::U256).unwrap(); - assert!( - parsed - == ScVal::U256(UInt256Parts { - lo_lo, - lo_hi, - hi_lo, - hi_hi - }) - ); -} - -#[test] -#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] -fn parse_i128() { - let b = -170_000_000_000_000_000_000_000_000_000_000_000_000i128; - let res = &format!("{b}"); - let lo = b as u64; - let hi = (b >> 64) as i64; - let parsed = from_string_primitive(res, &ScSpecTypeDef::I128).unwrap(); - assert!(parsed == ScVal::I128(Int128Parts { hi, lo })); -} - -#[test] -#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] -fn parse_i256() { - let b = -170_000_000_000_000_000_000_000_000_000_000_000_000i128; - let res = &format!("{b}"); - let lo_lo = b as u64; - let lo_hi = (b >> 64) as u64; - // b is negative i128, so hi parts are all ones - let hi_lo = u64::MAX; - let hi_hi = -1i64; - let parsed = from_string_primitive(res, &ScSpecTypeDef::I256).unwrap(); - assert!( - parsed - == ScVal::I256(Int256Parts { - lo_lo, - lo_hi, - hi_lo, - hi_hi - }) - ); -} - -#[test] -fn parse_bytes() { - let b = from_string_primitive(r"beefface", &ScSpecTypeDef::Bytes).unwrap(); - assert_eq!( - b, - ScVal::Bytes(ScBytes(vec![0xbe, 0xef, 0xfa, 0xce].try_into().unwrap())) - ); -} - -#[test] -fn parse_bytes_when_hex_is_all_numbers() { - let b = from_string_primitive(r"4554", &ScSpecTypeDef::Bytes).unwrap(); - assert_eq!( - b, - ScVal::Bytes(ScBytes(vec![0x45, 0x54].try_into().unwrap())) - ); -} - -#[test] -fn parse_bytesn() { - let b = from_string_primitive( - r"beefface", - &ScSpecTypeDef::BytesN(ScSpecTypeBytesN { n: 4 }), - ) - .unwrap(); - assert_eq!( - b, - ScVal::Bytes(ScBytes(vec![0xbe, 0xef, 0xfa, 0xce].try_into().unwrap())) - ); -} - -#[test] -fn parse_bytesn_when_hex_is_all_numbers() { - let b = - from_string_primitive(r"4554", &ScSpecTypeDef::BytesN(ScSpecTypeBytesN { n: 2 })).unwrap(); - assert_eq!( - b, - ScVal::Bytes(ScBytes(vec![0x45, 0x54].try_into().unwrap())) - ); -} - -#[test] -fn parse_timepoint() { - let b = 1_760_501_234u64; - let res = &format!("{b}"); - let parsed = from_string_primitive(res, &ScSpecTypeDef::Timepoint).unwrap(); - assert!(parsed == ScVal::Timepoint(TimePoint::from(b))); -} - -#[test] -fn parse_duration() { - let b = 1_234_567u64; - let res = &format!("{b}"); - let parsed = from_string_primitive(res, &ScSpecTypeDef::Duration).unwrap(); - assert!(parsed == ScVal::Duration(Duration::from(b))); -} - -#[test] -fn parse_symbol() { - let parsed = from_string_primitive(r#""hello""#, &ScSpecTypeDef::Symbol).unwrap(); - assert!(parsed == ScVal::Symbol("hello".try_into().unwrap())); -} - -#[test] -fn parse_symbol_with_no_quotation_marks() { - let parsed = from_string_primitive("hello", &ScSpecTypeDef::Symbol).unwrap(); - assert!(parsed == ScVal::Symbol("hello".try_into().unwrap())); -} - -#[test] -fn parse_optional_symbol_with_no_quotation_marks() { - let parsed = from_string_primitive( - "hello", - &ScSpecTypeDef::Option(Box::new(ScSpecTypeOption { - value_type: Box::new(ScSpecTypeDef::Symbol), - })), - ) - .unwrap(); - assert!(parsed == ScVal::Symbol("hello".try_into().unwrap())); -} - -#[test] -fn parse_optional_bool_with_no_quotation_marks() { - let parsed = from_string_primitive( - "true", - &ScSpecTypeDef::Option(Box::new(ScSpecTypeOption { - value_type: Box::new(ScSpecTypeDef::Bool), - })), - ) - .unwrap(); - assert!(parsed == ScVal::Bool(true)); -} - -#[test] -fn parse_obj() { - let type_ = &ScSpecTypeDef::Udt(ScSpecTypeUdt { - name: "Test".parse().unwrap(), - }); - let entries = get_spec(); - let val = &json!({"a": 42, "b": false, "c": "world"}); - println!("{:#?}", entries.from_json(val, type_)); -} - -#[test] -fn parse_enum() { - let entries = get_spec(); - let func = entries.find_function("simple").unwrap(); - println!("{func:#?}"); - let type_ = &func.inputs.as_slice()[0].type_; - println!("{:#?}", entries.from_json(&json!("First"), type_)); -} - -#[test] -fn parse_enum_const() { - let entries = get_spec(); - let func = entries.find_function("card").unwrap(); - println!("{func:#?}"); - let type_ = &func.inputs.as_slice()[0].type_; - println!("{:#?}", entries.from_json(&json!(11), type_)); -} - -fn get_spec() -> Spec { - let res = soroban_spec::read::from_wasm(&CUSTOM_TYPES.bytes()).unwrap(); - Spec(Some(res)) -} diff --git a/cmd/crates/soroban-test/tests/it/init.rs b/cmd/crates/soroban-test/tests/it/init.rs index 4b5fd907eb..c5285b1216 100644 --- a/cmd/crates/soroban-test/tests/it/init.rs +++ b/cmd/crates/soroban-test/tests/it/init.rs @@ -3,7 +3,6 @@ use predicates::prelude::predicate; use soroban_test::TestEnv; #[test] -#[ignore = "We need to ignore these until soroban-sdk is 23.0.0 stable"] fn init() { let sandbox = TestEnv::default(); let cli_version = soroban_cli::commands::version::pkg(); @@ -21,11 +20,11 @@ fn init() { .assert(predicate::function(|c: &str| { let table = toml::from_str::(c).unwrap(); let sdk_version = table["workspace"]["dependencies"]["soroban-sdk"].as_str(); - println!("Check expected version {major}.0.0 matches template's {sdk_version:?}"); + println!("Check expected version {major} matches template's {sdk_version:?}"); if is_rc { - sdk_version.and_then(|x| x.split('-').next()) == Some(&format!("{major}.0.0")) + sdk_version.and_then(|x| x.split('-').next()) == Some(major) } else { - sdk_version == Some(&format!("{major}.0.0")) + sdk_version == Some(major) } })); } diff --git a/cmd/crates/soroban-test/tests/it/integration.rs b/cmd/crates/soroban-test/tests/it/integration.rs index f0e49793c8..aeb9b0c974 100644 --- a/cmd/crates/soroban-test/tests/it/integration.rs +++ b/cmd/crates/soroban-test/tests/it/integration.rs @@ -13,4 +13,3 @@ mod secure_store; mod snapshot; mod tx; mod util; -mod wrap; diff --git a/cmd/crates/soroban-test/tests/it/integration/custom_types.rs b/cmd/crates/soroban-test/tests/it/integration/custom_types.rs index 6ccec4fbb2..df0549249d 100644 --- a/cmd/crates/soroban-test/tests/it/integration/custom_types.rs +++ b/cmd/crates/soroban-test/tests/it/integration/custom_types.rs @@ -44,6 +44,9 @@ async fn parse() { contract_address(sandbox, id).await; contract_address_with_alias(sandbox, id).await; bytes(sandbox, id).await; + bytes_n(sandbox, id).await; + timepoint(sandbox, id).await; + duration(sandbox, id).await; const_enum(sandbox, id).await; number_arg_return_ok(sandbox, id); void(sandbox, id); @@ -275,6 +278,39 @@ async fn bytes(sandbox: &TestEnv, id: &str) { invoke_with_roundtrip(sandbox, id, "bytes", json!("7374656c6c6172")).await; } +async fn bytes_n(sandbox: &TestEnv, id: &str) { + let bytes = "beeffacebeefface00"; + invoke_custom(sandbox, id, "bytes_n") + .arg("--bytes_n") + .arg(bytes) + .assert() + .success() + .stdout(format!( + r#""{bytes}" +"#, + )); +} + +async fn timepoint(sandbox: &TestEnv, id: &str) { + let tp = "1633046400"; + invoke_custom(sandbox, id, "timepoint") + .arg("--timepoint") + .arg(tp) + .assert() + .success() + .stdout(format!("{tp}\n")); +} + +async fn duration(sandbox: &TestEnv, id: &str) { + let dur = "3600"; + invoke_custom(sandbox, id, "duration") + .arg("--duration") + .arg(dur) + .assert() + .success() + .stdout(format!("{dur}\n")); +} + async fn const_enum(sandbox: &TestEnv, id: &str) { invoke_with_roundtrip(sandbox, id, "card", "11").await; } diff --git a/cmd/crates/soroban-test/tests/it/integration/hello_world.rs b/cmd/crates/soroban-test/tests/it/integration/hello_world.rs index 5df5d0dfdb..b0e667a3f0 100644 --- a/cmd/crates/soroban-test/tests/it/integration/hello_world.rs +++ b/cmd/crates/soroban-test/tests/it/integration/hello_world.rs @@ -7,7 +7,7 @@ use soroban_cli::{ }; use soroban_test::{AssertExt, TestEnv, LOCAL_NETWORK_PASSPHRASE}; -use super::util::{deploy_hello, extend, HELLO_WORLD}; +use super::util::{deploy_hello, extend}; use crate::integration::util::extend_contract; #[allow(clippy::too_many_lines)] @@ -317,26 +317,6 @@ async fn contract_data_read() { .stdout(predicates::str::starts_with("COUNTER,2")); } -#[tokio::test] -#[ignore] -async fn half_max_instructions() { - let sandbox = TestEnv::new(); - let wasm = HELLO_WORLD; - sandbox - .new_assert_cmd("contract") - .arg("deploy") - .arg("--fee") - .arg("1000000") - .arg("--instructions") - .arg((u32::MAX / 2).to_string()) - .arg("--wasm") - .arg(wasm.path()) - .arg("--ignore-checks") - .assert() - .stderr("") - .stdout_as_str(); -} - async fn invoke_with_seed(sandbox: &TestEnv, id: &str, seed_phrase: &str) { invoke_with_source(sandbox, seed_phrase, id).await; } diff --git a/cmd/crates/soroban-test/tests/it/integration/init.rs b/cmd/crates/soroban-test/tests/it/integration/init.rs index 83d1ad4cfa..a071032987 100644 --- a/cmd/crates/soroban-test/tests/it/integration/init.rs +++ b/cmd/crates/soroban-test/tests/it/integration/init.rs @@ -1,10 +1,9 @@ use soroban_test::{AssertExt, TestEnv}; #[test] -#[ignore] fn init_and_deploy() { let name = "hello_world"; - let sandbox = TestEnv::default(); + let sandbox = &TestEnv::new(); sandbox .new_assert_cmd("contract") diff --git a/cmd/crates/soroban-test/tests/it/integration/ledger/entry.rs b/cmd/crates/soroban-test/tests/it/integration/ledger/entry.rs index 7e5589be89..cc9a85e9f3 100644 --- a/cmd/crates/soroban-test/tests/it/integration/ledger/entry.rs +++ b/cmd/crates/soroban-test/tests/it/integration/ledger/entry.rs @@ -221,8 +221,7 @@ async fn ledger_entry_contract_data() { .assert() .success() .stdout_as_str(); - let parsed_key_output: FullLedgerEntries = - serde_json::from_str(&key_output).expect("Failed to parse JSON"); + let parsed_key_output: FullLedgerEntries = serde_json::from_str(&key_output).unwrap(); assert!(!parsed_key_output.entries.is_empty()); // get entry by key xdr @@ -240,9 +239,7 @@ async fn ledger_entry_contract_data() { .assert() .success() .stdout_as_str(); - - let parsed_key_xdr_output: FullLedgerEntries = - serde_json::from_str(&key_xdr_output).expect("Failed to parse JSON"); + let parsed_key_xdr_output: FullLedgerEntries = serde_json::from_str(&key_xdr_output).unwrap(); assert!(!parsed_key_xdr_output.entries.is_empty()); let expected_contract_data_key = expected_contract_ledger_key(&contract_id, storage_key).await; @@ -264,6 +261,33 @@ async fn ledger_entry_contract_data() { // the output should be the same regardless of key format assert_eq!(parsed_key_output.entries, parsed_key_xdr_output.entries); + + // get instance data entry + let instance_output = sandbox + .new_assert_cmd("ledger") + .arg("entry") + .arg("fetch") + .arg("contract-data") + .arg("--contract") + .arg(&contract_id) + .arg("--network") + .arg("testnet") + .arg("--instance") + .assert() + .success() + .stdout_as_str(); + let parsed_instance_output: FullLedgerEntries = serde_json::from_str(&instance_output).unwrap(); + let expected_instance_key = LedgerKey::ContractData(LedgerKeyContractData { + contract: ScAddress::Contract(Hash(Contract::from_string(&contract_id).unwrap().0).into()), + key: ScVal::LedgerKeyContractInstance, + durability: ContractDataDurability::Persistent, + }); + assert!(!parsed_instance_output.entries.is_empty()); + assert_eq!(parsed_instance_output.entries[0].key, expected_instance_key); + assert!(matches!( + parsed_instance_output.entries[0].val, + LedgerEntryData::ContractData { .. } + )); } // top level test diff --git a/cmd/crates/soroban-test/tests/it/integration/secure_store.rs b/cmd/crates/soroban-test/tests/it/integration/secure_store.rs index 7a47033bf1..5bd6a76119 100644 --- a/cmd/crates/soroban-test/tests/it/integration/secure_store.rs +++ b/cmd/crates/soroban-test/tests/it/integration/secure_store.rs @@ -2,36 +2,49 @@ use predicates::prelude::predicate; use soroban_cli::tx::ONE_XLM; use soroban_test::{AssertExt, TestEnv}; -fn secure_store_key(sandbox: &TestEnv, name: &str) -> String { +// All secure store tests are run within one test to avoid issues with multiple +// tests trying to access the dbus at the same time which can lead to intermittent failures. +#[tokio::test] +async fn secure_store_key_management() { + let sandbox = &TestEnv::new(); + + let secure_key_name = "secure-store-test"; + + // generate a new secret key in secure store sandbox .new_assert_cmd("keys") - .args(["generate", "--fund", "--secure-store", name]) + .args(["generate", secure_key_name, "--secure-store", "--fund"]) .assert() - .success() - .stdout_as_str(); + .success(); + // validate that we cannot get the secret key back sandbox .new_assert_cmd("keys") - .args(["address", name]) + .arg("secret") + .arg(secure_key_name) .assert() - .success() - .stdout_as_str() -} + .stderr(predicate::str::contains("does not reveal secret key")) + .failure(); -// test that we can create a create-account tx and sign it with a secure-store key -#[tokio::test] -async fn create_account() { - let sandbox = &TestEnv::new(); - let secure_store_address = secure_store_key(sandbox, "secure-store"); + // validate that we can get the public key + let secure_store_address = sandbox + .new_assert_cmd("keys") + .args(["address", secure_key_name]) + .assert() + .success() + .stdout_as_str(); + assert!(secure_store_address.starts_with('G')); + // use the secure store key to fund a new account + let new_key_name = "new"; sandbox .new_assert_cmd("keys") - .args(["generate", "new"]) + .args(["generate", new_key_name]) .assert() .success(); let new_address = sandbox .new_assert_cmd("keys") - .args(["address", "new"]) + .args(["address", new_key_name]) .assert() .success() .stdout_as_str(); @@ -50,7 +63,7 @@ async fn create_account() { "--starting-balance", starting_balance.to_string().as_str(), "--source", - "secure-store", + secure_key_name, ]) .assert() .success() @@ -62,37 +75,3 @@ async fn create_account() { let new_account = client.get_account(&new_address).await.unwrap(); assert_eq!(new_account.balance, starting_balance); } - -#[tokio::test] -async fn get_secret_key() { - let sandbox = &TestEnv::new(); - sandbox - .new_assert_cmd("keys") - .args(["generate", "secret-key-test", "--secure-store", "--fund"]) - .assert() - .success(); - sandbox - .new_assert_cmd("keys") - .arg("secret") - .arg("secret-key-test") - .assert() - .stderr(predicate::str::contains("does not reveal secret key")) - .failure(); -} - -#[tokio::test] -async fn public_key_with_secure_store() { - let sandbox = &TestEnv::new(); - sandbox - .new_assert_cmd("keys") - .args(["generate", "public-key-test", "--secure-store", "--fund"]) - .assert() - .success(); - sandbox - .new_assert_cmd("keys") - .arg("public-key") - .arg("public-key-test") - .assert() - .stdout(predicate::str::contains("G")) - .success(); -} diff --git a/cmd/crates/soroban-test/tests/it/integration/wrap.rs b/cmd/crates/soroban-test/tests/it/integration/wrap.rs deleted file mode 100644 index 961cd6b4ad..0000000000 --- a/cmd/crates/soroban-test/tests/it/integration/wrap.rs +++ /dev/null @@ -1,103 +0,0 @@ -use soroban_cli::{config::locator, tx::builder, utils::contract_id_hash_from_asset}; -use soroban_test::{AssertExt, TestEnv, LOCAL_NETWORK_PASSPHRASE}; - -#[tokio::test] -#[ignore] -async fn burn() { - let sandbox = &TestEnv::new(); - let network_passphrase = LOCAL_NETWORK_PASSPHRASE.to_string(); - let address = sandbox - .new_assert_cmd("keys") - .arg("address") - .arg("test") - .assert() - .stdout_as_str(); - let asset = "native"; - sandbox - .new_assert_cmd("contract") - .arg("asset") - .arg("deploy") - .arg("--source=test") - .arg("--asset") - .arg(asset) - .assert() - .success(); - let asset = asset - .parse::() - .unwrap() - .resolve(&locator::Args::default()) - .unwrap(); - let hash = contract_id_hash_from_asset(&asset, &network_passphrase); - let id = stellar_strkey::Contract(hash.0).to_string(); - sandbox - .new_assert_cmd("contract") - .args([ - "invoke", - "--id", - &id, - "--", - "balance", - "--id", - &address.to_string(), - ]) - .assert() - .stdout("\"9223372036854775807\"\n"); - sandbox - .new_assert_cmd("contract") - .arg("invoke") - .args([ - "--id", - &id, - "--", - "authorized", - "--id", - &address.to_string(), - ]) - .assert() - .stdout("true\n"); - sandbox - .new_assert_cmd("contract") - .args([ - "invoke", - "--id", - &id, - "--", - "balance", - "--id", - &address.to_string(), - ]) - .assert() - .stdout("\"9223372036854775807\"\n"); - sandbox - .new_assert_cmd("contract") - .arg("invoke") - .env("RUST_LOGS", "trace") - .args([ - "--source=test", - "--id", - &id, - "--", - "burn", - "--from", - "test", - "--amount=100", - ]) - .assert() - .stdout("") - .stderr(""); - - println!("hi"); - sandbox - .new_assert_cmd("contract") - .args([ - "invoke", - "--id", - &id, - "--", - "balance", - "--id", - &address.to_string(), - ]) - .assert() - .stdout("\"9223372036854775707\"\n"); -} diff --git a/cmd/crates/soroban-test/tests/it/main.rs b/cmd/crates/soroban-test/tests/it/main.rs index a16d2311b5..aff760b4c1 100644 --- a/cmd/crates/soroban-test/tests/it/main.rs +++ b/cmd/crates/soroban-test/tests/it/main.rs @@ -1,4 +1,3 @@ -mod arg_parsing; mod build; mod config; #[cfg(feature = "emulator-tests")]