diff --git a/.circleci/config.yml b/.circleci/config.yml index 51c641f4d0..e60c5617e6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,9 +63,9 @@ workflows: # Keep those job names in sync with .mergify.yml jobs: - arm64 + - package_core - package_crypto - package_check - - package_core - package_schema - package_schema_derive - package_std @@ -238,9 +238,12 @@ jobs: - contracts/staking/target/wasm32-unknown-unknown/release/build - contracts/staking/target/wasm32-unknown-unknown/release/deps - package_crypto: + package_core: docker: - image: rust:1.74 + environment: + # Limit the number of parallel jobs to avoid OOM crashes during doc testing + RUST_TEST_THREADS: 8 steps: - checkout - run: @@ -248,28 +251,50 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_crypto-rust:1.74-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_core-rust:1.74-{{ checksum "Cargo.lock" }} - run: - name: Build (no features) - working_directory: ~/project/packages/crypto + name: Add thumbv7em-none-eabi target + command: rustup target add thumbv7em-none-eabi && rustup target list --installed + - run: + name: Add wasm32 target + command: rustup target add wasm32-unknown-unknown && rustup target list --installed + - run: + name: Build library for native target (no features) + working_directory: ~/project/packages/core command: cargo build --locked --no-default-features - run: - name: Build (all features) - working_directory: ~/project/packages/crypto - command: cargo build --locked --features std + name: Build library for wasm target (no features) + working_directory: ~/project/packages/core + command: cargo wasm --locked --no-default-features - run: - name: Run tests - working_directory: ~/project/packages/crypto - command: cargo test --locked --features std + name: Build library for no_std target (no features) + working_directory: ~/project/packages/core + command: cargo no-std --locked --no-default-features + - run: + name: Run unit tests (no features) + working_directory: ~/project/packages/core + command: cargo test --locked --no-default-features + - run: + name: Build library for native target (all features) + working_directory: ~/project/packages/core + command: cargo build --locked --all-features + - run: + name: Build library for wasm target (all features) + working_directory: ~/project/packages/core + command: cargo wasm --locked --all-features + - run: + name: Run unit tests (all features) + working_directory: ~/project/packages/core + command: cargo test --locked --all-features - save_cache: paths: - /usr/local/cargo/registry - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_crypto-rust:1.74-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_core-rust:1.74-{{ checksum "Cargo.lock" }} - package_check: + package_crypto: docker: - image: rust:1.74 steps: @@ -279,14 +304,14 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_check-rust:1.74-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_crypto-rust:1.74-{{ checksum "Cargo.lock" }} - run: name: Build - working_directory: ~/project/packages/check + working_directory: ~/project/packages/crypto command: cargo build --locked - run: name: Run tests - working_directory: ~/project/packages/check + working_directory: ~/project/packages/crypto command: cargo test --locked - save_cache: paths: @@ -294,14 +319,11 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_check-rust:1.74-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_crypto-rust:1.74-{{ checksum "Cargo.lock" }} - package_core: + package_check: docker: - image: rust:1.74 - environment: - # Limit the number of parallel jobs to avoid OOM crashes during doc testing - RUST_TEST_THREADS: 8 steps: - checkout - run: @@ -309,48 +331,22 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_core-rust:1.74-{{ checksum "Cargo.lock" }} - - run: - name: Add thumbv7em-none-eabi target - command: rustup target add thumbv7em-none-eabi && rustup target list --installed - - run: - name: Add wasm32 target - command: rustup target add wasm32-unknown-unknown && rustup target list --installed - - run: - name: Build library for native target (no features) - working_directory: ~/project/packages/core - command: cargo build --locked --no-default-features - - run: - name: Build library for wasm target (no features) - working_directory: ~/project/packages/core - command: cargo wasm --locked --no-default-features - - run: - name: Build library for no_std target (no features) - working_directory: ~/project/packages/core - command: cargo no-std --locked --no-default-features - - run: - name: Run unit tests (no features) - working_directory: ~/project/packages/core - command: cargo test --locked --no-default-features - - run: - name: Build library for native target (all features) - working_directory: ~/project/packages/core - command: cargo build --locked --features std + - cargocache-v2-package_check-rust:1.74-{{ checksum "Cargo.lock" }} - run: - name: Build library for wasm target (all features) - working_directory: ~/project/packages/core - command: cargo wasm --locked --features std + name: Build + working_directory: ~/project/packages/check + command: cargo build --locked - run: - name: Run unit tests (all features) - working_directory: ~/project/packages/core - command: cargo test --locked --features std + name: Run tests + working_directory: ~/project/packages/check + command: cargo test --locked - save_cache: paths: - /usr/local/cargo/registry - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_core-rust:1.74-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_check-rust:1.74-{{ checksum "Cargo.lock" }} package_schema: docker: @@ -1006,6 +1002,14 @@ jobs: # # Workspace packages # + - run: + name: Clippy linting on core (no feature flags) + working_directory: ~/project/packages/core + command: cargo clippy --all-targets -- -D warnings + - run: + name: Clippy linting on core (all feature flags) + working_directory: ~/project/packages/core + command: cargo clippy --all-features --all-targets -- -D warnings - run: name: Clippy linting on crypto working_directory: ~/project/packages/crypto @@ -1022,14 +1026,6 @@ jobs: name: Clippy linting on schema-derive working_directory: ~/project/packages/schema-derive command: cargo clippy --all-targets --tests -- -D warnings - - run: - name: Clippy linting on core (no feature flags) - working_directory: ~/project/packages/core - command: cargo clippy --all-targets -- -D warnings - - run: - name: Clippy linting on core (all feature flags) - working_directory: ~/project/packages/core - command: cargo clippy --all-features --all-targets -- -D warnings - run: name: Clippy linting on std (no feature flags) working_directory: ~/project/packages/std diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index 70f505e4de..23eb8b0f49 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -21,6 +21,8 @@ jobs: toolchain: 1.74.0 targets: wasm32-unknown-unknown components: clippy, rustfmt + - name: "Cache build artifacts" + uses: Swatinem/rust-cache@v2 - name: Check workspace run: ./devtools/check_workspace.sh @@ -35,5 +37,7 @@ jobs: with: toolchain: 1.74.0 components: rustfmt + - name: "Cache build artifacts" + uses: Swatinem/rust-cache@v2 - name: Test workspace run: ./devtools/test_workspace.sh diff --git a/Cargo.lock b/Cargo.lock index 828cab83ef..b9f7463872 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -576,22 +576,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.1", - "bnum", - "cosmwasm-crypto", - "cosmwasm-std", - "crc32fast", - "derive_more", - "hex", - "hex-literal", - "schemars", - "serde", - "serde_json", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -603,9 +587,8 @@ dependencies = [ "ark-serialize", "base64 0.22.1", "base64-serde", - "cfg-if", + "cosmwasm-core", "criterion", - "derive_more", "digest", "ecdsa", "ed25519-zebra", @@ -665,6 +648,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.1", "bech32", + "bnum", "chrono", "cosmwasm-core", "cosmwasm-crypto", @@ -680,6 +664,7 @@ dependencies = [ "serde-json-wasm", "serde_json", "sha2", + "static_assertions", "thiserror", ] @@ -691,6 +676,7 @@ dependencies = [ "bytes", "clap", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index ce6007e622..ff563ac95a 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -449,18 +449,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -470,8 +458,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -519,6 +506,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -529,6 +517,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -539,6 +528,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 2232d941bd..3bdc5afa39 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -444,18 +444,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -465,8 +453,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -514,6 +501,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -524,6 +512,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -534,6 +523,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 49b7da2dc4..f9976ef4a8 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -461,18 +461,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -482,8 +470,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -531,6 +518,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -541,6 +529,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -551,6 +540,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index 9071e1c36f..67eb83cb55 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -438,18 +438,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -459,8 +447,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -508,6 +495,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -518,6 +506,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -528,6 +517,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 5d02e84db4..ab7ec1e559 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -4,11 +4,11 @@ version = 3 [[package]] name = "addr2line" -version = "0.15.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ - "gimli 0.24.0", + "gimli 0.29.0", ] [[package]] @@ -42,58 +42,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - -[[package]] -name = "anstream" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" - -[[package]] -name = "anstyle-parse" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.3" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" -dependencies = [ - "anstyle", - "windows-sys 0.52.0", -] +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "anyhow" @@ -224,27 +175,27 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.60" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7815ea54e4d821e791162e078acbebfd6d8c8939cd559c9335dceb1c8ca7282" +checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" dependencies = [ "addr2line", "cc", "cfg-if", "libc", - "miniz_oxide 0.4.4", + "miniz_oxide", "object", "rustc-demangle", ] @@ -263,9 +214,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bech32" @@ -275,21 +226,33 @@ checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] [[package]] name = "block-buffer" -version = "0.10.2" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -302,15 +265,15 @@ checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytecheck" -version = "0.6.10" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13fe11640a23eb24562225322cd3e452b93a3d4091d62fab69c70542fcd17d1f" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" dependencies = [ "bytecheck_derive", "ptr_meta", @@ -319,9 +282,9 @@ dependencies = [ [[package]] name = "bytecheck_derive" -version = "0.6.10" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ "proc-macro2", "quote", @@ -330,15 +293,15 @@ dependencies = [ [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" dependencies = [ "serde", ] @@ -354,9 +317,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.69" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cfg-if" @@ -364,69 +327,23 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "clap" -version = "4.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.52", -] - -[[package]] -name = "clap_lex" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" - [[package]] name = "clru" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8191fa7302e03607ff0e237d4246cc043ff5b3cb9409d995172ba3bea16b807" - -[[package]] -name = "colorchoice" -version = "1.0.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59" [[package]] name = "const-oid" -version = "0.9.4" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "corosensei" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9847f90f32a50b0dcbd68bc23ff242798b13080b97b0569f6ed96a45ce4cf2cd" +checksum = "80128832c58ea9cbd041d2a759ec449224487b2c1e400453d99d244eead87a8e" dependencies = [ "autocfg", "cfg-if", @@ -438,18 +355,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -459,8 +364,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -479,7 +383,7 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] @@ -499,15 +403,16 @@ version = "2.0.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] name = "cosmwasm-std" version = "2.0.1" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -518,6 +423,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -528,6 +434,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", @@ -577,7 +484,7 @@ dependencies = [ "cranelift-egraph", "cranelift-entity", "cranelift-isle", - "gimli 0.26.1", + "gimli 0.26.2", "log", "regalloc2", "smallvec", @@ -639,62 +546,52 @@ checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "cfg-if", "crossbeam-utils", - "lazy_static", - "memoffset 0.6.4", - "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.8" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" -dependencies = [ - "cfg-if", - "lazy_static", -] +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crypto-bigint" -version = "0.5.2" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", "rand_core", @@ -737,7 +634,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] @@ -752,12 +649,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.3" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" dependencies = [ - "darling_core 0.20.3", - "darling_macro 0.20.3", + "darling_core 0.20.9", + "darling_macro 0.20.9", ] [[package]] @@ -776,15 +673,15 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] @@ -800,23 +697,23 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ - "darling_core 0.20.3", + "darling_core 0.20.9", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] name = "dashmap" -version = "5.4.0" +version = "5.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.12.3", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -824,9 +721,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.7" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "zeroize", @@ -891,7 +788,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", "unicode-xid", ] @@ -918,9 +815,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.4" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "dynasm" @@ -928,7 +825,7 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "add9a102807b524ec050363f09e06f1504214b0e1c7797f64261c891022dce8b" dependencies = [ - "bitflags 1.2.1", + "bitflags 1.3.2", "byteorder", "lazy_static", "proc-macro-error", @@ -945,14 +842,14 @@ checksum = "64fba5a42bd76a17cad4bfa00de168ee1cbfa06a5e8ce992ae880218c05641a9" dependencies = [ "byteorder", "dynasm", - "memmap2 0.5.0", + "memmap2 0.5.10", ] [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", "digest", @@ -978,7 +875,7 @@ checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ "curve25519-dalek", "ed25519", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "hex", "rand_core", "sha2", @@ -987,9 +884,9 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "elliptic-curve" @@ -1031,9 +928,9 @@ dependencies = [ [[package]] name = "enumset" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e875f1719c16de097dee81ed675e2d9bb63096823ed3f0ca827b7dea3028bbbb" +checksum = "226c0da7462c13fb57e5cc9e0dc8f0635e7d27f276a3a7fd30054647f669007d" dependencies = [ "enumset_derive", ] @@ -1044,10 +941,10 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ - "darling 0.20.3", + "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] @@ -1090,9 +987,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c007b1ae3abe1cb6f85a16305acd418b7ca6343b953633fee2b76d8f108b830f" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "filetime" @@ -1113,7 +1010,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", - "miniz_oxide 0.7.3", + "miniz_oxide", ] [[package]] @@ -1143,6 +1040,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "fxhash" version = "0.2.1" @@ -1178,21 +1081,21 @@ dependencies = [ [[package]] name = "gimli" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" - -[[package]] -name = "gimli" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" dependencies = [ "fallible-iterator", "indexmap 1.9.3", "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + [[package]] name = "group" version = "0.13.0" @@ -1230,9 +1133,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash 0.8.11", "allocator-api2", @@ -1240,9 +1143,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hex" @@ -1288,21 +1191,15 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "serde", ] -[[package]] -name = "is_terminal_polyfill" -version = "1.70.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" - [[package]] name = "itertools" version = "0.10.5" @@ -1312,12 +1209,6 @@ dependencies = [ "either", ] -[[package]] -name = "itoa" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" - [[package]] name = "itoa" version = "1.0.11" @@ -1326,9 +1217,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -1353,9 +1244,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "leb128" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" @@ -1377,9 +1268,9 @@ checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -1387,12 +1278,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.14" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if", -] +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "mach" @@ -1403,6 +1291,15 @@ dependencies = [ "libc", ] +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + [[package]] name = "memchr" version = "2.7.2" @@ -1411,9 +1308,9 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memmap2" -version = "0.5.0" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4647a11b578fead29cdbb34d4adef8dd3dc35b876c9c6d5240d83f205abfe96e" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" dependencies = [ "libc", ] @@ -1429,32 +1326,13 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - [[package]] name = "miniz_oxide" version = "0.7.3" @@ -1466,17 +1344,16 @@ dependencies = [ [[package]] name = "more-asserts" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" +checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", ] @@ -1492,18 +1369,18 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "object" -version = "0.25.3" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38f2be3697a57b4060074ff41b44c16870d916ad7877c17696e063257482bc7" +checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" dependencies = [ "memchr", ] @@ -1528,22 +1405,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall 0.5.1", "smallvec", - "windows-targets 0.48.1", + "windows-targets", ] [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "percent-encoding" @@ -1553,9 +1430,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "platforms" @@ -1604,9 +1481,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -1633,13 +1510,19 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.5" @@ -1671,9 +1554,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -1691,20 +1574,20 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags 1.2.1", + "bitflags 1.3.2", ] [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 1.2.1", + "bitflags 2.5.0", ] [[package]] @@ -1721,21 +1604,21 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "e6b6ebd13bc009aef9cd476c1310d49ac354d36e240cf1bd753290f3dc7199a7" dependencies = [ - "bitflags 1.2.1", + "bitflags 1.3.2", "libc", - "mach", - "winapi", + "mach2", + "windows-sys 0.52.0", ] [[package]] name = "rend" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" dependencies = [ "bytecheck", ] @@ -1752,24 +1635,28 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.41" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21499ed91807f07ae081880aabb2ccc0235e9d88011867d984525e9a4c3cfa3e" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" dependencies = [ + "bitvec", "bytecheck", + "bytes", "hashbrown 0.12.3", "indexmap 1.9.3", "ptr_meta", "rend", "rkyv_derive", "seahash", + "tinyvec", + "uuid", ] [[package]] name = "rkyv_derive" -version = "0.7.41" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1c672430eb41556291981f45ca900a0239ad007242d1cb4b4167af842db666" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" dependencies = [ "proc-macro2", "quote", @@ -1778,9 +1665,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.20" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc_version" @@ -1797,7 +1684,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -1806,21 +1693,21 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schemars" -version = "0.8.16" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", "schemars_derive", @@ -1831,21 +1718,21 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.16" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "seahash" @@ -1868,24 +1755,24 @@ dependencies = [ [[package]] name = "self_cell" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c309e515543e67811222dbc9e3dd7e1056279b782e1dacffe4242b718734fb6" +checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.197" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] @@ -1922,33 +1809,33 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] name = "serde_derive_internals" -version = "0.26.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ - "itoa 0.4.7", + "itoa", "ryu", "serde", ] @@ -1968,8 +1855,8 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.5", - "itoa 1.0.11", + "indexmap 2.2.6", + "itoa", "ryu", "serde", "unsafe-libyaml", @@ -1998,9 +1885,9 @@ dependencies = [ [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", "rand_core", @@ -2014,15 +1901,15 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" [[package]] name = "slice-group-by" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.6.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "stable_deref_trait" @@ -2053,22 +1940,22 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +checksum = "f7993a8e3a9e88a00351486baae9522c91b123a088f76469e5bd5cc17198ea87" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" @@ -2083,15 +1970,21 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tar" version = "0.4.40" @@ -2105,9 +1998,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.7" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" +checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "tempfile" @@ -2123,22 +2016,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] @@ -2170,14 +2063,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.13", + "toml_edit 0.22.14", ] [[package]] @@ -2195,7 +2088,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", @@ -2204,15 +2097,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.13" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.8", + "winnow 0.6.11", ] [[package]] @@ -2234,7 +2127,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] @@ -2248,9 +2141,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" @@ -2260,9 +2153,9 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -2298,10 +2191,10 @@ dependencies = [ ] [[package]] -name = "utf8parse" -version = "0.2.1" +name = "uuid" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" [[package]] name = "version_check" @@ -2317,9 +2210,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2327,24 +2220,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.66", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2352,22 +2245,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasmer" @@ -2411,7 +2304,7 @@ dependencies = [ "enumset", "lazy_static", "leb128", - "memmap2 0.5.0", + "memmap2 0.5.10", "more-asserts", "region", "rkyv", @@ -2435,7 +2328,7 @@ dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "gimli 0.26.1", + "gimli 0.26.2", "more-asserts", "rayon", "smallvec", @@ -2455,7 +2348,7 @@ dependencies = [ "dynasm", "dynasmrt", "enumset", - "gimli 0.26.1", + "gimli 0.26.2", "lazy_static", "more-asserts", "rayon", @@ -2474,7 +2367,7 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.5", + "indexmap 2.2.6", "schemars", "semver", "serde", @@ -2482,7 +2375,7 @@ dependencies = [ "serde_json", "serde_yaml", "thiserror", - "toml 0.8.13", + "toml 0.8.14", "url", ] @@ -2549,7 +2442,7 @@ dependencies = [ "lazy_static", "libc", "mach", - "memoffset 0.9.0", + "memoffset", "more-asserts", "region", "scopeguard", @@ -2564,22 +2457,21 @@ version = "0.121.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ - "bitflags 2.4.2", - "indexmap 2.2.5", + "bitflags 2.5.0", + "indexmap 2.2.6", "semver", ] [[package]] name = "webc" -version = "6.0.0-alpha9" +version = "6.0.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b4e8dd987046eede4348d660404ff990412631b7d493f9e547adcf2862cd5" +checksum = "c1fc686c7b43c9bc630a499f6ae1f0a4c4bd656576a53ae8a147b0cc9bc983ad" dependencies = [ "anyhow", "base64 0.21.7", "bytes", "cfg-if", - "clap", "document-features", "flate2", "indexmap 1.9.3", @@ -2640,22 +2532,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", -] - -[[package]] -name = "windows-targets" -version = "0.48.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows-targets", ] [[package]] @@ -2664,22 +2541,16 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_gnullvm", "windows_aarch64_msvc 0.52.5", "windows_i686_gnu 0.52.5", "windows_i686_gnullvm", "windows_i686_msvc 0.52.5", "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_gnullvm", "windows_x86_64_msvc 0.52.5", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.5" @@ -2692,12 +2563,6 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - [[package]] name = "windows_aarch64_msvc" version = "0.52.5" @@ -2710,12 +2575,6 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - [[package]] name = "windows_i686_gnu" version = "0.52.5" @@ -2734,12 +2593,6 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - [[package]] name = "windows_i686_msvc" version = "0.52.5" @@ -2752,24 +2605,12 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - [[package]] name = "windows_x86_64_gnu" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.5" @@ -2782,12 +2623,6 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - [[package]] name = "windows_x86_64_msvc" version = "0.52.5" @@ -2805,13 +2640,22 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.8" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +checksum = "56c52728401e1dc672a56e81e593e912aa54c78f40246869f78359a2bf24d29d" dependencies = [ "memchr", ] +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "xattr" version = "1.3.1" @@ -2831,29 +2675,29 @@ checksum = "927da81e25be1e1a2901d59b81b37dd2efd1fc9c9345a55007f09bf5a2d3ee03" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -2866,5 +2710,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.66", ] diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 61a721f1e1..e2ace11e58 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -438,18 +438,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -459,8 +447,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -508,6 +495,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -518,6 +506,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -528,6 +517,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/ibc-callbacks/Cargo.lock b/contracts/ibc-callbacks/Cargo.lock index e5ce98e288..22102c124d 100644 --- a/contracts/ibc-callbacks/Cargo.lock +++ b/contracts/ibc-callbacks/Cargo.lock @@ -450,18 +450,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.1", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -471,8 +459,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -520,6 +507,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.1", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -530,6 +518,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -540,6 +529,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index 571f9eee15..8c72af8a7a 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -438,18 +438,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -459,8 +447,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -508,6 +495,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -518,6 +506,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -528,6 +517,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index 9512f2f33c..fae64df289 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -438,18 +438,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -459,8 +447,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -508,6 +495,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -518,6 +506,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -528,6 +517,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 4c75d9d514..c8c90ba70a 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -438,18 +438,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -459,8 +447,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -508,6 +495,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -518,6 +506,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -528,6 +517,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index b5b277c373..1edc2eb82b 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -438,18 +438,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -459,8 +447,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -508,6 +495,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -518,6 +506,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -528,6 +517,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 67b7a3517d..089cd0d27e 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -438,18 +438,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -459,8 +447,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -508,6 +495,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -518,6 +506,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -528,6 +517,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 89e8a9be5c..55b818f70a 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -438,18 +438,6 @@ dependencies = [ [[package]] name = "cosmwasm-core" version = "2.0.1" -dependencies = [ - "base64 0.22.0", - "bnum", - "cosmwasm-crypto", - "derive_more", - "hex", - "schemars", - "serde", - "sha2", - "static_assertions", - "thiserror", -] [[package]] name = "cosmwasm-crypto" @@ -459,8 +447,7 @@ dependencies = [ "ark-ec", "ark-ff", "ark-serialize", - "cfg-if", - "derive_more", + "cosmwasm-core", "digest", "ecdsa", "ed25519-zebra", @@ -508,6 +495,7 @@ version = "2.0.1" dependencies = [ "base64 0.22.0", "bech32", + "bnum", "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", @@ -518,6 +506,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2", + "static_assertions", "thiserror", ] @@ -528,6 +517,7 @@ dependencies = [ "bech32", "bytes", "clru", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-std", "crc32fast", diff --git a/devtools/test_workspace.sh b/devtools/test_workspace.sh index 0303753549..aa0fa25665 100755 --- a/devtools/test_workspace.sh +++ b/devtools/test_workspace.sh @@ -4,7 +4,8 @@ command -v shellcheck >/dev/null && shellcheck "$0" cargo fmt (cd packages/crypto && cargo test) -(cd packages/std && cargo test --features iterator,cosmwasm_1_2) +# A test inside the std package expects backtraces to be disabled +(cd packages/std && RUST_BACKTRACE=0 cargo test --features iterator,cosmwasm_1_2) (cd packages/schema && cargo test) (cd packages/schema-derive && cargo test) (cd packages/vm && cargo test --features iterator,stargate) diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 05dfbcb478..f0ed9e8dc4 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -7,27 +7,4 @@ repository = "https://github.com/CosmWasm/cosmwasm/tree/main/packages/core" license = "Apache-2.0" readme = "README.md" -[package.metadata.release] -release = false - [dependencies] -base64 = { version = "0.22.0", default-features = false, features = ["alloc"] } -bnum = "0.11.0" -cosmwasm-crypto = { version = "2.0.1", path = "../crypto" } -derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] } -hex = { version = "0.4.3", default-features = false, features = ["alloc"] } -schemars = { version = "0.8.16", optional = true } -serde = { version = "1.0.197", default-features = false, features = ["alloc", "derive"] } -sha2 = { version = "0.10.8", default-features = false } -static_assertions = "1.1.0" -thiserror = { version = "1.0.26", optional = true } - -[features] -std = ["dep:schemars", "dep:thiserror"] - -[dev-dependencies] -# Cyclic dependencies for doc tests.. -cosmwasm-std = { path = "../std", version = "2.0.1" } -crc32fast = { version = "1.4.0", default-features = false } -hex-literal = "0.4.1" -serde_json = "1.0.114" diff --git a/packages/core/src/crypto.rs b/packages/core/src/crypto.rs new file mode 100644 index 0000000000..3030cddbb2 --- /dev/null +++ b/packages/core/src/crypto.rs @@ -0,0 +1,24 @@ +pub const BLS12_381_G1_POINT_LEN: usize = 48; +pub const BLS12_381_G2_POINT_LEN: usize = 96; + +/// A generator in G1 (in compressed serialization). +/// +/// This can be used directly for signature verification +/// (see e.g. https://twitter.com/simon_warta/status/1786342207106019765) +pub const BLS12_381_G1_GENERATOR: [u8; BLS12_381_G1_POINT_LEN] = [ + 151, 241, 211, 167, 49, 151, 215, 148, 38, 149, 99, 140, 79, 169, 172, 15, 195, 104, 140, 79, + 151, 116, 185, 5, 161, 78, 58, 63, 23, 27, 172, 88, 108, 85, 232, 63, 249, 122, 26, 239, 251, + 58, 240, 10, 219, 34, 198, 187, +]; + +/// A generator in G2 (in compressed serialization). +/// +/// This can be used directly for signature verification +/// (see e.g. https://twitter.com/simon_warta/status/1786342207106019765) +pub const BLS12_381_G2_GENERATOR: [u8; BLS12_381_G2_POINT_LEN] = [ + 147, 224, 43, 96, 82, 113, 159, 96, 125, 172, 211, 160, 136, 39, 79, 101, 89, 107, 208, 208, + 153, 32, 182, 26, 181, 218, 97, 187, 220, 127, 80, 73, 51, 76, 241, 18, 19, 148, 93, 87, 229, + 172, 125, 5, 93, 4, 43, 126, 2, 74, 162, 178, 240, 143, 10, 145, 38, 8, 5, 39, 45, 197, 16, 81, + 198, 228, 122, 212, 250, 64, 59, 2, 180, 81, 11, 100, 122, 227, 209, 119, 11, 172, 3, 38, 168, + 5, 187, 239, 212, 128, 86, 200, 193, 33, 189, 184, +]; diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index 0537a84028..75f2e6dc17 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -1,48 +1,8 @@ -//! cosmwasm-core contains components of cosmwasm-std that can be used in a no_std environment. -//! All symbols are re-exported by cosmwasm-std, such that contract developers don't need to -//! add this dependency directly. It is recommended to only use cosmwasm-std whenever possible. +#![no_std] -#![cfg_attr(not(feature = "std"), no_std)] - -#[macro_use] -extern crate alloc; - -#[cfg(test)] -extern crate std; // allow for file I/O during tests - -mod addresses; -mod binary; -mod encoding; -mod errors; -mod forward_ref; -mod hex_binary; -mod math; -mod timestamp; +mod crypto; #[doc(hidden)] -pub mod __internal; - -use crate::__internal__forward_ref_partial_eq as forward_ref_partial_eq; - -pub use crate::addresses::{instantiate2_address, Addr, CanonicalAddr, Instantiate2AddressError}; -pub use crate::binary::Binary; -pub use crate::encoding::{from_base64, from_hex, to_base64, to_hex}; -pub use crate::errors::{ - AggregationError, CheckedFromRatioError, CheckedMultiplyFractionError, - CheckedMultiplyRatioError, CoinFromStrError, CoinsError, ConversionOverflowError, CoreError, - CoreResult, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, - PairingEqualityError, RecoverPubkeyError, RoundDownOverflowError, RoundUpOverflowError, - SystemError, VerificationError, -}; -pub use crate::hex_binary::HexBinary; -pub use crate::math::{ - Decimal, Decimal256, Decimal256RangeExceeded, DecimalRangeExceeded, Fraction, Int128, Int256, - Int512, Int64, Isqrt, SignedDecimal, SignedDecimal256, SignedDecimal256RangeExceeded, - SignedDecimalRangeExceeded, Uint128, Uint256, Uint512, Uint64, +pub use self::crypto::{ + BLS12_381_G1_GENERATOR, BLS12_381_G1_POINT_LEN, BLS12_381_G2_GENERATOR, BLS12_381_G2_POINT_LEN, }; -pub use crate::timestamp::Timestamp; - -/// Exposed for testing only -/// Both unit tests and integration tests are compiled to native code, so everything in here does not need to compile to Wasm. -#[cfg(not(target_arch = "wasm32"))] -pub mod testing; diff --git a/packages/core/src/testing/mod.rs b/packages/core/src/testing/mod.rs deleted file mode 100644 index abe4990132..0000000000 --- a/packages/core/src/testing/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod assertions; - -pub use assertions::assert_approx_eq_impl; -#[cfg(test)] -pub use assertions::assert_hash_works_impl; diff --git a/packages/crypto/Cargo.toml b/packages/crypto/Cargo.toml index 1edfbb072e..dc2063bfe3 100644 --- a/packages/crypto/Cargo.toml +++ b/packages/crypto/Cargo.toml @@ -7,40 +7,26 @@ description = "Crypto bindings for cosmwasm contracts" repository = "https://github.com/CosmWasm/cosmwasm/tree/main/packages/crypto" license = "Apache-2.0" -[features] -default = [] -std = [ - "dep:ark-bls12-381", - "dep:ark-ec", - "dep:ark-ff", - "dep:ark-serialize", - "dep:num-traits", - "dep:rayon", - "dep:sha2", - "dep:thiserror" -] - [lib] # See https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options bench = false [dependencies] -ark-bls12-381 = { version = "0.4.0", optional = true } -ark-ec = { version = "0.4.2", features = ["parallel"], optional = true } -ark-ff = { version = "0.4.2", features = ["asm", "parallel"], optional = true } -ark-serialize = { version = "0.4.2", optional = true } -cfg-if = "1.0.0" -derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] } +ark-bls12-381 = "0.4.0" +ark-ec = { version = "0.4.2", features = ["parallel"] } +ark-ff = { version = "0.4.2", features = ["asm", "parallel"] } +ark-serialize = "0.4.2" +cosmwasm-core = { version = "2.0.1", path = "../core" } digest = "0.10" ecdsa = "0.16.2" # Not used directly, but needed to bump transitive dependency, see: https://github.com/CosmWasm/cosmwasm/pull/1899 for details. ed25519-zebra = { version = "4.0.3", default-features = false } k256 = { version = "0.13.3", default-features = false, features = ["ecdsa"] } -num-traits = { version = "0.2.18", optional = true } +num-traits = "0.2.18" p256 = { version = "0.13.2", default-features = false, features = ["ecdsa"] } rand_core = "0.6" -rayon = { version = "1.9.0", optional = true } -sha2 = { version = "0.10", optional = true } -thiserror = { version = "1.0.26", optional = true } +rayon = "1.9.0" +sha2 = "0.10" +thiserror = "1.0.26" [dev-dependencies] base64 = "0.22.0" @@ -56,6 +42,10 @@ hex-literal = "0.4.1" english-numbers = "0.3" glob = "0.3.1" +[features] +default = ["std"] +std = [] + [[bench]] name = "main" harness = false diff --git a/packages/crypto/benches/main.rs b/packages/crypto/benches/main.rs index afc64cbf13..f434115a9d 100644 --- a/packages/crypto/benches/main.rs +++ b/packages/crypto/benches/main.rs @@ -15,11 +15,11 @@ use digest::Digest; use k256::ecdsa::SigningKey; // type alias use sha2::Sha256; +use cosmwasm_core::{BLS12_381_G1_GENERATOR, BLS12_381_G1_POINT_LEN, BLS12_381_G2_POINT_LEN}; use cosmwasm_crypto::{ bls12_381_aggregate_g1, bls12_381_aggregate_g2, bls12_381_hash_to_g1, bls12_381_hash_to_g2, bls12_381_pairing_equality, ed25519_batch_verify, ed25519_verify, secp256k1_recover_pubkey, secp256k1_verify, secp256r1_recover_pubkey, secp256r1_verify, HashFunction, - BLS12_381_G1_GENERATOR, BLS12_381_G1_POINT_LEN, BLS12_381_G2_POINT_LEN, }; use std::cmp::min; diff --git a/packages/crypto/src/bls12_318/constants.rs b/packages/crypto/src/bls12_318/constants.rs index 8281719cf5..67e58adeb3 100644 --- a/packages/crypto/src/bls12_318/constants.rs +++ b/packages/crypto/src/bls12_318/constants.rs @@ -1,36 +1,11 @@ -pub const BLS12_381_G1_POINT_LEN: usize = 48; -pub const BLS12_381_G2_POINT_LEN: usize = 96; - -/// A generator in G1 (in compressed serialization). -/// -/// This can be used directly for signature verification -/// (see e.g. https://twitter.com/simon_warta/status/1786342207106019765) -pub const BLS12_381_G1_GENERATOR: [u8; BLS12_381_G1_POINT_LEN] = [ - 151, 241, 211, 167, 49, 151, 215, 148, 38, 149, 99, 140, 79, 169, 172, 15, 195, 104, 140, 79, - 151, 116, 185, 5, 161, 78, 58, 63, 23, 27, 172, 88, 108, 85, 232, 63, 249, 122, 26, 239, 251, - 58, 240, 10, 219, 34, 198, 187, -]; - -/// A generator in G2 (in compressed serialization). -/// -/// This can be used directly for signature verification -/// (see e.g. https://twitter.com/simon_warta/status/1786342207106019765) -pub const BLS12_381_G2_GENERATOR: [u8; BLS12_381_G2_POINT_LEN] = [ - 147, 224, 43, 96, 82, 113, 159, 96, 125, 172, 211, 160, 136, 39, 79, 101, 89, 107, 208, 208, - 153, 32, 182, 26, 181, 218, 97, 187, 220, 127, 80, 73, 51, 76, 241, 18, 19, 148, 93, 87, 229, - 172, 125, 5, 93, 4, 43, 126, 2, 74, 162, 178, 240, 143, 10, 145, 38, 8, 5, 39, 45, 197, 16, 81, - 198, 228, 122, 212, 250, 64, 59, 2, 180, 81, 11, 100, 122, 227, 209, 119, 11, 172, 3, 38, 168, - 5, 187, 239, 212, 128, 86, 200, 193, 33, 189, 184, -]; - -#[cfg(all(test, feature = "std"))] +#[cfg(test)] mod test { use ark_bls12_381::{G1Affine, G2Affine}; use ark_ec::AffineRepr; use ark_serialize::CanonicalSerialize; use hex_literal::hex; - use super::{ + use cosmwasm_core::{ BLS12_381_G1_GENERATOR, BLS12_381_G1_POINT_LEN, BLS12_381_G2_GENERATOR, BLS12_381_G2_POINT_LEN, }; diff --git a/packages/crypto/src/bls12_318/hash.rs b/packages/crypto/src/bls12_318/hash.rs index 2d26e4aa81..917894abf6 100644 --- a/packages/crypto/src/bls12_318/hash.rs +++ b/packages/crypto/src/bls12_318/hash.rs @@ -27,9 +27,10 @@ use ark_ec::{ }; use ark_ff::field_hashers::DefaultFieldHasher; use ark_serialize::CanonicalSerialize; +use cosmwasm_core::{BLS12_381_G1_POINT_LEN, BLS12_381_G2_POINT_LEN}; use sha2::Sha256; -use crate::{CryptoError, BLS12_381_G1_POINT_LEN, BLS12_381_G2_POINT_LEN}; +use crate::CryptoError; type HashToCurve = MapToCurveBasedHasher, DefaultFieldHasher, WBMap>; diff --git a/packages/crypto/src/bls12_318/mod.rs b/packages/crypto/src/bls12_318/mod.rs index 719b0b59c1..fb3b32ad69 100644 --- a/packages/crypto/src/bls12_318/mod.rs +++ b/packages/crypto/src/bls12_318/mod.rs @@ -1,19 +1,10 @@ +mod aggregate; mod constants; +mod hash; +mod pairing; +mod points; -pub use self::constants::{ - BLS12_381_G1_GENERATOR, BLS12_381_G1_POINT_LEN, BLS12_381_G2_GENERATOR, BLS12_381_G2_POINT_LEN, -}; - -cfg_if::cfg_if! { - if #[cfg(feature = "std")] { - mod aggregate; - mod hash; - mod pairing; - mod points; - - pub use self::aggregate::{bls12_381_aggregate_g1, bls12_381_aggregate_g2}; - pub use self::hash::{bls12_381_hash_to_g1, bls12_381_hash_to_g2, HashFunction}; - pub use self::pairing::bls12_381_pairing_equality; - pub use self::points::{bls12_381_g1_is_identity, bls12_381_g2_is_identity}; - } -} +pub use self::aggregate::{bls12_381_aggregate_g1, bls12_381_aggregate_g2}; +pub use self::hash::{bls12_381_hash_to_g1, bls12_381_hash_to_g2, HashFunction}; +pub use self::pairing::bls12_381_pairing_equality; +pub use self::points::{bls12_381_g1_is_identity, bls12_381_g2_is_identity}; diff --git a/packages/crypto/src/bls12_318/pairing.rs b/packages/crypto/src/bls12_318/pairing.rs index 6e630722cc..e72cc80009 100644 --- a/packages/crypto/src/bls12_318/pairing.rs +++ b/packages/crypto/src/bls12_318/pairing.rs @@ -1,13 +1,14 @@ use core::ops::Neg; -use crate::{errors::PairingEquality, CryptoError, BLS12_381_G1_POINT_LEN, BLS12_381_G2_POINT_LEN}; - use super::points::{g1_from_variable, g2_from_variable}; +use crate::{errors::PairingEquality, CryptoError}; + use ark_bls12_381::Bls12_381; use ark_ec::{ bls12::{G1Prepared, G2Prepared}, pairing::Pairing, }; +use cosmwasm_core::{BLS12_381_G1_POINT_LEN, BLS12_381_G2_POINT_LEN}; use num_traits::Zero; use rayon::{ iter::{IndexedParallelIterator, ParallelIterator}, diff --git a/packages/crypto/src/bls12_318/points.rs b/packages/crypto/src/bls12_318/points.rs index a6e4b7c3e5..26980a9f9a 100644 --- a/packages/crypto/src/bls12_318/points.rs +++ b/packages/crypto/src/bls12_318/points.rs @@ -7,10 +7,10 @@ use core::{fmt, ops::Neg}; use ark_bls12_381::{G1Affine, G1Projective, G2Affine, G2Projective}; use ark_ec::AffineRepr; +use cosmwasm_core::{BLS12_381_G1_POINT_LEN, BLS12_381_G2_POINT_LEN}; use num_traits::Zero; -use crate::errors::InvalidPoint; -use crate::{CryptoError, BLS12_381_G1_POINT_LEN, BLS12_381_G2_POINT_LEN}; +use crate::{errors::InvalidPoint, CryptoError}; /// Point on G1 #[derive(Debug, PartialEq, Clone)] @@ -195,9 +195,9 @@ pub fn bls12_381_g2_is_identity(g2: &[u8; BLS12_381_G2_POINT_LEN]) -> Result Cr /// Three Variants are suppported in the input for convenience: /// - Equal number of messages, signatures, and public keys: Standard, generic functionality. /// - One message, and an equal number of signatures and public keys: Multiple digital signature -/// (multisig) verification of a single message. +/// (multisig) verification of a single message. /// - One public key, and an equal number of messages and signatures: Verification of multiple -/// messages, all signed with the same private key. +/// messages, all signed with the same private key. /// /// Any other variants of input vectors result in an error. /// /// Notes: -/// - The "one-message, with zero signatures and zero public keys" case, is considered the empty -/// case. -/// - The "one-public key, with zero messages and zero signatures" case, is considered the empty -/// case. +/// - The "one-message, with zero signatures and zero public keys" case, is considered the empty case. +/// - The "one-public key, with zero messages and zero signatures" case, is considered the empty case. /// - The empty case (no messages, no signatures and no public keys) returns true. pub fn ed25519_batch_verify( rng: &mut R, diff --git a/packages/crypto/src/errors.rs b/packages/crypto/src/errors.rs index bd3a6ccc41..e4b85cc92a 100644 --- a/packages/crypto/src/errors.rs +++ b/packages/crypto/src/errors.rs @@ -1,68 +1,63 @@ use alloc::string::String; use core::fmt::Debug; -use derive_more::Display; use crate::BT; pub type CryptoResult = core::result::Result; -#[derive(Debug, Display)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, thiserror::Error)] pub enum Aggregation { - #[display("List of points is empty")] + #[error("List of points is empty")] Empty, - #[display("List is not a multiple of {expected_multiple}. Remainder: {remainder}")] + #[error("List is not a multiple of {expected_multiple}. Remainder: {remainder}")] NotMultiple { expected_multiple: usize, remainder: usize, }, } -#[derive(Debug, Display)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, thiserror::Error)] pub enum PairingEquality { - #[display("List is not a multiple of 48. Remainder: {remainder}")] + #[error("List is not a multiple of 48. Remainder: {remainder}")] NotMultipleG1 { remainder: usize }, - #[display("List is not a multiple of 96. Remainder: {remainder}")] + #[error("List is not a multiple of 96. Remainder: {remainder}")] NotMultipleG2 { remainder: usize }, - #[display("Not the same amount of points passed. Left: {left}, Right: {right}")] + #[error("Not the same amount of points passed. Left: {left}, Right: {right}")] UnequalPointAmount { left: usize, right: usize }, } -#[derive(Debug, Display)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, thiserror::Error)] pub enum InvalidPoint { - #[display("Invalid input length for point (must be in compressed format): Expected {expected}, actual: {actual}")] + #[error("Invalid input length for point (must be in compressed format): Expected {expected}, actual: {actual}")] InvalidLength { expected: usize, actual: usize }, - #[display("Invalid point")] + #[error("Invalid point")] DecodingError {}, } -#[derive(Display, Debug)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, thiserror::Error)] pub enum CryptoError { - #[display("Point aggregation error: {source}")] + #[error("Point aggregation error: {source}")] Aggregation { source: Aggregation, backtrace: BT }, - #[display("Batch verify error: {msg}")] + #[error("Batch verify error: {msg}")] BatchErr { msg: String, backtrace: BT }, - #[display("Crypto error: {msg}")] + #[error("Crypto error: {msg}")] GenericErr { msg: String, backtrace: BT }, - #[display("Invalid hash format")] + #[error("Invalid hash format")] InvalidHashFormat { backtrace: BT }, - #[display("Invalid public key format")] + #[error("Invalid public key format")] InvalidPubkeyFormat { backtrace: BT }, - #[display("Invalid signature format")] + #[error("Invalid signature format")] InvalidSignatureFormat { backtrace: BT }, - #[display("Invalid recovery parameter. Supported values: 0 and 1.")] + #[error("Invalid recovery parameter. Supported values: 0 and 1.")] InvalidRecoveryParam { backtrace: BT }, - #[display("Invalid point: {source}")] + #[error("Invalid point: {source}")] InvalidPoint { source: InvalidPoint, backtrace: BT }, - #[display("Pairing equality error: {source}")] + #[error("Pairing equality error: {source}")] PairingEquality { source: PairingEquality, backtrace: BT, }, - #[display("Unknown hash function")] + #[error("Unknown hash function")] UnknownHashFunction { backtrace: BT }, } diff --git a/packages/crypto/src/lib.rs b/packages/crypto/src/lib.rs index 36d40016e1..f8fe007357 100644 --- a/packages/crypto/src/lib.rs +++ b/packages/crypto/src/lib.rs @@ -3,13 +3,8 @@ //! they might change frequently, or be removed in the future. //! This crate does not adhere to semantic versioning. -#![cfg_attr(not(feature = "std"), no_std)] - extern crate alloc; -#[cfg(test)] -extern crate std; // allow for file I/O during tests - mod backtrace; mod bls12_318; mod ecdsa; @@ -19,18 +14,12 @@ mod identity_digest; mod secp256k1; mod secp256r1; -#[cfg(feature = "std")] #[doc(hidden)] pub use crate::bls12_318::{ bls12_381_aggregate_g1, bls12_381_aggregate_g2, bls12_381_g1_is_identity, bls12_381_g2_is_identity, bls12_381_hash_to_g1, bls12_381_hash_to_g2, bls12_381_pairing_equality, HashFunction, }; - -#[doc(hidden)] -pub use crate::bls12_318::{ - BLS12_381_G1_GENERATOR, BLS12_381_G1_POINT_LEN, BLS12_381_G2_GENERATOR, BLS12_381_G2_POINT_LEN, -}; #[doc(hidden)] pub use crate::ecdsa::{ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, MESSAGE_HASH_MAX_LEN}; #[doc(hidden)] diff --git a/packages/crypto/src/secp256k1.rs b/packages/crypto/src/secp256k1.rs index c5ab3bb559..25efb71327 100644 --- a/packages/crypto/src/secp256k1.rs +++ b/packages/crypto/src/secp256k1.rs @@ -18,7 +18,7 @@ use crate::identity_digest::Identity256; /// The signature and public key are in "Cosmos" format: /// - signature: Serialized "compact" signature (64 bytes). /// - public key: [Serialized according to SEC 2](https://www.oreilly.com/library/view/programming-bitcoin/9781492031482/ch04.html) -/// (33 or 65 bytes). +/// (33 or 65 bytes). /// /// This implementation accepts both high-S and low-S signatures. Some applications /// including Ethereum transactions consider high-S signatures invalid in order to diff --git a/packages/crypto/src/secp256r1.rs b/packages/crypto/src/secp256r1.rs index 8778569f64..8b41aefe9c 100644 --- a/packages/crypto/src/secp256r1.rs +++ b/packages/crypto/src/secp256r1.rs @@ -19,7 +19,7 @@ use crate::identity_digest::Identity256; /// The signature and public key are in "Cosmos" format: /// - signature: Serialized "compact" signature (64 bytes). /// - public key: [Serialized according to SEC 2](https://www.oreilly.com/library/view/programming-bitcoin/9781492031482/ch04.html) -/// (33 or 65 bytes). +/// (33 or 65 bytes). pub fn secp256r1_verify( message_hash: &[u8], signature: &[u8], diff --git a/packages/crypto/tests/bls12_381.rs b/packages/crypto/tests/bls12_381.rs index 93ccf12060..623d9d5b67 100644 --- a/packages/crypto/tests/bls12_381.rs +++ b/packages/crypto/tests/bls12_381.rs @@ -1,14 +1,12 @@ -#![cfg(feature = "std")] - use std::{error::Error, fs}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use base64::engine::general_purpose::STANDARD; use base64_serde::base64_serde_type; +use cosmwasm_core::{BLS12_381_G1_GENERATOR, BLS12_381_G2_POINT_LEN}; use cosmwasm_crypto::{ bls12_381_aggregate_g1, bls12_381_aggregate_g2, bls12_381_g1_is_identity, bls12_381_g2_is_identity, bls12_381_hash_to_g2, bls12_381_pairing_equality, HashFunction, - BLS12_381_G1_GENERATOR, BLS12_381_G2_POINT_LEN, }; const PROOF_OF_POSSESSION_DST: &[u8] = b"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_"; diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 321fcfb546..daae6d70a1 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -12,14 +12,8 @@ readme = "README.md" features = ["abort", "stargate", "staking", "cosmwasm_2_1"] [features] -default = ["iterator", "abort"] +default = ["iterator", "abort", "std"] abort = [] -# LEGACY. REMOVE NEXT BREAKING RELEASE. -# -# This feature is unused. This library is not intended to run without the `std` library. -# Use `cosmwasm-core` instead if you *really* need a `no_std` environment. -# -# If you need any types exclusive to `cosmwasm-std` in a `no_std` environment, open an issue to discuss moving it to `cosmwasm-core`. std = [] # iterator allows us to iterate over all DB items in a given range # optional as some merkle stores (like tries) don't support this @@ -57,20 +51,21 @@ cosmwasm_2_1 = ["cosmwasm_2_0"] [dependencies] base64 = "0.22.0" +bnum = "0.11.0" +cosmwasm-core = { version = "2.0.1", path = "../core" } cosmwasm-derive = { version = "2.0.1", path = "../derive" } -cosmwasm-core = { path = "../core", version = "2.0.1", features = ["std"] } -cosmwasm-crypto = { version = "2.0.1", path = "../crypto" } derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["debug"] } hex = "0.4" schemars = { workspace = true } sha2 = "0.10.3" serde = { workspace = true, features = ["std"] } serde-json-wasm = { version = "1.0.1", default-features = false, features = ["std"] } +static_assertions = "1.1.0" thiserror = "1.0.26" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] bech32 = "0.11.0" -cosmwasm-crypto = { version = "2.0.1", path = "../crypto", features = ["std"] } +cosmwasm-crypto = { version = "2.0.1", path = "../crypto" } rand_core = { version = "0.6.4", features = ["getrandom"] } [dev-dependencies] diff --git a/packages/core/src/__internal.rs b/packages/std/src/__internal.rs similarity index 100% rename from packages/core/src/__internal.rs rename to packages/std/src/__internal.rs diff --git a/packages/core/src/addresses.rs b/packages/std/src/addresses.rs similarity index 98% rename from packages/core/src/addresses.rs rename to packages/std/src/addresses.rs index c4e18e98aa..d23c5b1aa3 100644 --- a/packages/core/src/addresses.rs +++ b/packages/std/src/addresses.rs @@ -8,7 +8,7 @@ use sha2::{ }; use crate::Binary; -use crate::{forward_ref_partial_eq, HexBinary}; +use crate::{HexBinary, __internal::forward_ref_partial_eq}; /// A human readable address. /// @@ -26,8 +26,9 @@ use crate::{forward_ref_partial_eq, HexBinary}; /// This type is immutable. If you really need to mutate it (Really? Are you sure?), create /// a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` /// instance. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, schemars::JsonSchema, +)] pub struct Addr(String); forward_ref_partial_eq!(Addr, Addr); @@ -127,8 +128,7 @@ impl<'a> From<&'a Addr> for Cow<'a, Addr> { /// addition to that there are many unsafe ways to convert any binary data into an instance. /// So the type should be treated as a marker to express the intended data type, not as /// a validity guarantee of any sort. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash, schemars::JsonSchema)] pub struct CanonicalAddr(Binary); /// Implement `CanonicalAddr == Binary` @@ -249,8 +249,7 @@ impl fmt::Display for CanonicalAddr { } } -#[derive(Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] pub enum Instantiate2AddressError { /// Checksum must be 32 bytes InvalidChecksumLength, diff --git a/packages/core/src/binary.rs b/packages/std/src/binary.rs similarity index 96% rename from packages/core/src/binary.rs rename to packages/std/src/binary.rs index 7564916240..72dfd6cc64 100644 --- a/packages/core/src/binary.rs +++ b/packages/std/src/binary.rs @@ -6,7 +6,7 @@ use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::{ encoding::{from_base64, to_base64}, - errors::{CoreError, CoreResult}, + errors::{StdError, StdResult}, }; /// Binary is a wrapper around Vec to add base64 de/serialization @@ -14,9 +14,8 @@ use crate::{ /// /// This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. /// See also . -#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Binary(#[cfg_attr(feature = "std", schemars(with = "String"))] Vec); +#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Binary(#[schemars(with = "String")] Vec); impl Binary { /// Creates a new `Binary` containing the given data. @@ -26,7 +25,7 @@ impl Binary { /// take an (untrusted) string and decode it into bytes. /// fails if it is not valid base64 - pub fn from_base64(encoded: &str) -> CoreResult { + pub fn from_base64(encoded: &str) -> StdResult { from_base64(encoded).map(Self::new) } @@ -61,9 +60,9 @@ impl Binary { /// let num = u64::from_be_bytes(binary.to_array().unwrap()); /// assert_eq!(num, 10045108015024774967); /// ``` - pub fn to_array(&self) -> CoreResult<[u8; LENGTH]> { + pub fn to_array(&self) -> StdResult<[u8; LENGTH]> { if self.len() != LENGTH { - return Err(CoreError::invalid_data_size(LENGTH, self.len())); + return Err(StdError::invalid_data_size(LENGTH, self.len())); } let mut out: [u8; LENGTH] = [0; LENGTH]; @@ -255,7 +254,7 @@ impl<'de> de::Visitor<'de> for Base64Visitor { mod tests { use super::*; use crate::assert_hash_works; - use crate::errors::CoreError; + use crate::errors::StdError; #[test] fn to_array_works() { @@ -273,7 +272,7 @@ mod tests { let binary = Binary::from(&[1, 2, 3]); let error = binary.to_array::<8>().unwrap_err(); match error { - CoreError::InvalidDataSize { + StdError::InvalidDataSize { expected, actual, .. } => { assert_eq!(expected, 8); @@ -332,7 +331,7 @@ mod tests { ("cmFuZ", "Invalid input length: 5"), ] { match Binary::from_base64(invalid_base64) { - Err(CoreError::InvalidBase64 { msg, .. }) => assert_eq!(want, msg), + Err(StdError::InvalidBase64 { msg, .. }) => assert_eq!(want, msg), result => panic!("Unexpected result: {result:?}"), } } diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index 650e392729..54d41e0858 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -1,10 +1,10 @@ use core::{fmt, str::FromStr}; -use cosmwasm_core::Uint128; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::prelude::*; use crate::CoinFromStrError; +use crate::Uint128; #[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, JsonSchema)] pub struct Coin { diff --git a/packages/core/src/encoding.rs b/packages/std/src/encoding.rs similarity index 89% rename from packages/core/src/encoding.rs rename to packages/std/src/encoding.rs index 9a8e2a44a2..6b835b3c2d 100644 --- a/packages/core/src/encoding.rs +++ b/packages/std/src/encoding.rs @@ -1,7 +1,7 @@ use alloc::{string::String, vec::Vec}; use base64::{engine::GeneralPurpose, Engine}; -use crate::{CoreError, CoreResult}; +use crate::{StdError, StdResult}; /// Base64 encoding engine used in conversion to/from base64. /// @@ -14,11 +14,11 @@ const B64_ENGINE: GeneralPurpose = GeneralPurpose::new( ); /// Deserialize a bag of bytes from Base64 into a vector of bytes -pub fn from_base64(input: I) -> CoreResult> +pub fn from_base64(input: I) -> StdResult> where I: AsRef<[u8]>, { - B64_ENGINE.decode(input).map_err(CoreError::invalid_base64) + B64_ENGINE.decode(input).map_err(StdError::invalid_base64) } /// Encode a bag of bytes into the Base64 format @@ -30,11 +30,11 @@ where } /// Decode a bag of bytes from hex into a vector of bytes -pub fn from_hex(input: I) -> CoreResult> +pub fn from_hex(input: I) -> StdResult> where I: AsRef<[u8]>, { - hex::decode(input).map_err(CoreError::invalid_hex) + hex::decode(input).map_err(StdError::invalid_hex) } /// Encode a bag of bytes into the hex format diff --git a/packages/core/src/errors/backtrace.rs b/packages/std/src/errors/backtrace.rs similarity index 100% rename from packages/core/src/errors/backtrace.rs rename to packages/std/src/errors/backtrace.rs diff --git a/packages/core/src/errors/mod.rs b/packages/std/src/errors/mod.rs similarity index 61% rename from packages/core/src/errors/mod.rs rename to packages/std/src/errors/mod.rs index 6c10d5f80a..768af1d633 100644 --- a/packages/core/src/errors/mod.rs +++ b/packages/std/src/errors/mod.rs @@ -1,16 +1,16 @@ mod backtrace; -mod core_error; mod recover_pubkey_error; +mod std_error; mod system_error; mod verification_error; pub(crate) use backtrace::{impl_from_err, BT}; -pub use core_error::{ +pub use recover_pubkey_error::RecoverPubkeyError; +pub use std_error::{ CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, - CoinFromStrError, CoinsError, ConversionOverflowError, CoreError, CoreResult, - DivideByZeroError, DivisionError, OverflowError, OverflowOperation, RoundDownOverflowError, - RoundUpOverflowError, + CoinFromStrError, CoinsError, ConversionOverflowError, DivideByZeroError, DivisionError, + OverflowError, OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, StdError, + StdResult, }; -pub use recover_pubkey_error::RecoverPubkeyError; pub use system_error::SystemError; pub use verification_error::{AggregationError, PairingEqualityError, VerificationError}; diff --git a/packages/core/src/errors/recover_pubkey_error.rs b/packages/std/src/errors/recover_pubkey_error.rs similarity index 88% rename from packages/core/src/errors/recover_pubkey_error.rs rename to packages/std/src/errors/recover_pubkey_error.rs index 6bf97e6d95..f473b091f1 100644 --- a/packages/core/src/errors/recover_pubkey_error.rs +++ b/packages/std/src/errors/recover_pubkey_error.rs @@ -1,20 +1,18 @@ use core::fmt::Debug; #[cfg(not(target_arch = "wasm32"))] use cosmwasm_crypto::CryptoError; -use derive_more::Display; use super::BT; -#[derive(Display, Debug)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, thiserror::Error)] pub enum RecoverPubkeyError { - #[display("Invalid hash format")] + #[error("Invalid hash format")] InvalidHashFormat, - #[display("Invalid signature format")] + #[error("Invalid signature format")] InvalidSignatureFormat, - #[display("Invalid recovery parameter. Supported values: 0 and 1.")] + #[error("Invalid recovery parameter. Supported values: 0 and 1.")] InvalidRecoveryParam, - #[display("Unknown error: {error_code}")] + #[error("Unknown error: {error_code}")] UnknownErr { error_code: u32, backtrace: BT }, } diff --git a/packages/core/src/errors/core_error.rs b/packages/std/src/errors/std_error.rs similarity index 68% rename from packages/core/src/errors/core_error.rs rename to packages/std/src/errors/std_error.rs index 39fefad28e..7c922e3b68 100644 --- a/packages/core/src/errors/core_error.rs +++ b/packages/std/src/errors/std_error.rs @@ -1,6 +1,5 @@ use alloc::string::{String, ToString}; use core::fmt; -use derive_more::{Display, From}; use super::{impl_from_err, BT}; @@ -21,62 +20,61 @@ use crate::errors::{RecoverPubkeyError, VerificationError}; /// Checklist for adding a new error: /// - Add enum case /// - Add creator function in std_error_helpers.rs -#[derive(Display, Debug)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -pub enum CoreError { - #[display("Verification error: {source}")] +#[derive(Debug, thiserror::Error)] +pub enum StdError { + #[error("Verification error: {source}")] VerificationErr { source: VerificationError, backtrace: BT, }, - #[display("Recover pubkey error: {source}")] + #[error("Recover pubkey error: {source}")] RecoverPubkeyErr { source: RecoverPubkeyError, backtrace: BT, }, /// Whenever there is no specific error type available - #[display("Generic error: {msg}")] + #[error("Generic error: {msg}")] GenericErr { msg: String, backtrace: BT }, - #[display("Invalid Base64 string: {msg}")] + #[error("Invalid Base64 string: {msg}")] InvalidBase64 { msg: String, backtrace: BT }, - #[display("Invalid data size: expected={expected} actual={actual}")] + #[error("Invalid data size: expected={expected} actual={actual}")] InvalidDataSize { expected: u64, actual: u64, backtrace: BT, }, - #[display("Invalid hex string: {msg}")] + #[error("Invalid hex string: {msg}")] InvalidHex { msg: String, backtrace: BT }, /// Whenever UTF-8 bytes cannot be decoded into a unicode string, e.g. in String::from_utf8 or str::from_utf8. - #[display("Cannot decode UTF8 bytes into string: {msg}")] + #[error("Cannot decode UTF8 bytes into string: {msg}")] InvalidUtf8 { msg: String, backtrace: BT }, - #[display("{kind} not found")] + #[error("{kind} not found")] NotFound { kind: String, backtrace: BT }, - #[display("Error parsing into type {target_type}: {msg}")] + #[error("Error parsing into type {target_type}: {msg}")] ParseErr { /// the target type that was attempted target_type: String, msg: String, backtrace: BT, }, - #[display("Error serializing type {source_type}: {msg}")] + #[error("Error serializing type {source_type}: {msg}")] SerializeErr { /// the source type that was attempted source_type: String, msg: String, backtrace: BT, }, - #[display("Overflow: {source}")] + #[error("Overflow: {source}")] Overflow { source: OverflowError, backtrace: BT, }, - #[display("Divide by zero: {source}")] + #[error("Divide by zero: {source}")] DivideByZero { source: DivideByZeroError, backtrace: BT, }, - #[display("Conversion error: ")] + #[error("Conversion error: ")] ConversionOverflow { source: ConversionOverflowError, backtrace: BT, @@ -85,41 +83,41 @@ pub enum CoreError { impl_from_err!( ConversionOverflowError, - CoreError, - CoreError::ConversionOverflow + StdError, + StdError::ConversionOverflow ); -impl CoreError { +impl StdError { pub fn verification_err(source: VerificationError) -> Self { - CoreError::VerificationErr { + StdError::VerificationErr { source, backtrace: BT::capture(), } } pub fn recover_pubkey_err(source: RecoverPubkeyError) -> Self { - CoreError::RecoverPubkeyErr { + StdError::RecoverPubkeyErr { source, backtrace: BT::capture(), } } pub fn generic_err(msg: impl Into) -> Self { - CoreError::GenericErr { + StdError::GenericErr { msg: msg.into(), backtrace: BT::capture(), } } pub fn invalid_base64(msg: impl ToString) -> Self { - CoreError::InvalidBase64 { + StdError::InvalidBase64 { msg: msg.to_string(), backtrace: BT::capture(), } } pub fn invalid_data_size(expected: usize, actual: usize) -> Self { - CoreError::InvalidDataSize { + StdError::InvalidDataSize { // Cast is safe because usize is 32 or 64 bit large in all environments we support expected: expected as u64, actual: actual as u64, @@ -128,28 +126,28 @@ impl CoreError { } pub fn invalid_hex(msg: impl ToString) -> Self { - CoreError::InvalidHex { + StdError::InvalidHex { msg: msg.to_string(), backtrace: BT::capture(), } } pub fn invalid_utf8(msg: impl ToString) -> Self { - CoreError::InvalidUtf8 { + StdError::InvalidUtf8 { msg: msg.to_string(), backtrace: BT::capture(), } } pub fn not_found(kind: impl Into) -> Self { - CoreError::NotFound { + StdError::NotFound { kind: kind.into(), backtrace: BT::capture(), } } pub fn parse_err(target: impl Into, msg: impl ToString) -> Self { - CoreError::ParseErr { + StdError::ParseErr { target_type: target.into(), msg: msg.to_string(), backtrace: BT::capture(), @@ -157,7 +155,7 @@ impl CoreError { } pub fn serialize_err(source: impl Into, msg: impl ToString) -> Self { - CoreError::SerializeErr { + StdError::SerializeErr { source_type: source.into(), msg: msg.to_string(), backtrace: BT::capture(), @@ -165,28 +163,28 @@ impl CoreError { } pub fn overflow(source: OverflowError) -> Self { - CoreError::Overflow { + StdError::Overflow { source, backtrace: BT::capture(), } } pub fn divide_by_zero(source: DivideByZeroError) -> Self { - CoreError::DivideByZero { + StdError::DivideByZero { source, backtrace: BT::capture(), } } } -impl PartialEq for CoreError { - fn eq(&self, rhs: &CoreError) -> bool { +impl PartialEq for StdError { + fn eq(&self, rhs: &StdError) -> bool { match self { - CoreError::VerificationErr { + StdError::VerificationErr { source, backtrace: _, } => { - if let CoreError::VerificationErr { + if let StdError::VerificationErr { source: rhs_source, backtrace: _, } = rhs @@ -196,11 +194,11 @@ impl PartialEq for CoreError { false } } - CoreError::RecoverPubkeyErr { + StdError::RecoverPubkeyErr { source, backtrace: _, } => { - if let CoreError::RecoverPubkeyErr { + if let StdError::RecoverPubkeyErr { source: rhs_source, backtrace: _, } = rhs @@ -210,8 +208,8 @@ impl PartialEq for CoreError { false } } - CoreError::GenericErr { msg, backtrace: _ } => { - if let CoreError::GenericErr { + StdError::GenericErr { msg, backtrace: _ } => { + if let StdError::GenericErr { msg: rhs_msg, backtrace: _, } = rhs @@ -221,8 +219,8 @@ impl PartialEq for CoreError { false } } - CoreError::InvalidBase64 { msg, backtrace: _ } => { - if let CoreError::InvalidBase64 { + StdError::InvalidBase64 { msg, backtrace: _ } => { + if let StdError::InvalidBase64 { msg: rhs_msg, backtrace: _, } = rhs @@ -232,12 +230,12 @@ impl PartialEq for CoreError { false } } - CoreError::InvalidDataSize { + StdError::InvalidDataSize { expected, actual, backtrace: _, } => { - if let CoreError::InvalidDataSize { + if let StdError::InvalidDataSize { expected: rhs_expected, actual: rhs_actual, backtrace: _, @@ -248,8 +246,8 @@ impl PartialEq for CoreError { false } } - CoreError::InvalidHex { msg, backtrace: _ } => { - if let CoreError::InvalidHex { + StdError::InvalidHex { msg, backtrace: _ } => { + if let StdError::InvalidHex { msg: rhs_msg, backtrace: _, } = rhs @@ -259,8 +257,8 @@ impl PartialEq for CoreError { false } } - CoreError::InvalidUtf8 { msg, backtrace: _ } => { - if let CoreError::InvalidUtf8 { + StdError::InvalidUtf8 { msg, backtrace: _ } => { + if let StdError::InvalidUtf8 { msg: rhs_msg, backtrace: _, } = rhs @@ -270,8 +268,8 @@ impl PartialEq for CoreError { false } } - CoreError::NotFound { kind, backtrace: _ } => { - if let CoreError::NotFound { + StdError::NotFound { kind, backtrace: _ } => { + if let StdError::NotFound { kind: rhs_kind, backtrace: _, } = rhs @@ -281,12 +279,12 @@ impl PartialEq for CoreError { false } } - CoreError::ParseErr { + StdError::ParseErr { target_type, msg, backtrace: _, } => { - if let CoreError::ParseErr { + if let StdError::ParseErr { target_type: rhs_target_type, msg: rhs_msg, backtrace: _, @@ -297,12 +295,12 @@ impl PartialEq for CoreError { false } } - CoreError::SerializeErr { + StdError::SerializeErr { source_type, msg, backtrace: _, } => { - if let CoreError::SerializeErr { + if let StdError::SerializeErr { source_type: rhs_source_type, msg: rhs_msg, backtrace: _, @@ -313,11 +311,11 @@ impl PartialEq for CoreError { false } } - CoreError::Overflow { + StdError::Overflow { source, backtrace: _, } => { - if let CoreError::Overflow { + if let StdError::Overflow { source: rhs_source, backtrace: _, } = rhs @@ -327,11 +325,11 @@ impl PartialEq for CoreError { false } } - CoreError::DivideByZero { + StdError::DivideByZero { source, backtrace: _, } => { - if let CoreError::DivideByZero { + if let StdError::DivideByZero { source: rhs_source, backtrace: _, } = rhs @@ -341,11 +339,11 @@ impl PartialEq for CoreError { false } } - CoreError::ConversionOverflow { + StdError::ConversionOverflow { source, backtrace: _, } => { - if let CoreError::ConversionOverflow { + if let StdError::ConversionOverflow { source: rhs_source, backtrace: _, } = rhs @@ -359,37 +357,37 @@ impl PartialEq for CoreError { } } -impl From for CoreError { +impl From for StdError { fn from(source: core::str::Utf8Error) -> Self { Self::invalid_utf8(source) } } -impl From for CoreError { +impl From for StdError { fn from(source: alloc::string::FromUtf8Error) -> Self { Self::invalid_utf8(source) } } -impl From for CoreError { +impl From for StdError { fn from(source: VerificationError) -> Self { Self::verification_err(source) } } -impl From for CoreError { +impl From for StdError { fn from(source: RecoverPubkeyError) -> Self { Self::recover_pubkey_err(source) } } -impl From for CoreError { +impl From for StdError { fn from(source: OverflowError) -> Self { Self::overflow(source) } } -impl From for CoreError { +impl From for StdError { fn from(source: DivideByZeroError) -> Self { Self::divide_by_zero(source) } @@ -400,7 +398,7 @@ impl From for CoreError { /// /// The prefix "Core"/"Std" means "the standard result within the core/standard library". This is not the only /// result/error type in cosmwasm-core/cosmwasm-std. -pub type CoreResult = core::result::Result; +pub type StdResult = core::result::Result; #[derive(Debug, PartialEq, Eq)] pub enum OverflowOperation { @@ -418,9 +416,8 @@ impl fmt::Display for OverflowOperation { } } -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -#[display("Cannot {operation} with given operands")] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] +#[error("Cannot {operation} with given operands")] pub struct OverflowError { pub operation: OverflowOperation, } @@ -437,9 +434,8 @@ impl OverflowError { /// [`TryFrom`]: core::convert::TryFrom /// [`Uint256`]: crate::Uint256 /// [`Uint128`]: crate::Uint128 -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -#[display("Error converting {source_type} to {target_type}")] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] +#[error("Error converting {source_type} to {target_type}")] pub struct ConversionOverflowError { pub source_type: &'static str, pub target_type: &'static str, @@ -454,9 +450,8 @@ impl ConversionOverflowError { } } -#[derive(Display, Debug, Default, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -#[display("Cannot divide by zero")] +#[derive(Debug, Default, PartialEq, Eq, thiserror::Error)] +#[error("Cannot divide by zero")] pub struct DivideByZeroError; impl DivideByZeroError { @@ -465,81 +460,72 @@ impl DivideByZeroError { } } -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] pub enum DivisionError { - #[display("Divide by zero")] + #[error("Divide by zero")] DivideByZero, - #[display("Overflow in division")] + #[error("Overflow in division")] Overflow, } -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -#[cfg_attr(not(feature = "std"), derive(From))] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] pub enum CheckedMultiplyFractionError { - #[display("{_0}")] + #[error("{_0}")] DivideByZero(#[from] DivideByZeroError), - #[display("{_0}")] + #[error("{_0}")] ConversionOverflow(#[from] ConversionOverflowError), - #[display("{_0}")] + #[error("{_0}")] Overflow(#[from] OverflowError), } -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] pub enum CheckedMultiplyRatioError { - #[display("Denominator must not be zero")] + #[error("Denominator must not be zero")] DivideByZero, - #[display("Multiplication overflow")] + #[error("Multiplication overflow")] Overflow, } -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] pub enum CheckedFromRatioError { - #[display("Denominator must not be zero")] + #[error("Denominator must not be zero")] DivideByZero, - #[display("Overflow")] + #[error("Overflow")] Overflow, } -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -#[display("Round up operation failed because of overflow")] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] +#[error("Round up operation failed because of overflow")] pub struct RoundUpOverflowError; -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -#[display("Round down operation failed because of overflow")] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] +#[error("Round down operation failed because of overflow")] pub struct RoundDownOverflowError; -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] pub enum CoinsError { - #[display("Duplicate denom")] + #[error("Duplicate denom")] DuplicateDenom, } -impl From for CoreError { +impl From for StdError { fn from(value: CoinsError) -> Self { Self::generic_err(format!("Creating Coins: {value}")) } } -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] pub enum CoinFromStrError { - #[display("Missing denominator")] + #[error("Missing denominator")] MissingDenom, - #[display("Missing amount or non-digit characters in amount")] + #[error("Missing amount or non-digit characters in amount")] MissingAmount, - #[display("Invalid amount: {_0}")] + #[error("Invalid amount: {_0}")] InvalidAmount(core::num::ParseIntError), } @@ -549,7 +535,7 @@ impl From for CoinFromStrError { } } -impl From for CoreError { +impl From for StdError { fn from(value: CoinFromStrError) -> Self { Self::generic_err(format!("Parsing Coin: {value}")) } @@ -566,9 +552,9 @@ mod tests { #[test] fn generic_err_owned() { let guess = 7; - let error = CoreError::generic_err(format!("{guess} is too low")); + let error = StdError::generic_err(format!("{guess} is too low")); match error { - CoreError::GenericErr { msg, .. } => { + StdError::GenericErr { msg, .. } => { assert_eq!(msg, String::from("7 is too low")); } e => panic!("unexpected error, {e:?}"), @@ -578,18 +564,18 @@ mod tests { // example of reporting static contract errors #[test] fn generic_err_ref() { - let error = CoreError::generic_err("not implemented"); + let error = StdError::generic_err("not implemented"); match error { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "not implemented"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "not implemented"), e => panic!("unexpected error, {e:?}"), } } #[test] fn invalid_base64_works_for_strings() { - let error = CoreError::invalid_base64("my text"); + let error = StdError::invalid_base64("my text"); match error { - CoreError::InvalidBase64 { msg, .. } => { + StdError::InvalidBase64 { msg, .. } => { assert_eq!(msg, "my text"); } _ => panic!("expect different error"), @@ -599,9 +585,9 @@ mod tests { #[test] fn invalid_base64_works_for_errors() { let original = base64::DecodeError::InvalidLength(10); - let error = CoreError::invalid_base64(original); + let error = StdError::invalid_base64(original); match error { - CoreError::InvalidBase64 { msg, .. } => { + StdError::InvalidBase64 { msg, .. } => { assert_eq!(msg, "Invalid input length: 10"); } _ => panic!("expect different error"), @@ -610,9 +596,9 @@ mod tests { #[test] fn invalid_data_size_works() { - let error = CoreError::invalid_data_size(31, 14); + let error = StdError::invalid_data_size(31, 14); match error { - CoreError::InvalidDataSize { + StdError::InvalidDataSize { expected, actual, .. } => { assert_eq!(expected, 31); @@ -624,9 +610,9 @@ mod tests { #[test] fn invalid_hex_works_for_strings() { - let error = CoreError::invalid_hex("my text"); + let error = StdError::invalid_hex("my text"); match error { - CoreError::InvalidHex { msg, .. } => { + StdError::InvalidHex { msg, .. } => { assert_eq!(msg, "my text"); } _ => panic!("expect different error"), @@ -636,9 +622,9 @@ mod tests { #[test] fn invalid_hex_works_for_errors() { let original = hex::FromHexError::OddLength; - let error = CoreError::invalid_hex(original); + let error = StdError::invalid_hex(original); match error { - CoreError::InvalidHex { msg, .. } => { + StdError::InvalidHex { msg, .. } => { assert_eq!(msg, "Odd number of digits"); } _ => panic!("expect different error"), @@ -647,9 +633,9 @@ mod tests { #[test] fn invalid_utf8_works_for_strings() { - let error = CoreError::invalid_utf8("my text"); + let error = StdError::invalid_utf8("my text"); match error { - CoreError::InvalidUtf8 { msg, .. } => { + StdError::InvalidUtf8 { msg, .. } => { assert_eq!(msg, "my text"); } _ => panic!("expect different error"), @@ -659,9 +645,9 @@ mod tests { #[test] fn invalid_utf8_works_for_errors() { let original = String::from_utf8(vec![0x80]).unwrap_err(); - let error = CoreError::invalid_utf8(original); + let error = StdError::invalid_utf8(original); match error { - CoreError::InvalidUtf8 { msg, .. } => { + StdError::InvalidUtf8 { msg, .. } => { assert_eq!(msg, "invalid utf-8 sequence of 1 bytes from index 0"); } _ => panic!("expect different error"), @@ -670,18 +656,18 @@ mod tests { #[test] fn not_found_works() { - let error = CoreError::not_found("gold"); + let error = StdError::not_found("gold"); match error { - CoreError::NotFound { kind, .. } => assert_eq!(kind, "gold"), + StdError::NotFound { kind, .. } => assert_eq!(kind, "gold"), _ => panic!("expect different error"), } } #[test] fn parse_err_works() { - let error = CoreError::parse_err("Book", "Missing field: title"); + let error = StdError::parse_err("Book", "Missing field: title"); match error { - CoreError::ParseErr { + StdError::ParseErr { target_type, msg, .. } => { assert_eq!(target_type, "Book"); @@ -693,9 +679,9 @@ mod tests { #[test] fn serialize_err_works() { - let error = CoreError::serialize_err("Book", "Content too long"); + let error = StdError::serialize_err("Book", "Content too long"); match error { - CoreError::SerializeErr { + StdError::SerializeErr { source_type, msg, .. } => { assert_eq!(source_type, "Book"); @@ -707,10 +693,10 @@ mod tests { #[test] fn underflow_works_for_u128() { - let error = CoreError::overflow(OverflowError::new(OverflowOperation::Sub)); + let error = StdError::overflow(OverflowError::new(OverflowOperation::Sub)); assert!(matches!( error, - CoreError::Overflow { + StdError::Overflow { source: OverflowError { operation: OverflowOperation::Sub }, @@ -721,10 +707,10 @@ mod tests { #[test] fn overflow_works_for_i64() { - let error = CoreError::overflow(OverflowError::new(OverflowOperation::Sub)); + let error = StdError::overflow(OverflowError::new(OverflowOperation::Sub)); assert!(matches!( error, - CoreError::Overflow { + StdError::Overflow { source: OverflowError { operation: OverflowOperation::Sub }, @@ -735,10 +721,10 @@ mod tests { #[test] fn divide_by_zero_works() { - let error = CoreError::divide_by_zero(DivideByZeroError); + let error = StdError::divide_by_zero(DivideByZeroError); assert!(matches!( error, - CoreError::DivideByZero { + StdError::DivideByZero { source: DivideByZeroError, .. } @@ -747,7 +733,7 @@ mod tests { #[test] fn implements_debug() { - let error: CoreError = CoreError::from(OverflowError::new(OverflowOperation::Sub)); + let error: StdError = StdError::from(OverflowError::new(OverflowOperation::Sub)); let embedded = format!("Debug: {error:?}"); let expected = r#"Debug: Overflow { source: OverflowError { operation: Sub }, backtrace: }"#; assert_eq!(embedded, expected); @@ -755,7 +741,7 @@ mod tests { #[test] fn implements_display() { - let error: CoreError = CoreError::from(OverflowError::new(OverflowOperation::Sub)); + let error: StdError = StdError::from(OverflowError::new(OverflowOperation::Sub)); let embedded = format!("Display: {error}"); assert_eq!( embedded, @@ -765,11 +751,11 @@ mod tests { #[test] fn implements_partial_eq() { - let u1 = CoreError::from(OverflowError::new(OverflowOperation::Sub)); - let u2 = CoreError::from(OverflowError::new(OverflowOperation::Sub)); - let s1 = CoreError::serialize_err("Book", "Content too long"); - let s2 = CoreError::serialize_err("Book", "Content too long"); - let s3 = CoreError::serialize_err("Book", "Title too long"); + let u1 = StdError::from(OverflowError::new(OverflowOperation::Sub)); + let u2 = StdError::from(OverflowError::new(OverflowOperation::Sub)); + let s1 = StdError::serialize_err("Book", "Content too long"); + let s2 = StdError::serialize_err("Book", "Content too long"); + let s3 = StdError::serialize_err("Book", "Title too long"); assert_eq!(u1, u2); assert_ne!(u1, s1); assert_eq!(s1, s2); @@ -779,9 +765,9 @@ mod tests { #[test] fn from_std_str_utf8error_works() { let broken = Vec::from(b"Hello \xF0\x90\x80World" as &[u8]); - let error: CoreError = str::from_utf8(&broken).unwrap_err().into(); + let error: StdError = str::from_utf8(&broken).unwrap_err().into(); match error { - CoreError::InvalidUtf8 { msg, .. } => { + StdError::InvalidUtf8 { msg, .. } => { assert_eq!(msg, "invalid utf-8 sequence of 3 bytes from index 6") } err => panic!("Unexpected error: {err:?}"), @@ -790,11 +776,11 @@ mod tests { #[test] fn from_std_string_from_utf8error_works() { - let error: CoreError = String::from_utf8(b"Hello \xF0\x90\x80World".to_vec()) + let error: StdError = String::from_utf8(b"Hello \xF0\x90\x80World".to_vec()) .unwrap_err() .into(); match error { - CoreError::InvalidUtf8 { msg, .. } => { + StdError::InvalidUtf8 { msg, .. } => { assert_eq!(msg, "invalid utf-8 sequence of 3 bytes from index 6") } err => panic!("Unexpected error: {err:?}"), diff --git a/packages/core/src/errors/system_error.rs b/packages/std/src/errors/system_error.rs similarity index 96% rename from packages/core/src/errors/system_error.rs rename to packages/std/src/errors/system_error.rs index b146233da2..ea9052e4d7 100644 --- a/packages/core/src/errors/system_error.rs +++ b/packages/std/src/errors/system_error.rs @@ -12,8 +12,9 @@ use crate::Binary; /// /// Such errors are only created by the VM. The error type is defined in the standard library, to ensure /// the contract understands the error format without creating a dependency on cosmwasm-vm. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema, thiserror::Error))] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, schemars::JsonSchema, thiserror::Error, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub enum SystemError { diff --git a/packages/core/src/errors/verification_error.rs b/packages/std/src/errors/verification_error.rs similarity index 83% rename from packages/core/src/errors/verification_error.rs rename to packages/std/src/errors/verification_error.rs index 3d9120ddd1..3beafb9607 100644 --- a/packages/core/src/errors/verification_error.rs +++ b/packages/std/src/errors/verification_error.rs @@ -1,55 +1,51 @@ use core::fmt::Debug; -use derive_more::Display; use super::BT; #[cfg(not(target_arch = "wasm32"))] use cosmwasm_crypto::CryptoError; -#[derive(Display, Debug, PartialEq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, PartialEq, thiserror::Error)] pub enum AggregationError { - #[display("List of points is empty")] + #[error("List of points is empty")] Empty, - #[display("List is not an expected multiple")] + #[error("List is not an expected multiple")] NotMultiple, } -#[derive(Display, Debug, PartialEq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, PartialEq, thiserror::Error)] pub enum PairingEqualityError { - #[display("List is not a multiple of 48")] + #[error("List is not a multiple of 48")] NotMultipleG1, - #[display("List is not a multiple of 96")] + #[error("List is not a multiple of 96")] NotMultipleG2, - #[display("Not the same amount of points passed")] + #[error("Not the same amount of points passed")] UnequalPointAmount, } -#[derive(Display, Debug)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] +#[derive(Debug, thiserror::Error)] pub enum VerificationError { - #[display("Aggregation error: {source}")] + #[error("Aggregation error: {source}")] Aggregation { source: AggregationError }, - #[display("Batch error")] + #[error("Batch error")] BatchErr, - #[display("Generic error")] + #[error("Generic error")] GenericErr, - #[display("Invalid hash format")] + #[error("Invalid hash format")] InvalidHashFormat, - #[display("Invalid signature format")] + #[error("Invalid signature format")] InvalidSignatureFormat, - #[display("Invalid public key format")] + #[error("Invalid public key format")] InvalidPubkeyFormat, - #[display("Invalid recovery parameter. Supported values: 0 and 1.")] + #[error("Invalid recovery parameter. Supported values: 0 and 1.")] InvalidRecoveryParam, - #[display("Invalid point")] + #[error("Invalid point")] InvalidPoint, - #[display("Unknown hash function")] + #[error("Unknown hash function")] UnknownHashFunction, - #[display("Aggregation pairing equality error: {source}")] + #[error("Aggregation pairing equality error: {source}")] PairingEquality { source: PairingEqualityError }, - #[display("Unknown error: {error_code}")] + #[error("Unknown error: {error_code}")] UnknownErr { error_code: u32, backtrace: BT }, } diff --git a/packages/core/src/forward_ref.rs b/packages/std/src/forward_ref.rs similarity index 100% rename from packages/core/src/forward_ref.rs rename to packages/std/src/forward_ref.rs diff --git a/packages/core/src/hex_binary.rs b/packages/std/src/hex_binary.rs similarity index 95% rename from packages/core/src/hex_binary.rs rename to packages/std/src/hex_binary.rs index bce0df2179..e2168942c7 100644 --- a/packages/core/src/hex_binary.rs +++ b/packages/std/src/hex_binary.rs @@ -6,7 +6,7 @@ use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::{ encoding::{from_hex, to_hex}, - Binary, CoreError, CoreResult, + Binary, StdError, StdResult, }; /// This is a wrapper around Vec to add hex de/serialization @@ -14,12 +14,11 @@ use crate::{ /// /// This is similar to `cosmwasm_std::Binary` but uses hex. /// See also . -#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct HexBinary(#[cfg_attr(feature = "std", schemars(with = "String"))] Vec); +#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord, schemars::JsonSchema)] +pub struct HexBinary(#[schemars(with = "String")] Vec); impl HexBinary { - pub fn from_hex(input: &str) -> CoreResult { + pub fn from_hex(input: &str) -> StdResult { from_hex(input).map(Self) } @@ -52,9 +51,9 @@ impl HexBinary { /// let num = u64::from_be_bytes(data.to_array().unwrap()); /// assert_eq!(num, 10045108015024774967); /// ``` - pub fn to_array(&self) -> CoreResult<[u8; LENGTH]> { + pub fn to_array(&self) -> StdResult<[u8; LENGTH]> { if self.len() != LENGTH { - return Err(CoreError::invalid_data_size(LENGTH, self.len())); + return Err(StdError::invalid_data_size(LENGTH, self.len())); } let mut out: [u8; LENGTH] = [0; LENGTH]; @@ -258,7 +257,7 @@ impl<'de> de::Visitor<'de> for HexVisitor { mod tests { use super::*; - use crate::{assert_hash_works, CoreError}; + use crate::{assert_hash_works, StdError}; #[test] fn from_hex_works() { @@ -278,21 +277,21 @@ mod tests { // odd match HexBinary::from_hex("123").unwrap_err() { - CoreError::InvalidHex { msg, .. } => { + StdError::InvalidHex { msg, .. } => { assert_eq!(msg, "Odd number of digits") } _ => panic!("Unexpected error type"), } // non-hex match HexBinary::from_hex("efgh").unwrap_err() { - CoreError::InvalidHex { msg, .. } => { + StdError::InvalidHex { msg, .. } => { assert_eq!(msg, "Invalid character 'g' at position 2") } _ => panic!("Unexpected error type"), } // 0x prefixed match HexBinary::from_hex("0xaa").unwrap_err() { - CoreError::InvalidHex { msg, .. } => { + StdError::InvalidHex { msg, .. } => { assert_eq!(msg, "Invalid character 'x' at position 1") } _ => panic!("Unexpected error type"), @@ -300,19 +299,19 @@ mod tests { // spaces assert!(matches!( HexBinary::from_hex("aa ").unwrap_err(), - CoreError::InvalidHex { .. } + StdError::InvalidHex { .. } )); assert!(matches!( HexBinary::from_hex(" aa").unwrap_err(), - CoreError::InvalidHex { .. } + StdError::InvalidHex { .. } )); assert!(matches!( HexBinary::from_hex("a a").unwrap_err(), - CoreError::InvalidHex { .. } + StdError::InvalidHex { .. } )); assert!(matches!( HexBinary::from_hex(" aa ").unwrap_err(), - CoreError::InvalidHex { .. } + StdError::InvalidHex { .. } )); } @@ -347,7 +346,7 @@ mod tests { let binary = HexBinary::from(&[1, 2, 3]); let error = binary.to_array::<8>().unwrap_err(); match error { - CoreError::InvalidDataSize { + StdError::InvalidDataSize { expected, actual, .. } => { assert_eq!(expected, 8); diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index cec3b790d7..723d8ac668 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -2,7 +2,6 @@ // The rest of the IBC related functionality is defined here use core::cmp::{Ord, Ordering, PartialOrd}; -use cosmwasm_core::{Addr, Timestamp}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -11,6 +10,7 @@ use crate::prelude::*; use crate::results::{Attribute, CosmosMsg, Empty, Event, SubMsg}; use crate::StdResult; use crate::{to_json_binary, Binary}; +use crate::{Addr, Timestamp}; mod callbacks; pub use callbacks::*; diff --git a/packages/std/src/imports.rs b/packages/std/src/imports.rs index 6647585945..1ac223acdf 100644 --- a/packages/std/src/imports.rs +++ b/packages/std/src/imports.rs @@ -1,5 +1,4 @@ use alloc::vec::Vec; -use cosmwasm_core::{Addr, CanonicalAddr}; use crate::import_helpers::{from_high_half, from_low_half}; use crate::memory::{Owned, Region}; @@ -14,6 +13,7 @@ use crate::{ iterator::{Order, Record}, memory::get_optional_region_address, }; +use crate::{Addr, CanonicalAddr}; #[cfg(feature = "cosmwasm_2_1")] use crate::{AggregationError, HashFunction, PairingEqualityError}; use crate::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index d83774e750..496fbd3040 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -1,18 +1,33 @@ +#[cfg(not(feature = "std"))] +core::compile_error!( + r#"Please enable `cosmwasm-std`'s `std` feature, as we might move existing functionality to that feature in the future. +Builds without the std feature are currently not expected to work. If you need no_std support see #1484. +"# +); + #[macro_use] extern crate alloc; // Exposed on all platforms +mod __internal; +mod addresses; mod assertions; +mod binary; mod checksum; mod coin; mod coins; mod conversion; mod deps; +mod encoding; +mod errors; +mod forward_ref; +mod hex_binary; mod ibc; mod import_helpers; #[cfg(feature = "iterator")] mod iterator; +mod math; mod metadata; mod never; mod pagination; @@ -23,6 +38,7 @@ mod sections; mod serde; mod stdack; mod storage; +mod timestamp; mod traits; mod types; @@ -34,10 +50,21 @@ pub(crate) mod prelude; /// contract devs to use it directly. pub mod storage_keys; +pub use crate::addresses::{instantiate2_address, Addr, CanonicalAddr, Instantiate2AddressError}; +pub use crate::binary::Binary; pub use crate::checksum::{Checksum, ChecksumError}; pub use crate::coin::{coin, coins, has_coins, Coin}; pub use crate::coins::Coins; pub use crate::deps::{Deps, DepsMut, OwnedDeps}; +pub use crate::encoding::{from_base64, from_hex, to_base64, to_hex}; +pub use crate::errors::{ + AggregationError, CheckedFromRatioError, CheckedMultiplyFractionError, + CheckedMultiplyRatioError, CoinFromStrError, CoinsError, ConversionOverflowError, + DivideByZeroError, DivisionError, OverflowError, OverflowOperation, PairingEqualityError, + RecoverPubkeyError, RoundDownOverflowError, RoundUpOverflowError, StdError, StdResult, + SystemError, VerificationError, +}; +pub use crate::hex_binary::HexBinary; pub use crate::ibc::IbcChannelOpenResponse; pub use crate::ibc::{ Ibc3ChannelOpenResponse, IbcAckCallbackMsg, IbcAcknowledgement, IbcBasicResponse, @@ -48,6 +75,11 @@ pub use crate::ibc::{ }; #[cfg(feature = "iterator")] pub use crate::iterator::{Order, Record}; +pub use crate::math::{ + Decimal, Decimal256, Decimal256RangeExceeded, DecimalRangeExceeded, Fraction, Int128, Int256, + Int512, Int64, Isqrt, SignedDecimal, SignedDecimal256, SignedDecimal256RangeExceeded, + SignedDecimalRangeExceeded, Uint128, Uint256, Uint512, Uint64, +}; pub use crate::metadata::{DenomMetadata, DenomUnit}; pub use crate::never::Never; pub use crate::pagination::PageRequest; @@ -78,6 +110,7 @@ pub use crate::serde::{ }; pub use crate::stdack::StdAck; pub use crate::storage::MemoryStorage; +pub use crate::timestamp::Timestamp; pub use crate::traits::{Api, HashFunction, Querier, QuerierResult, QuerierWrapper, Storage}; pub use crate::types::{BlockInfo, ContractInfo, Env, MessageInfo, TransactionInfo}; @@ -108,24 +141,5 @@ pub use crate::imports::{ExternalApi, ExternalQuerier, ExternalStorage}; #[cfg(not(target_arch = "wasm32"))] pub mod testing; -// Re-exports - -pub use cosmwasm_core::CoreError as StdError; -pub use cosmwasm_core::CoreResult as StdResult; -pub use cosmwasm_core::{ - from_base64, from_hex, instantiate2_address, to_base64, to_hex, Addr, AggregationError, Binary, - CanonicalAddr, CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, - CoinFromStrError, CoinsError, ConversionOverflowError, Decimal, Decimal256, - Decimal256RangeExceeded, DecimalRangeExceeded, DivideByZeroError, DivisionError, Fraction, - HexBinary, Instantiate2AddressError, Int128, Int256, Int512, Int64, Isqrt, OverflowError, - OverflowOperation, PairingEqualityError, RecoverPubkeyError, SignedDecimal, SignedDecimal256, - SignedDecimal256RangeExceeded, SignedDecimalRangeExceeded, SystemError, Timestamp, Uint128, - Uint256, Uint512, Uint64, VerificationError, -}; - -#[cfg(not(target_arch = "wasm32"))] -pub use cosmwasm_core::assert_approx_eq; - -pub use cosmwasm_crypto::{BLS12_381_G1_GENERATOR, BLS12_381_G2_GENERATOR}; - +pub use cosmwasm_core::{BLS12_381_G1_GENERATOR, BLS12_381_G2_GENERATOR}; pub use cosmwasm_derive::entry_point; diff --git a/packages/core/src/math/conversion.rs b/packages/std/src/math/conversion.rs similarity index 100% rename from packages/core/src/math/conversion.rs rename to packages/std/src/math/conversion.rs diff --git a/packages/core/src/math/decimal.rs b/packages/std/src/math/decimal.rs similarity index 97% rename from packages/core/src/math/decimal.rs rename to packages/std/src/math/decimal.rs index 831b956d80..19b1c0a293 100644 --- a/packages/core/src/math/decimal.rs +++ b/packages/std/src/math/decimal.rs @@ -3,15 +3,14 @@ use core::cmp::Ordering; use core::fmt::{self, Write}; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign}; use core::str::FromStr; -use derive_more::Display; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, - OverflowOperation, RoundUpOverflowError, + CheckedFromRatioError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, + OverflowOperation, RoundUpOverflowError, StdError, }; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use crate::{forward_ref_partial_eq, Decimal256, SignedDecimal, SignedDecimal256}; +use crate::{Decimal256, SignedDecimal, SignedDecimal256, __internal::forward_ref_partial_eq}; use super::Fraction; use super::Isqrt; @@ -20,15 +19,13 @@ use super::{Uint128, Uint256}; /// A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0 /// /// The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Decimal(#[cfg_attr(feature = "std", schemars(with = "String"))] Uint128); +#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Decimal(#[schemars(with = "String")] Uint128); forward_ref_partial_eq!(Decimal, Decimal); -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -#[display("Decimal range exceeded")] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] +#[error("Decimal range exceeded")] pub struct DecimalRangeExceeded; impl Decimal { @@ -538,7 +535,7 @@ impl TryFrom for Decimal { } impl FromStr for Decimal { - type Err = CoreError; + type Err = StdError; /// Converts the decimal string to a Decimal /// Possible inputs: "1.23", "1", "000012", "1.123000000" @@ -552,18 +549,18 @@ impl FromStr for Decimal { let whole_part = parts_iter.next().unwrap(); // split always returns at least one element let whole = whole_part .parse::() - .map_err(|_| CoreError::generic_err("Error parsing whole"))?; + .map_err(|_| StdError::generic_err("Error parsing whole"))?; let mut atomics = whole .checked_mul(Self::DECIMAL_FRACTIONAL) - .map_err(|_| CoreError::generic_err("Value too big"))?; + .map_err(|_| StdError::generic_err("Value too big"))?; if let Some(fractional_part) = parts_iter.next() { let fractional = fractional_part .parse::() - .map_err(|_| CoreError::generic_err("Error parsing fractional"))?; + .map_err(|_| StdError::generic_err("Error parsing fractional"))?; let exp = (Self::DECIMAL_PLACES.checked_sub(fractional_part.len() as u32)).ok_or_else( || { - CoreError::generic_err(format!( + StdError::generic_err(format!( "Cannot parse more than {} fractional digits", Self::DECIMAL_PLACES )) @@ -577,11 +574,11 @@ impl FromStr for Decimal { // fractional < 10^DECIMAL_PLACES && fractional_factor <= 10^DECIMAL_PLACES fractional.checked_mul(fractional_factor).unwrap(), ) - .map_err(|_| CoreError::generic_err("Value too big"))?; + .map_err(|_| StdError::generic_err("Value too big"))?; } if parts_iter.next().is_some() { - return Err(CoreError::generic_err("Unexpected number of dots")); + return Err(StdError::generic_err("Unexpected number of dots")); } Ok(Decimal(atomics)) @@ -1092,17 +1089,17 @@ mod tests { #[test] fn decimal_from_str_errors_for_broken_whole_part() { match Decimal::from_str("").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str(" ").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("-1").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } } @@ -1110,22 +1107,22 @@ mod tests { #[test] fn decimal_from_str_errors_for_broken_fractional_part() { match Decimal::from_str("1.").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("1. ").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("1.e").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("1.2e3").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } } @@ -1133,7 +1130,7 @@ mod tests { #[test] fn decimal_from_str_errors_for_more_than_18_fractional_digits() { match Decimal::from_str("7.1234567890123456789").unwrap_err() { - CoreError::GenericErr { msg, .. } => { + StdError::GenericErr { msg, .. } => { assert_eq!(msg, "Cannot parse more than 18 fractional digits",) } e => panic!("Unexpected error: {e:?}"), @@ -1141,7 +1138,7 @@ mod tests { // No special rules for trailing zeros. This could be changed but adds gas cost for the happy path. match Decimal::from_str("7.1230000000000000000").unwrap_err() { - CoreError::GenericErr { msg, .. } => { + StdError::GenericErr { msg, .. } => { assert_eq!(msg, "Cannot parse more than 18 fractional digits") } e => panic!("Unexpected error: {e:?}"), @@ -1151,12 +1148,12 @@ mod tests { #[test] fn decimal_from_str_errors_for_invalid_number_of_dots() { match Decimal::from_str("1.2.3").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("1.2.3.4").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), e => panic!("Unexpected error: {e:?}"), } } @@ -1165,17 +1162,17 @@ mod tests { fn decimal_from_str_errors_for_more_than_max_value() { // Integer match Decimal::from_str("340282366920938463464").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } // Decimal match Decimal::from_str("340282366920938463464.0").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } match Decimal::from_str("340282366920938463463.374607431768211456").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } } diff --git a/packages/core/src/math/decimal256.rs b/packages/std/src/math/decimal256.rs similarity index 97% rename from packages/core/src/math/decimal256.rs rename to packages/std/src/math/decimal256.rs index 5cdaf4863e..a37a0ffeec 100644 --- a/packages/core/src/math/decimal256.rs +++ b/packages/std/src/math/decimal256.rs @@ -3,15 +3,16 @@ use core::cmp::Ordering; use core::fmt::{self, Write}; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign}; use core::str::FromStr; -use derive_more::Display; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, - OverflowOperation, RoundUpOverflowError, + CheckedFromRatioError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, + OverflowOperation, RoundUpOverflowError, StdError, }; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use crate::{forward_ref_partial_eq, Decimal, SignedDecimal, SignedDecimal256, Uint512}; +use crate::{ + Decimal, SignedDecimal, SignedDecimal256, Uint512, __internal::forward_ref_partial_eq, +}; use super::Fraction; use super::Isqrt; @@ -22,15 +23,13 @@ use super::Uint256; /// The greatest possible value that can be represented is /// 115792089237316195423570985008687907853269984665640564039457.584007913129639935 /// (which is (2^256 - 1) / 10^18) -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Decimal256(#[cfg_attr(feature = "std", schemars(with = "String"))] Uint256); +#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Decimal256(#[schemars(with = "String")] Uint256); forward_ref_partial_eq!(Decimal256, Decimal256); -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -#[display("Decimal256 range exceeded")] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] +#[error("Decimal256 range exceeded")] pub struct Decimal256RangeExceeded; impl Decimal256 { @@ -538,7 +537,7 @@ impl TryFrom for Decimal256 { } impl FromStr for Decimal256 { - type Err = CoreError; + type Err = StdError; /// Converts the decimal string to a Decimal256 /// Possible inputs: "1.23", "1", "000012", "1.123000000" @@ -552,18 +551,18 @@ impl FromStr for Decimal256 { let whole_part = parts_iter.next().unwrap(); // split always returns at least one element let whole = whole_part .parse::() - .map_err(|_| CoreError::generic_err("Error parsing whole"))?; + .map_err(|_| StdError::generic_err("Error parsing whole"))?; let mut atomics = whole .checked_mul(Self::DECIMAL_FRACTIONAL) - .map_err(|_| CoreError::generic_err("Value too big"))?; + .map_err(|_| StdError::generic_err("Value too big"))?; if let Some(fractional_part) = parts_iter.next() { let fractional = fractional_part .parse::() - .map_err(|_| CoreError::generic_err("Error parsing fractional"))?; + .map_err(|_| StdError::generic_err("Error parsing fractional"))?; let exp = (Self::DECIMAL_PLACES.checked_sub(fractional_part.len() as u32)).ok_or_else( || { - CoreError::generic_err(format!( + StdError::generic_err(format!( "Cannot parse more than {} fractional digits", Self::DECIMAL_PLACES )) @@ -577,11 +576,11 @@ impl FromStr for Decimal256 { // fractional < 10^DECIMAL_PLACES && fractional_factor <= 10^DECIMAL_PLACES fractional.checked_mul(fractional_factor).unwrap(), ) - .map_err(|_| CoreError::generic_err("Value too big"))?; + .map_err(|_| StdError::generic_err("Value too big"))?; } if parts_iter.next().is_some() { - return Err(CoreError::generic_err("Unexpected number of dots")); + return Err(StdError::generic_err("Unexpected number of dots")); } Ok(Self(atomics)) @@ -784,7 +783,7 @@ impl<'de> de::Visitor<'de> for Decimal256Visitor { #[cfg(test)] mod tests { use super::*; - use crate::errors::CoreError; + use crate::errors::StdError; use alloc::vec::Vec; @@ -1118,17 +1117,17 @@ mod tests { #[test] fn decimal256_from_str_errors_for_broken_whole_part() { match Decimal256::from_str("").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str(" ").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str("-1").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), e => panic!("Unexpected error: {e:?}"), } } @@ -1136,22 +1135,22 @@ mod tests { #[test] fn decimal256_from_str_errors_for_broken_fractional_part() { match Decimal256::from_str("1.").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str("1. ").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str("1.e").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str("1.2e3").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), e => panic!("Unexpected error: {e:?}"), } } @@ -1159,7 +1158,7 @@ mod tests { #[test] fn decimal256_from_str_errors_for_more_than_36_fractional_digits() { match Decimal256::from_str("7.1234567890123456789").unwrap_err() { - CoreError::GenericErr { msg, .. } => { + StdError::GenericErr { msg, .. } => { assert_eq!(msg, "Cannot parse more than 18 fractional digits") } e => panic!("Unexpected error: {e:?}"), @@ -1167,7 +1166,7 @@ mod tests { // No special rules for trailing zeros. This could be changed but adds gas cost for the happy path. match Decimal256::from_str("7.1230000000000000000").unwrap_err() { - CoreError::GenericErr { msg, .. } => { + StdError::GenericErr { msg, .. } => { assert_eq!(msg, "Cannot parse more than 18 fractional digits") } e => panic!("Unexpected error: {e:?}"), @@ -1177,12 +1176,12 @@ mod tests { #[test] fn decimal256_from_str_errors_for_invalid_number_of_dots() { match Decimal256::from_str("1.2.3").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str("1.2.3.4").unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), e => panic!("Unexpected error: {e:?}"), } } @@ -1193,7 +1192,7 @@ mod tests { match Decimal256::from_str("115792089237316195423570985008687907853269984665640564039458") .unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } @@ -1201,7 +1200,7 @@ mod tests { match Decimal256::from_str("115792089237316195423570985008687907853269984665640564039458.0") .unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } match Decimal256::from_str( @@ -1209,7 +1208,7 @@ mod tests { ) .unwrap_err() { - CoreError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), + StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), e => panic!("Unexpected error: {e:?}"), } } diff --git a/packages/core/src/math/fraction.rs b/packages/std/src/math/fraction.rs similarity index 100% rename from packages/core/src/math/fraction.rs rename to packages/std/src/math/fraction.rs diff --git a/packages/core/src/math/int128.rs b/packages/std/src/math/int128.rs similarity index 98% rename from packages/core/src/math/int128.rs rename to packages/std/src/math/int128.rs index cf8afefe0e..6d240f285a 100644 --- a/packages/core/src/math/int128.rs +++ b/packages/std/src/math/int128.rs @@ -7,13 +7,11 @@ use core::ops::{ use core::str::FromStr; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::errors::{ - CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, -}; +use crate::errors::{DivideByZeroError, DivisionError, OverflowError, OverflowOperation, StdError}; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ - forward_ref_partial_eq, CheckedMultiplyRatioError, Int256, Int512, Int64, Uint128, Uint256, - Uint512, Uint64, + CheckedMultiplyRatioError, Int256, Int512, Int64, Uint128, Uint256, Uint512, Uint64, + __internal::forward_ref_partial_eq, }; use super::conversion::{forward_try_from, try_from_int_to_int}; @@ -32,9 +30,8 @@ use super::num_consts::NumConsts; /// let a = Int128::from(258i128); /// assert_eq!(a.i128(), 258); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Int128(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) i128); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Int128(#[schemars(with = "String")] pub(crate) i128); forward_ref_partial_eq!(Int128, Int128); @@ -374,7 +371,7 @@ impl From for Int128 { } impl TryFrom<&str> for Int128 { - type Error = CoreError; + type Error = StdError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -382,12 +379,12 @@ impl TryFrom<&str> for Int128 { } impl FromStr for Int128 { - type Err = CoreError; + type Err = StdError; fn from_str(s: &str) -> Result { match s.parse::() { Ok(u) => Ok(Self(u)), - Err(e) => Err(CoreError::generic_err(format!("Parsing Int128: {e}"))), + Err(e) => Err(StdError::generic_err(format!("Parsing Int128: {e}"))), } } } diff --git a/packages/core/src/math/int256.rs b/packages/std/src/math/int256.rs similarity index 98% rename from packages/core/src/math/int256.rs rename to packages/std/src/math/int256.rs index 4b509c07ee..4b236bed15 100644 --- a/packages/core/src/math/int256.rs +++ b/packages/std/src/math/int256.rs @@ -7,13 +7,11 @@ use core::ops::{ use core::str::FromStr; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::errors::{ - CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, -}; +use crate::errors::{DivideByZeroError, DivisionError, OverflowError, OverflowOperation, StdError}; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ - forward_ref_partial_eq, CheckedMultiplyRatioError, Int128, Int512, Int64, Uint128, Uint256, - Uint512, Uint64, + CheckedMultiplyRatioError, Int128, Int512, Int64, Uint128, Uint256, Uint512, Uint64, + __internal::forward_ref_partial_eq, }; /// Used internally - we don't want to leak this type since we might change @@ -43,9 +41,8 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Int256(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) I256); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Int256(#[schemars(with = "String")] pub(crate) I256); forward_ref_partial_eq!(Int256, Int256); @@ -449,7 +446,7 @@ impl From for Int256 { } impl TryFrom<&str> for Int256 { - type Error = CoreError; + type Error = StdError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -457,12 +454,12 @@ impl TryFrom<&str> for Int256 { } impl FromStr for Int256 { - type Err = CoreError; + type Err = StdError; fn from_str(s: &str) -> Result { match I256::from_str_radix(s, 10) { Ok(u) => Ok(Self(u)), - Err(e) => Err(CoreError::generic_err(format!("Parsing Int256: {e}"))), + Err(e) => Err(StdError::generic_err(format!("Parsing Int256: {e}"))), } } } diff --git a/packages/core/src/math/int512.rs b/packages/std/src/math/int512.rs similarity index 98% rename from packages/core/src/math/int512.rs rename to packages/std/src/math/int512.rs index 29b4ed21e2..edbfaa2a47 100644 --- a/packages/core/src/math/int512.rs +++ b/packages/std/src/math/int512.rs @@ -7,11 +7,11 @@ use core::ops::{ use core::str::FromStr; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::errors::{ - CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, -}; +use crate::errors::{DivideByZeroError, DivisionError, OverflowError, OverflowOperation, StdError}; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use crate::{forward_ref_partial_eq, Int128, Int256, Int64, Uint128, Uint256, Uint512, Uint64}; +use crate::{ + Int128, Int256, Int64, Uint128, Uint256, Uint512, Uint64, __internal::forward_ref_partial_eq, +}; /// Used internally - we don't want to leak this type since we might change /// the implementation in the future. @@ -44,9 +44,8 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Int512(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) I512); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Int512(#[schemars(with = "String")] pub(crate) I512); forward_ref_partial_eq!(Int512, Int512); @@ -446,7 +445,7 @@ impl From for Int512 { } impl TryFrom<&str> for Int512 { - type Error = CoreError; + type Error = StdError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -454,12 +453,12 @@ impl TryFrom<&str> for Int512 { } impl FromStr for Int512 { - type Err = CoreError; + type Err = StdError; fn from_str(s: &str) -> Result { match I512::from_str_radix(s, 10) { Ok(u) => Ok(Self(u)), - Err(e) => Err(CoreError::generic_err(format!("Parsing Int512: {e}"))), + Err(e) => Err(StdError::generic_err(format!("Parsing Int512: {e}"))), } } } diff --git a/packages/core/src/math/int64.rs b/packages/std/src/math/int64.rs similarity index 98% rename from packages/core/src/math/int64.rs rename to packages/std/src/math/int64.rs index 15d8ddd957..ccabc9ef3b 100644 --- a/packages/core/src/math/int64.rs +++ b/packages/std/src/math/int64.rs @@ -7,13 +7,11 @@ use core::ops::{ use core::str::FromStr; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use crate::errors::{ - CoreError, DivideByZeroError, DivisionError, OverflowError, OverflowOperation, -}; +use crate::errors::{DivideByZeroError, DivisionError, OverflowError, OverflowOperation, StdError}; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ - forward_ref_partial_eq, CheckedMultiplyRatioError, Int128, Int256, Int512, Uint128, Uint256, - Uint512, Uint64, + CheckedMultiplyRatioError, Int128, Int256, Int512, Uint128, Uint256, Uint512, Uint64, + __internal::forward_ref_partial_eq, }; use super::conversion::{forward_try_from, try_from_int_to_int}; @@ -32,9 +30,8 @@ use super::num_consts::NumConsts; /// let a = Int64::from(258i64); /// assert_eq!(a.i64(), 258); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Int64(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) i64); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Int64(#[schemars(with = "String")] pub(crate) i64); forward_ref_partial_eq!(Int64, Int64); @@ -353,7 +350,7 @@ forward_try_from!(Uint256, Int64); forward_try_from!(Uint512, Int64); impl TryFrom<&str> for Int64 { - type Error = CoreError; + type Error = StdError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -361,12 +358,12 @@ impl TryFrom<&str> for Int64 { } impl FromStr for Int64 { - type Err = CoreError; + type Err = StdError; fn from_str(s: &str) -> Result { match s.parse::() { Ok(u) => Ok(Self(u)), - Err(e) => Err(CoreError::generic_err(format!("Parsing Int64: {e}"))), + Err(e) => Err(StdError::generic_err(format!("Parsing Int64: {e}"))), } } } diff --git a/packages/core/src/math/isqrt.rs b/packages/std/src/math/isqrt.rs similarity index 100% rename from packages/core/src/math/isqrt.rs rename to packages/std/src/math/isqrt.rs diff --git a/packages/core/src/math/mod.rs b/packages/std/src/math/mod.rs similarity index 100% rename from packages/core/src/math/mod.rs rename to packages/std/src/math/mod.rs diff --git a/packages/core/src/math/num_consts.rs b/packages/std/src/math/num_consts.rs similarity index 100% rename from packages/core/src/math/num_consts.rs rename to packages/std/src/math/num_consts.rs diff --git a/packages/core/src/math/signed_decimal.rs b/packages/std/src/math/signed_decimal.rs similarity index 98% rename from packages/core/src/math/signed_decimal.rs rename to packages/std/src/math/signed_decimal.rs index bffd426bc3..5dd82b10e1 100644 --- a/packages/core/src/math/signed_decimal.rs +++ b/packages/std/src/math/signed_decimal.rs @@ -5,15 +5,14 @@ use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign, }; use core::str::FromStr; -use derive_more::Display; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, - OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, + CheckedFromRatioError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, + OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, StdError, }; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use crate::{forward_ref_partial_eq, Decimal, Decimal256, Int256, SignedDecimal256}; +use crate::{Decimal, Decimal256, Int256, SignedDecimal256, __internal::forward_ref_partial_eq}; use super::Fraction; use super::Int128; @@ -22,15 +21,13 @@ use super::Int128; /// /// The greatest possible value that can be represented is 170141183460469231731.687303715884105727 (which is (2^127 - 1) / 10^18) /// and the smallest is -170141183460469231731.687303715884105728 (which is -2^127 / 10^18). -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct SignedDecimal(#[cfg_attr(feature = "std", schemars(with = "String"))] Int128); +#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct SignedDecimal(#[schemars(with = "String")] Int128); forward_ref_partial_eq!(SignedDecimal, SignedDecimal); -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -#[display("SignedDecimal range exceeded")] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] +#[error("SignedDecimal range exceeded")] pub struct SignedDecimalRangeExceeded; impl SignedDecimal { @@ -649,7 +646,7 @@ impl TryFrom for SignedDecimal { } impl FromStr for SignedDecimal { - type Err = CoreError; + type Err = StdError; /// Converts the decimal string to a SignedDecimal /// Possible inputs: "1.23", "1", "000012", "1.123000000", "-1.12300" @@ -665,18 +662,18 @@ impl FromStr for SignedDecimal { let whole = whole_part .parse::() - .map_err(|_| CoreError::generic_err("Error parsing whole"))?; + .map_err(|_| StdError::generic_err("Error parsing whole"))?; let mut atomics = whole .checked_mul(Self::DECIMAL_FRACTIONAL) - .map_err(|_| CoreError::generic_err("Value too big"))?; + .map_err(|_| StdError::generic_err("Value too big"))?; if let Some(fractional_part) = parts_iter.next() { let fractional = fractional_part .parse::() // u64 is enough for 18 decimal places - .map_err(|_| CoreError::generic_err("Error parsing fractional"))?; + .map_err(|_| StdError::generic_err("Error parsing fractional"))?; let exp = (Self::DECIMAL_PLACES.checked_sub(fractional_part.len() as u32)).ok_or_else( || { - CoreError::generic_err(format!( + StdError::generic_err(format!( "Cannot parse more than {} fractional digits", Self::DECIMAL_PLACES )) @@ -697,11 +694,11 @@ impl FromStr for SignedDecimal { } else { atomics.checked_add(fractional_part) } - .map_err(|_| CoreError::generic_err("Value too big"))?; + .map_err(|_| StdError::generic_err("Value too big"))?; } if parts_iter.next().is_some() { - return Err(CoreError::generic_err("Unexpected number of dots")); + return Err(StdError::generic_err("Unexpected number of dots")); } Ok(SignedDecimal(atomics)) @@ -1358,7 +1355,7 @@ mod tests { #[test] fn signed_decimal_from_str_errors_for_broken_whole_part() { - let expected_err = CoreError::generic_err("Error parsing whole"); + let expected_err = StdError::generic_err("Error parsing whole"); assert_eq!(SignedDecimal::from_str("").unwrap_err(), expected_err); assert_eq!(SignedDecimal::from_str(" ").unwrap_err(), expected_err); assert_eq!(SignedDecimal::from_str("-").unwrap_err(), expected_err); @@ -1366,7 +1363,7 @@ mod tests { #[test] fn signed_decimal_from_str_errors_for_broken_fractional_part() { - let expected_err = CoreError::generic_err("Error parsing fractional"); + let expected_err = StdError::generic_err("Error parsing fractional"); assert_eq!(SignedDecimal::from_str("1.").unwrap_err(), expected_err); assert_eq!(SignedDecimal::from_str("1. ").unwrap_err(), expected_err); assert_eq!(SignedDecimal::from_str("1.e").unwrap_err(), expected_err); @@ -1376,7 +1373,7 @@ mod tests { #[test] fn signed_decimal_from_str_errors_for_more_than_18_fractional_digits() { - let expected_err = CoreError::generic_err("Cannot parse more than 18 fractional digits"); + let expected_err = StdError::generic_err("Cannot parse more than 18 fractional digits"); assert_eq!( SignedDecimal::from_str("7.1234567890123456789").unwrap_err(), expected_err @@ -1390,7 +1387,7 @@ mod tests { #[test] fn signed_decimal_from_str_errors_for_invalid_number_of_dots() { - let expected_err = CoreError::generic_err("Unexpected number of dots"); + let expected_err = StdError::generic_err("Unexpected number of dots"); assert_eq!(SignedDecimal::from_str("1.2.3").unwrap_err(), expected_err); assert_eq!( SignedDecimal::from_str("1.2.3.4").unwrap_err(), @@ -1400,7 +1397,7 @@ mod tests { #[test] fn signed_decimal_from_str_errors_for_more_than_max_value() { - let expected_err = CoreError::generic_err("Value too big"); + let expected_err = StdError::generic_err("Value too big"); // Integer assert_eq!( SignedDecimal::from_str("170141183460469231732").unwrap_err(), @@ -3098,7 +3095,6 @@ mod tests { } #[test] - #[cfg(feature = "std")] fn signed_decimal_has_defined_json_schema() { let schema = schemars::schema_for!(SignedDecimal); assert_eq!( diff --git a/packages/core/src/math/signed_decimal_256.rs b/packages/std/src/math/signed_decimal_256.rs similarity index 98% rename from packages/core/src/math/signed_decimal_256.rs rename to packages/std/src/math/signed_decimal_256.rs index d47649e6f3..e994bd7bac 100644 --- a/packages/core/src/math/signed_decimal_256.rs +++ b/packages/std/src/math/signed_decimal_256.rs @@ -5,15 +5,14 @@ use core::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign, }; use core::str::FromStr; -use derive_more::Display; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - CheckedFromRatioError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, OverflowError, - OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, + CheckedFromRatioError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, + OverflowOperation, RoundDownOverflowError, RoundUpOverflowError, StdError, }; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use crate::{forward_ref_partial_eq, Decimal, Decimal256, Int512, SignedDecimal}; +use crate::{Decimal, Decimal256, Int512, SignedDecimal, __internal::forward_ref_partial_eq}; use super::Fraction; use super::Int256; @@ -27,15 +26,13 @@ use super::Int256; /// and the smallest is /// -57896044618658097711785492504343953926634992332820282019728.792003956564819968 /// (which is -2^255 / 10^18). -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct SignedDecimal256(#[cfg_attr(feature = "std", schemars(with = "String"))] Int256); +#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct SignedDecimal256(#[schemars(with = "String")] Int256); forward_ref_partial_eq!(SignedDecimal256, SignedDecimal256); -#[derive(Display, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] -#[display("SignedDecimal256 range exceeded")] +#[derive(Debug, PartialEq, Eq, thiserror::Error)] +#[error("SignedDecimal256 range exceeded")] pub struct SignedDecimal256RangeExceeded; impl SignedDecimal256 { @@ -650,7 +647,7 @@ impl TryFrom for SignedDecimal256 { } impl FromStr for SignedDecimal256 { - type Err = CoreError; + type Err = StdError; /// Converts the decimal string to a SignedDecimal256 /// Possible inputs: "1.23", "1", "000012", "1.123000000", "-1.12300" @@ -666,18 +663,18 @@ impl FromStr for SignedDecimal256 { let whole = whole_part .parse::() - .map_err(|_| CoreError::generic_err("Error parsing whole"))?; + .map_err(|_| StdError::generic_err("Error parsing whole"))?; let mut atomics = whole .checked_mul(Self::DECIMAL_FRACTIONAL) - .map_err(|_| CoreError::generic_err("Value too big"))?; + .map_err(|_| StdError::generic_err("Value too big"))?; if let Some(fractional_part) = parts_iter.next() { let fractional = fractional_part .parse::() // u64 is enough for 18 decimal places - .map_err(|_| CoreError::generic_err("Error parsing fractional"))?; + .map_err(|_| StdError::generic_err("Error parsing fractional"))?; let exp = (Self::DECIMAL_PLACES.checked_sub(fractional_part.len() as u32)).ok_or_else( || { - CoreError::generic_err(format!( + StdError::generic_err(format!( "Cannot parse more than {} fractional digits", Self::DECIMAL_PLACES )) @@ -698,11 +695,11 @@ impl FromStr for SignedDecimal256 { } else { atomics.checked_add(fractional_part) } - .map_err(|_| CoreError::generic_err("Value too big"))?; + .map_err(|_| StdError::generic_err("Value too big"))?; } if parts_iter.next().is_some() { - return Err(CoreError::generic_err("Unexpected number of dots")); + return Err(StdError::generic_err("Unexpected number of dots")); } Ok(SignedDecimal256(atomics)) @@ -1365,7 +1362,7 @@ mod tests { #[test] fn signed_decimal_256_from_str_errors_for_broken_whole_part() { - let expected_err = CoreError::generic_err("Error parsing whole"); + let expected_err = StdError::generic_err("Error parsing whole"); assert_eq!(SignedDecimal256::from_str("").unwrap_err(), expected_err); assert_eq!(SignedDecimal256::from_str(" ").unwrap_err(), expected_err); assert_eq!(SignedDecimal256::from_str("-").unwrap_err(), expected_err); @@ -1373,7 +1370,7 @@ mod tests { #[test] fn signed_decimal_256_from_str_errors_for_broken_fractional_part() { - let expected_err = CoreError::generic_err("Error parsing fractional"); + let expected_err = StdError::generic_err("Error parsing fractional"); assert_eq!(SignedDecimal256::from_str("1.").unwrap_err(), expected_err); assert_eq!(SignedDecimal256::from_str("1. ").unwrap_err(), expected_err); assert_eq!(SignedDecimal256::from_str("1.e").unwrap_err(), expected_err); @@ -1389,7 +1386,7 @@ mod tests { #[test] fn signed_decimal_256_from_str_errors_for_more_than_18_fractional_digits() { - let expected_err = CoreError::generic_err("Cannot parse more than 18 fractional digits"); + let expected_err = StdError::generic_err("Cannot parse more than 18 fractional digits"); assert_eq!( SignedDecimal256::from_str("7.1234567890123456789").unwrap_err(), expected_err @@ -1403,7 +1400,7 @@ mod tests { #[test] fn signed_decimal_256_from_str_errors_for_invalid_number_of_dots() { - let expected_err = CoreError::generic_err("Unexpected number of dots"); + let expected_err = StdError::generic_err("Unexpected number of dots"); assert_eq!( SignedDecimal256::from_str("1.2.3").unwrap_err(), expected_err @@ -1416,7 +1413,7 @@ mod tests { #[test] fn signed_decimal_256_from_str_errors_for_more_than_max_value() { - let expected_err = CoreError::generic_err("Value too big"); + let expected_err = StdError::generic_err("Value too big"); // Integer assert_eq!( SignedDecimal256::from_str( @@ -3271,7 +3268,6 @@ mod tests { } #[test] - #[cfg(feature = "std")] fn signed_decimal_256_has_defined_json_schema() { let schema = schemars::schema_for!(SignedDecimal256); assert_eq!( diff --git a/packages/core/src/math/uint128.rs b/packages/std/src/math/uint128.rs similarity index 98% rename from packages/core/src/math/uint128.rs rename to packages/std/src/math/uint128.rs index 609fffda5c..b209f28007 100644 --- a/packages/core/src/math/uint128.rs +++ b/packages/std/src/math/uint128.rs @@ -9,13 +9,13 @@ use core::str::FromStr; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - CheckedMultiplyFractionError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, - OverflowError, OverflowOperation, + CheckedMultiplyFractionError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, + OverflowOperation, StdError, }; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ - forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, Uint256, - Uint64, + __internal::forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, + Uint256, Uint64, }; use super::conversion::forward_try_from; @@ -40,9 +40,8 @@ use super::num_consts::NumConsts; /// let c = Uint128::from(70u32); /// assert_eq!(c.u128(), 70); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Uint128(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) u128); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Uint128(#[schemars(with = "String")] pub(crate) u128); forward_ref_partial_eq!(Uint128, Uint128); @@ -367,7 +366,7 @@ forward_try_from!(Int256, Uint128); forward_try_from!(Int512, Uint128); impl TryFrom<&str> for Uint128 { - type Error = CoreError; + type Error = StdError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -375,12 +374,12 @@ impl TryFrom<&str> for Uint128 { } impl FromStr for Uint128 { - type Err = CoreError; + type Err = StdError; fn from_str(s: &str) -> Result { match s.parse::() { Ok(u) => Ok(Uint128(u)), - Err(e) => Err(CoreError::generic_err(format!("Parsing u128: {e}"))), + Err(e) => Err(StdError::generic_err(format!("Parsing u128: {e}"))), } } } diff --git a/packages/core/src/math/uint256.rs b/packages/std/src/math/uint256.rs similarity index 99% rename from packages/core/src/math/uint256.rs rename to packages/std/src/math/uint256.rs index 5db53530e1..815cf34003 100644 --- a/packages/core/src/math/uint256.rs +++ b/packages/std/src/math/uint256.rs @@ -8,13 +8,13 @@ use core::str::FromStr; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - CheckedMultiplyFractionError, CheckedMultiplyRatioError, ConversionOverflowError, CoreError, - DivideByZeroError, OverflowError, OverflowOperation, + CheckedMultiplyFractionError, CheckedMultiplyRatioError, ConversionOverflowError, + DivideByZeroError, OverflowError, OverflowOperation, StdError, }; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ - forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, Uint128, - Uint512, Uint64, + __internal::forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, + Uint128, Uint512, Uint64, }; /// Used internally - we don't want to leak this type since we might change @@ -44,9 +44,8 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Uint256(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) U256); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Uint256(#[schemars(with = "String")] pub(crate) U256); forward_ref_partial_eq!(Uint256, Uint256); @@ -437,7 +436,7 @@ try_from_int_to_uint!(Int256, Uint256); try_from_int_to_uint!(Int512, Uint256); impl TryFrom<&str> for Uint256 { - type Error = CoreError; + type Error = StdError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -445,18 +444,16 @@ impl TryFrom<&str> for Uint256 { } impl FromStr for Uint256 { - type Err = CoreError; + type Err = StdError; fn from_str(s: &str) -> Result { if s.is_empty() { - return Err(CoreError::generic_err( - "Parsing u256: received empty string", - )); + return Err(StdError::generic_err("Parsing u256: received empty string")); } match U256::from_str_radix(s, 10) { Ok(u) => Ok(Uint256(u)), - Err(e) => Err(CoreError::generic_err(format!("Parsing u256: {e}"))), + Err(e) => Err(StdError::generic_err(format!("Parsing u256: {e}"))), } } } diff --git a/packages/core/src/math/uint512.rs b/packages/std/src/math/uint512.rs similarity index 98% rename from packages/core/src/math/uint512.rs rename to packages/std/src/math/uint512.rs index f337c21925..cd96353c6f 100644 --- a/packages/core/src/math/uint512.rs +++ b/packages/std/src/math/uint512.rs @@ -8,10 +8,12 @@ use core::str::FromStr; use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - ConversionOverflowError, CoreError, DivideByZeroError, OverflowError, OverflowOperation, + ConversionOverflowError, DivideByZeroError, OverflowError, OverflowOperation, StdError, }; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; -use crate::{forward_ref_partial_eq, Int128, Int256, Int512, Int64, Uint128, Uint256, Uint64}; +use crate::{ + Int128, Int256, Int512, Int64, Uint128, Uint256, Uint64, __internal::forward_ref_partial_eq, +}; /// Used internally - we don't want to leak this type since we might change /// the implementation in the future. @@ -44,9 +46,8 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Uint512(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) U512); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Uint512(#[schemars(with = "String")] pub(crate) U512); forward_ref_partial_eq!(Uint512, Uint512); @@ -422,7 +423,7 @@ try_from_int_to_uint!(Int256, Uint512); try_from_int_to_uint!(Int512, Uint512); impl TryFrom<&str> for Uint512 { - type Error = CoreError; + type Error = StdError; fn try_from(val: &str) -> Result { Self::from_str(val) @@ -430,12 +431,12 @@ impl TryFrom<&str> for Uint512 { } impl FromStr for Uint512 { - type Err = CoreError; + type Err = StdError; fn from_str(s: &str) -> Result { match U512::from_str_radix(s, 10) { Ok(u) => Ok(Self(u)), - Err(e) => Err(CoreError::generic_err(format!("Parsing u512: {e}"))), + Err(e) => Err(StdError::generic_err(format!("Parsing u512: {e}"))), } } } diff --git a/packages/core/src/math/uint64.rs b/packages/std/src/math/uint64.rs similarity index 98% rename from packages/core/src/math/uint64.rs rename to packages/std/src/math/uint64.rs index 065a2580b9..707cd9e311 100644 --- a/packages/core/src/math/uint64.rs +++ b/packages/std/src/math/uint64.rs @@ -7,12 +7,13 @@ use core::ops::{ use serde::{de, ser, Deserialize, Deserializer, Serialize}; use crate::errors::{ - CheckedMultiplyFractionError, CheckedMultiplyRatioError, CoreError, DivideByZeroError, - OverflowError, OverflowOperation, + CheckedMultiplyFractionError, CheckedMultiplyRatioError, DivideByZeroError, OverflowError, + OverflowOperation, StdError, }; use crate::forward_ref::{forward_ref_binop, forward_ref_op_assign}; use crate::{ - forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, Uint128, + __internal::forward_ref_partial_eq, impl_mul_fraction, Fraction, Int128, Int256, Int512, Int64, + Uint128, }; use super::conversion::forward_try_from; @@ -34,9 +35,8 @@ use super::num_consts::NumConsts; /// let b = Uint64::from(70u32); /// assert_eq!(b.u64(), 70); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] -pub struct Uint64(#[cfg_attr(feature = "std", schemars(with = "String"))] pub(crate) u64); +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +pub struct Uint64(#[schemars(with = "String")] pub(crate) u64); forward_ref_partial_eq!(Uint64, Uint64); @@ -348,12 +348,12 @@ forward_try_from!(Int256, Uint64); forward_try_from!(Int512, Uint64); impl TryFrom<&str> for Uint64 { - type Error = CoreError; + type Error = StdError; fn try_from(val: &str) -> Result { match val.parse::() { Ok(u) => Ok(Uint64(u)), - Err(e) => Err(CoreError::generic_err(format!("Parsing u64: {e}"))), + Err(e) => Err(StdError::generic_err(format!("Parsing u64: {e}"))), } } } diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index c6a1a20f3e..f35c79faeb 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -165,6 +165,7 @@ pub struct AnyMsg { pub value: Binary, } +#[allow(dead_code)] struct BinaryToStringEncoder<'a>(&'a Binary); impl fmt::Display for BinaryToStringEncoder<'_> { @@ -487,6 +488,7 @@ mod tests { // should work with Into struct IntoAny; + impl From for AnyMsg { fn from(_: IntoAny) -> Self { AnyMsg { @@ -495,6 +497,7 @@ mod tests { } } } + let msg: CosmosMsg = IntoAny.into(); assert!(matches!( msg, diff --git a/packages/std/src/results/events.rs b/packages/std/src/results/events.rs index 6ab3957202..823a671a7c 100644 --- a/packages/std/src/results/events.rs +++ b/packages/std/src/results/events.rs @@ -1,4 +1,4 @@ -use cosmwasm_core::__internal::forward_ref_partial_eq; +use crate::__internal::forward_ref_partial_eq; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/packages/std/src/results/query.rs b/packages/std/src/results/query.rs index 6db3a13d0d..8619ab7e4a 100644 --- a/packages/std/src/results/query.rs +++ b/packages/std/src/results/query.rs @@ -1 +1 @@ -pub type QueryResponse = cosmwasm_core::Binary; +pub type QueryResponse = crate::Binary; diff --git a/packages/std/src/stdack.rs b/packages/std/src/stdack.rs index 50b72a6ae6..953ea8099c 100644 --- a/packages/std/src/stdack.rs +++ b/packages/std/src/stdack.rs @@ -1,9 +1,9 @@ -use cosmwasm_core::Binary; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::prelude::*; use crate::to_json_binary; +use crate::Binary; /// This is a standard IBC acknowledgement type. IBC application are free /// to use any acknowledgement format they want. However, for compatibility diff --git a/packages/core/src/testing/assertions.rs b/packages/std/src/testing/assertions.rs similarity index 100% rename from packages/core/src/testing/assertions.rs rename to packages/std/src/testing/assertions.rs diff --git a/packages/std/src/testing/message_info.rs b/packages/std/src/testing/message_info.rs index 53cfcff761..39178ba8a4 100644 --- a/packages/std/src/testing/message_info.rs +++ b/packages/std/src/testing/message_info.rs @@ -49,9 +49,7 @@ pub fn message_info(sender: &Addr, funds: &[Coin]) -> MessageInfo { #[cfg(test)] mod tests { - use cosmwasm_core::Uint128; - - use crate::coins; + use crate::{coins, Uint128}; use super::*; diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index 9e59a1c912..877c176161 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -1,5 +1,6 @@ use crate::prelude::*; use crate::HashFunction; +use crate::{Addr, CanonicalAddr, Timestamp}; use alloc::collections::BTreeMap; #[cfg(feature = "cosmwasm_1_3")] use alloc::collections::BTreeSet; @@ -8,7 +9,6 @@ use bech32::{encode, Bech32, Hrp}; use core::marker::PhantomData; #[cfg(feature = "cosmwasm_1_3")] use core::ops::Bound; -use cosmwasm_core::{Addr, CanonicalAddr, Timestamp}; use rand_core::OsRng; use serde::de::DeserializeOwned; #[cfg(feature = "stargate")] @@ -1169,7 +1169,7 @@ mod tests { #[cfg(feature = "staking")] use crate::{Decimal, Delegation}; use base64::{engine::general_purpose, Engine}; - use cosmwasm_crypto::BLS12_381_G1_GENERATOR; + use cosmwasm_core::BLS12_381_G1_GENERATOR; use hex_literal::hex; use serde::Deserialize; diff --git a/packages/std/src/testing/mod.rs b/packages/std/src/testing/mod.rs index 61863743f0..59f080e374 100644 --- a/packages/std/src/testing/mod.rs +++ b/packages/std/src/testing/mod.rs @@ -3,10 +3,13 @@ // Exposed for testing only // Both unit tests and integration tests are compiled to native code, so everything in here does not need to compile to Wasm. +mod assertions; mod message_info; mod mock; -pub use cosmwasm_core::testing::*; +pub use assertions::assert_approx_eq_impl; +#[cfg(test)] +pub use assertions::assert_hash_works_impl; pub use message_info::message_info; #[allow(deprecated)] diff --git a/packages/core/src/timestamp.rs b/packages/std/src/timestamp.rs similarity index 98% rename from packages/core/src/timestamp.rs rename to packages/std/src/timestamp.rs index 837b976984..331304a03d 100644 --- a/packages/core/src/timestamp.rs +++ b/packages/std/src/timestamp.rs @@ -21,8 +21,19 @@ use crate::Uint64; /// assert_eq!(ts.seconds(), 3); /// assert_eq!(ts.subsec_nanos(), 202); /// ``` -#[derive(Serialize, Deserialize, Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "std", derive(schemars::JsonSchema))] +#[derive( + Serialize, + Deserialize, + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, +)] pub struct Timestamp(Uint64); impl Timestamp { diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index 038f17f994..72eb7e56d4 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -1,6 +1,5 @@ use core::marker::PhantomData; use core::ops::Deref; -use cosmwasm_core::{Addr, CanonicalAddr}; use serde::{de::DeserializeOwned, Serialize}; use crate::coin::Coin; @@ -27,6 +26,7 @@ use crate::query::{ use crate::results::{ContractResult, Empty, SystemResult}; use crate::ContractInfoResponse; use crate::{from_json, to_json_binary, to_json_vec, Binary}; +use crate::{Addr, CanonicalAddr}; #[cfg(feature = "cosmwasm_1_3")] use crate::{DenomMetadata, PageRequest}; use crate::{RecoverPubkeyError, StdError, StdResult, VerificationError}; diff --git a/packages/std/src/types.rs b/packages/std/src/types.rs index b2a20ec27d..f85d42e8a0 100644 --- a/packages/std/src/types.rs +++ b/packages/std/src/types.rs @@ -1,9 +1,9 @@ -use cosmwasm_core::{Addr, Timestamp}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::coin::Coin; use crate::prelude::*; +use crate::{Addr, Timestamp}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct Env { diff --git a/packages/core/testdata/instantiate2_addresses.json b/packages/std/testdata/instantiate2_addresses.json similarity index 100% rename from packages/core/testdata/instantiate2_addresses.json rename to packages/std/testdata/instantiate2_addresses.json diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 730961e662..b02ce20324 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -45,8 +45,9 @@ clru = "0.6.1" crc32fast = "1.3.2" bech32 = "0.11.0" # Uses the path when built locally; uses the given version from crates.io when published +cosmwasm-core = { version = "2.0.1", path = "../core" } cosmwasm-std = { version = "2.0.1", path = "../std", default-features = false, features = ["std"] } -cosmwasm-crypto = { version = "2.0.1", path = "../crypto", features = ["std"] } +cosmwasm-crypto = { version = "2.0.1", path = "../crypto" } derivative = "2" hex = "0.4" rand_core = { version = "0.6", features = ["getrandom"] } diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs index dde9e634a1..96df03672c 100644 --- a/packages/vm/src/calls.rs +++ b/packages/vm/src/calls.rs @@ -904,7 +904,7 @@ mod tests { for seed in 0..RUNS_PER_INSTRUCTION { // query some input values for the instruction let args: Vec = from_json( - &call_query( + call_query( &mut instance, &mock_env(), format!( diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 115cd5f33c..da745b762b 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -2,11 +2,11 @@ use std::marker::PhantomData; +use cosmwasm_core::{BLS12_381_G1_POINT_LEN, BLS12_381_G2_POINT_LEN}; use cosmwasm_crypto::{ bls12_381_aggregate_g1, bls12_381_aggregate_g2, bls12_381_hash_to_g1, bls12_381_hash_to_g2, bls12_381_pairing_equality, ed25519_batch_verify, ed25519_verify, secp256k1_recover_pubkey, secp256k1_verify, secp256r1_recover_pubkey, secp256r1_verify, CryptoError, HashFunction, - BLS12_381_G1_POINT_LEN, BLS12_381_G2_POINT_LEN, }; use cosmwasm_crypto::{ ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, EDDSA_PUBKEY_LEN, MESSAGE_HASH_MAX_LEN,