diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51a598a89..2d4e8aa08 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,24 +26,22 @@ jobs: cargo --version - uses: taiki-e/install-action@cargo-hack + - uses: taiki-e/install-action@cargo-nextest - name: feature compatibility - run: cargo hack check --feature-powerset --no-dev-deps + run: make check-features - name: rustfmt run: cargo fmt -- --check - name: clippy - run: cargo clippy --all-features --all-targets - - - name: rustdoc - env: - RUSTDOCFLAGS: "--cfg=doc_cfg -Zunstable-options --generate-link-to-definition" - RUSTC_BOOTSTRAP: 1 - run: cargo doc --all-features --no-deps + run: make clippy - name: Run tests - run: cargo test --all-features + run: make test + + - name: rustdoc + run: make doc wasm: runs-on: ubuntu-latest @@ -63,6 +61,4 @@ jobs: run: sudo apt-get install -y clang - name: Run tests in wasm - env: - CC: clang - run: wasm-pack test --node --all-features + run: make wasm diff --git a/.github/workflows/rustdoc.yml b/.github/workflows/rustdoc.yml index cfd6f58f7..d991a9446 100644 --- a/.github/workflows/rustdoc.yml +++ b/.github/workflows/rustdoc.yml @@ -19,10 +19,7 @@ jobs: uses: actions/checkout@v4 - name: rustdoc - env: - RUSTDOCFLAGS: "--cfg=doc_cfg -Zunstable-options --generate-link-to-definition" - RUSTC_BOOTSTRAP: 1 - run: cargo doc --all-features --no-deps + run: make doc - name: Deploy Docs uses: peaceiris/actions-gh-pages@v3 diff --git a/Cargo.toml b/Cargo.toml index 686ca9ade..a848b85b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,71 +1,3 @@ -[package] -name = "sui-sdk" -version = "0.0.0" -authors = ["Brandon Williams "] -license = "Apache-2.0" -edition = "2021" -publish = false -readme = "README.md" -description = "Sdk for the Sui Blockchain" - -[package.metadata.docs.rs] -# To build locally: -# RUSTDOCFLAGS="--cfg=doc_cfg -Zunstable-options --generate-link-to-definition" RUSTC_BOOTSTRAP=1 cargo doc --all-features --no-deps --open -all-features = true -rustdoc-args = [ - # Enable doc_cfg showing the required features. - "--cfg=doc_cfg", - - # Generate links to definition in rustdoc source code pages - # https://github.com/rust-lang/rust/pull/84176 - "-Zunstable-options", "--generate-link-to-definition" -] - -[features] -default = [] -serde = ["dep:serde", "dep:serde_derive", "dep:serde_with", "dep:bcs", "dep:serde_json", "roaring/std"] -schemars = ["serde", "dep:schemars", "dep:serde_json"] -rand = ["dep:rand_core"] -hash = ["dep:blake2"] - -[dependencies] -base64ct = { version = "1.6.0", features = ["alloc"] } -bs58 = "0.5.1" -hex = "0.4.3" -roaring = { version = "0.10.6", default-features = false } -bnum = "0.11.0" -winnow = "0.6.18" - -# Serialization and Deserialization support -serde = { version = "1.0.190", optional = true } -serde_derive = { version = "1.0.190", optional = true } -serde_with = { version = "3.9", default-features = false, features = ["alloc"], optional = true } -bcs = { version = "0.1.6", optional = true } -serde_json = { version = "1.0.114", optional = true } - -# JsonSchema definitions for types, useful for generating an OpenAPI Specificaiton. -schemars = { version = "0.8.21", optional = true } - -# RNG support -rand_core = { version = "0.6.4", optional = true } - -# Hash support -blake2 = { version = "0.10.6", optional = true } - -[dev-dependencies] -bcs = "0.1.6" -serde_json = "1.0.114" -num-bigint = "0.4.4" -jsonschema = { version = "0.18", default-features = false } -paste = "1.0.15" - -# proptest support in tests -# -# Pin to this specific commit in order to work around an issue where proptest doesn't build properly in wasm environments -# see https://github.com/proptest-rs/proptest/pull/270 for more info -proptest = { git = "https://github.com/bmwill/proptest.git", rev = "bc36db126183bce18c8bc595f0c0cfeac48b870c", default-features = false, features = ["std"] } -test-strategy = "0.3.1" - -[target.wasm32-unknown-unknown.dev-dependencies] -wasm-bindgen-test = "0.3" -getrandom = { version = "0.2", features = ["js"] } +[workspace] +resolver = "2" +members = ["crates/*"] diff --git a/Makefile b/Makefile index ecf203358..9d1d5cc0b 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ # Set the default target of this Makefile .PHONY: all -all:: ci-full +all:: ci -.PHONY: check -check: - cargo hack check --feature-powerset --no-dev-deps +.PHONY: check-features +check-features: + $(MAKE) -C crates/sui-sdk check-features -.PHONY: fmt-check -fmt-check: +.PHONY: check-fmt +check-fmt: cargo fmt -- --check .PHONY: clippy @@ -16,11 +16,12 @@ clippy: .PHONY: test test: - cargo test --all-features + cargo nextest run --all-features + cargo test --doc .PHONY: wasm wasm: - CC=clang wasm-pack test --node --all-features + $(MAKE) -C crates/sui-sdk wasm .PHONY: doc doc: @@ -31,7 +32,7 @@ doc-open: RUSTDOCFLAGS="--cfg=doc_cfg -Zunstable-options --generate-link-to-definition" RUSTC_BOOTSTRAP=1 cargo doc --all-features --no-deps --open .PHONY: ci -ci: check fmt-check clippy test wasm +ci: check-features check-fmt test wasm .PHONY: ci-full ci-full: ci doc diff --git a/crates/sui-sdk/Cargo.toml b/crates/sui-sdk/Cargo.toml new file mode 100644 index 000000000..686ca9ade --- /dev/null +++ b/crates/sui-sdk/Cargo.toml @@ -0,0 +1,71 @@ +[package] +name = "sui-sdk" +version = "0.0.0" +authors = ["Brandon Williams "] +license = "Apache-2.0" +edition = "2021" +publish = false +readme = "README.md" +description = "Sdk for the Sui Blockchain" + +[package.metadata.docs.rs] +# To build locally: +# RUSTDOCFLAGS="--cfg=doc_cfg -Zunstable-options --generate-link-to-definition" RUSTC_BOOTSTRAP=1 cargo doc --all-features --no-deps --open +all-features = true +rustdoc-args = [ + # Enable doc_cfg showing the required features. + "--cfg=doc_cfg", + + # Generate links to definition in rustdoc source code pages + # https://github.com/rust-lang/rust/pull/84176 + "-Zunstable-options", "--generate-link-to-definition" +] + +[features] +default = [] +serde = ["dep:serde", "dep:serde_derive", "dep:serde_with", "dep:bcs", "dep:serde_json", "roaring/std"] +schemars = ["serde", "dep:schemars", "dep:serde_json"] +rand = ["dep:rand_core"] +hash = ["dep:blake2"] + +[dependencies] +base64ct = { version = "1.6.0", features = ["alloc"] } +bs58 = "0.5.1" +hex = "0.4.3" +roaring = { version = "0.10.6", default-features = false } +bnum = "0.11.0" +winnow = "0.6.18" + +# Serialization and Deserialization support +serde = { version = "1.0.190", optional = true } +serde_derive = { version = "1.0.190", optional = true } +serde_with = { version = "3.9", default-features = false, features = ["alloc"], optional = true } +bcs = { version = "0.1.6", optional = true } +serde_json = { version = "1.0.114", optional = true } + +# JsonSchema definitions for types, useful for generating an OpenAPI Specificaiton. +schemars = { version = "0.8.21", optional = true } + +# RNG support +rand_core = { version = "0.6.4", optional = true } + +# Hash support +blake2 = { version = "0.10.6", optional = true } + +[dev-dependencies] +bcs = "0.1.6" +serde_json = "1.0.114" +num-bigint = "0.4.4" +jsonschema = { version = "0.18", default-features = false } +paste = "1.0.15" + +# proptest support in tests +# +# Pin to this specific commit in order to work around an issue where proptest doesn't build properly in wasm environments +# see https://github.com/proptest-rs/proptest/pull/270 for more info +proptest = { git = "https://github.com/bmwill/proptest.git", rev = "bc36db126183bce18c8bc595f0c0cfeac48b870c", default-features = false, features = ["std"] } +test-strategy = "0.3.1" + +[target.wasm32-unknown-unknown.dev-dependencies] +wasm-bindgen-test = "0.3" +getrandom = { version = "0.2", features = ["js"] } diff --git a/crates/sui-sdk/Makefile b/crates/sui-sdk/Makefile new file mode 100644 index 000000000..acc0c2322 --- /dev/null +++ b/crates/sui-sdk/Makefile @@ -0,0 +1,23 @@ +# Set the default target of this Makefile +.PHONY: all +all:: check-features clippy test wasm + +.PHONY: check-features +check-features: + cargo hack check --feature-powerset --no-dev-deps + +.PHONY: clippy +clippy: + cargo clippy --all-features --all-targets + +.PHONY: test +test: + cargo nextest run --all-features + cargo test --doc + +.PHONY: wasm +wasm: + CC=clang wasm-pack test --node --all-features + +%: + $(MAKE) -C ../.. $@ diff --git a/src/hash.rs b/crates/sui-sdk/src/hash.rs similarity index 100% rename from src/hash.rs rename to crates/sui-sdk/src/hash.rs diff --git a/src/lib.rs b/crates/sui-sdk/src/lib.rs similarity index 100% rename from src/lib.rs rename to crates/sui-sdk/src/lib.rs diff --git a/src/types/address.rs b/crates/sui-sdk/src/types/address.rs similarity index 100% rename from src/types/address.rs rename to crates/sui-sdk/src/types/address.rs diff --git a/src/types/checkpoint.rs b/crates/sui-sdk/src/types/checkpoint.rs similarity index 100% rename from src/types/checkpoint.rs rename to crates/sui-sdk/src/types/checkpoint.rs diff --git a/src/types/crypto/bls12381.rs b/crates/sui-sdk/src/types/crypto/bls12381.rs similarity index 100% rename from src/types/crypto/bls12381.rs rename to crates/sui-sdk/src/types/crypto/bls12381.rs diff --git a/src/types/crypto/ed25519.rs b/crates/sui-sdk/src/types/crypto/ed25519.rs similarity index 100% rename from src/types/crypto/ed25519.rs rename to crates/sui-sdk/src/types/crypto/ed25519.rs diff --git a/src/types/crypto/mod.rs b/crates/sui-sdk/src/types/crypto/mod.rs similarity index 100% rename from src/types/crypto/mod.rs rename to crates/sui-sdk/src/types/crypto/mod.rs diff --git a/src/types/crypto/multisig.rs b/crates/sui-sdk/src/types/crypto/multisig.rs similarity index 100% rename from src/types/crypto/multisig.rs rename to crates/sui-sdk/src/types/crypto/multisig.rs diff --git a/src/types/crypto/passkey.rs b/crates/sui-sdk/src/types/crypto/passkey.rs similarity index 100% rename from src/types/crypto/passkey.rs rename to crates/sui-sdk/src/types/crypto/passkey.rs diff --git a/src/types/crypto/secp256k1.rs b/crates/sui-sdk/src/types/crypto/secp256k1.rs similarity index 100% rename from src/types/crypto/secp256k1.rs rename to crates/sui-sdk/src/types/crypto/secp256k1.rs diff --git a/src/types/crypto/secp256r1.rs b/crates/sui-sdk/src/types/crypto/secp256r1.rs similarity index 100% rename from src/types/crypto/secp256r1.rs rename to crates/sui-sdk/src/types/crypto/secp256r1.rs diff --git a/src/types/crypto/signature.rs b/crates/sui-sdk/src/types/crypto/signature.rs similarity index 100% rename from src/types/crypto/signature.rs rename to crates/sui-sdk/src/types/crypto/signature.rs diff --git a/src/types/crypto/validator.rs b/crates/sui-sdk/src/types/crypto/validator.rs similarity index 100% rename from src/types/crypto/validator.rs rename to crates/sui-sdk/src/types/crypto/validator.rs diff --git a/src/types/crypto/zklogin.rs b/crates/sui-sdk/src/types/crypto/zklogin.rs similarity index 100% rename from src/types/crypto/zklogin.rs rename to crates/sui-sdk/src/types/crypto/zklogin.rs diff --git a/src/types/digest.rs b/crates/sui-sdk/src/types/digest.rs similarity index 100% rename from src/types/digest.rs rename to crates/sui-sdk/src/types/digest.rs diff --git a/src/types/effects/fixtures/genesis-transaction-effects b/crates/sui-sdk/src/types/effects/fixtures/genesis-transaction-effects similarity index 100% rename from src/types/effects/fixtures/genesis-transaction-effects rename to crates/sui-sdk/src/types/effects/fixtures/genesis-transaction-effects diff --git a/src/types/effects/fixtures/pyth-wormhole-v2 b/crates/sui-sdk/src/types/effects/fixtures/pyth-wormhole-v2 similarity index 100% rename from src/types/effects/fixtures/pyth-wormhole-v2 rename to crates/sui-sdk/src/types/effects/fixtures/pyth-wormhole-v2 diff --git a/src/types/effects/mod.rs b/crates/sui-sdk/src/types/effects/mod.rs similarity index 100% rename from src/types/effects/mod.rs rename to crates/sui-sdk/src/types/effects/mod.rs diff --git a/src/types/effects/v1.rs b/crates/sui-sdk/src/types/effects/v1.rs similarity index 100% rename from src/types/effects/v1.rs rename to crates/sui-sdk/src/types/effects/v1.rs diff --git a/src/types/effects/v2.rs b/crates/sui-sdk/src/types/effects/v2.rs similarity index 100% rename from src/types/effects/v2.rs rename to crates/sui-sdk/src/types/effects/v2.rs diff --git a/src/types/events.rs b/crates/sui-sdk/src/types/events.rs similarity index 100% rename from src/types/events.rs rename to crates/sui-sdk/src/types/events.rs diff --git a/src/types/execution_status.rs b/crates/sui-sdk/src/types/execution_status.rs similarity index 100% rename from src/types/execution_status.rs rename to crates/sui-sdk/src/types/execution_status.rs diff --git a/src/types/framework.rs b/crates/sui-sdk/src/types/framework.rs similarity index 100% rename from src/types/framework.rs rename to crates/sui-sdk/src/types/framework.rs diff --git a/src/types/gas.rs b/crates/sui-sdk/src/types/gas.rs similarity index 100% rename from src/types/gas.rs rename to crates/sui-sdk/src/types/gas.rs diff --git a/src/types/mod.rs b/crates/sui-sdk/src/types/mod.rs similarity index 100% rename from src/types/mod.rs rename to crates/sui-sdk/src/types/mod.rs diff --git a/src/types/object.rs b/crates/sui-sdk/src/types/object.rs similarity index 100% rename from src/types/object.rs rename to crates/sui-sdk/src/types/object.rs diff --git a/src/types/object_id.rs b/crates/sui-sdk/src/types/object_id.rs similarity index 100% rename from src/types/object_id.rs rename to crates/sui-sdk/src/types/object_id.rs diff --git a/src/types/serialization_proptests.rs b/crates/sui-sdk/src/types/serialization_proptests.rs similarity index 100% rename from src/types/serialization_proptests.rs rename to crates/sui-sdk/src/types/serialization_proptests.rs diff --git a/src/types/transaction/fixtures/authenticator_state_update b/crates/sui-sdk/src/types/transaction/fixtures/authenticator_state_update similarity index 100% rename from src/types/transaction/fixtures/authenticator_state_update rename to crates/sui-sdk/src/types/transaction/fixtures/authenticator_state_update diff --git a/src/types/transaction/fixtures/genesis-transaction b/crates/sui-sdk/src/types/transaction/fixtures/genesis-transaction similarity index 100% rename from src/types/transaction/fixtures/genesis-transaction rename to crates/sui-sdk/src/types/transaction/fixtures/genesis-transaction diff --git a/src/types/transaction/fixtures/wormhole-pyth-transaction b/crates/sui-sdk/src/types/transaction/fixtures/wormhole-pyth-transaction similarity index 100% rename from src/types/transaction/fixtures/wormhole-pyth-transaction rename to crates/sui-sdk/src/types/transaction/fixtures/wormhole-pyth-transaction diff --git a/src/types/transaction/mod.rs b/crates/sui-sdk/src/types/transaction/mod.rs similarity index 100% rename from src/types/transaction/mod.rs rename to crates/sui-sdk/src/types/transaction/mod.rs diff --git a/src/types/transaction/serialization.rs b/crates/sui-sdk/src/types/transaction/serialization.rs similarity index 100% rename from src/types/transaction/serialization.rs rename to crates/sui-sdk/src/types/transaction/serialization.rs diff --git a/src/types/transaction/unresolved.rs b/crates/sui-sdk/src/types/transaction/unresolved.rs similarity index 100% rename from src/types/transaction/unresolved.rs rename to crates/sui-sdk/src/types/transaction/unresolved.rs diff --git a/src/types/type_tag/mod.rs b/crates/sui-sdk/src/types/type_tag/mod.rs similarity index 100% rename from src/types/type_tag/mod.rs rename to crates/sui-sdk/src/types/type_tag/mod.rs diff --git a/src/types/type_tag/parse.rs b/crates/sui-sdk/src/types/type_tag/parse.rs similarity index 100% rename from src/types/type_tag/parse.rs rename to crates/sui-sdk/src/types/type_tag/parse.rs diff --git a/src/types/type_tag/serialization.rs b/crates/sui-sdk/src/types/type_tag/serialization.rs similarity index 100% rename from src/types/type_tag/serialization.rs rename to crates/sui-sdk/src/types/type_tag/serialization.rs diff --git a/src/types/u256.rs b/crates/sui-sdk/src/types/u256.rs similarity index 100% rename from src/types/u256.rs rename to crates/sui-sdk/src/types/u256.rs