diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 9b076696..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,61 +0,0 @@ -version: 2.1 - -executors: - builder: - docker: - - image: buildpack-deps:trusty - -jobs: - docker-image: - executor: builder - steps: - - checkout - - setup_remote_docker - docker_layer_caching: true - - run: - name: Build Docker artifact - command: docker build --pull -t "cosmwasm/cw-gitpod-base:${CIRCLE_SHA1}" . - - run: - name: Push application Docker image to docker hub - command: | - if [ "${CIRCLE_BRANCH}" = "master" ]; then - docker tag "cosmwasm/cw-gitpod-base:${CIRCLE_SHA1}" cosmwasm/cw-gitpod-base:latest - docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS" - docker push cosmwasm/cw-gitpod-base:latest - docker logout - fi - - docker-tagged: - executor: builder - steps: - - checkout - - setup_remote_docker - docker_layer_caching: true - - run: - name: Push application Docker image to docker hub - command: | - docker tag "cosmwasm/cw-gitpod-base:${CIRCLE_SHA1}" "cosmwasm/cw-gitpod-base:${CIRCLE_TAG}" - docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS" - docker push - docker logout - -workflows: - version: 2 - test-suite: - jobs: - # this is now a slow process... let's only run on master - - docker-image: - filters: - branches: - only: - - master - - docker-tagged: - filters: - tags: - only: - - /^v.*/ - branches: - ignore: - - /.*/ - requires: - - docker-image diff --git a/Cargo.lock b/Cargo.lock index f4222f68..3adbf0d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,21 +46,21 @@ dependencies = [ [[package]] name = "atomic-order-example" -version = "0.1.0" +version = "0.2.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", "cw-multi-test", - "cw-storage-plus 0.16.0", + "cw-storage-plus 1.2.0", "cw-utils 0.16.0", "cw2 0.16.0", - "injective-cosmwasm 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "injective-math 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "injective-protobuf 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-cosmwasm", + "injective-math", + "injective-protobuf", "protobuf", "schemars", - "serde 1.0.192", + "serde 1.0.193", "thiserror", ] @@ -88,12 +88,24 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + [[package]] name = "base64ct" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + [[package]] name = "bitflags" version = "1.3.2" @@ -118,6 +130,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bnum" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab9008b6bb9fc80b5277f2fe481c09e828743d9151203e804583eb4c9e15b31d" + [[package]] name = "bumpalo" version = "3.14.0" @@ -211,22 +229,22 @@ dependencies = [ [[package]] name = "cosmwasm-schema" -version = "1.2.7" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "230e5d1cefae5331db8934763c81b9c871db6a2cd899056a5694fa71d292c815" +checksum = "0df41ea55f2946b6b43579659eec048cc2f66e8c8e2e3652fc5e5e476f673856" dependencies = [ "cosmwasm-schema-derive", "schemars", - "serde 1.0.192", + "serde 1.0.193", "serde_json 1.0.108", "thiserror", ] [[package]] name = "cosmwasm-schema-derive" -version = "1.2.7" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43dadf7c23406cb28079d69e6cb922c9c29b9157b0fe887e3b79c783b7d4bcb8" +checksum = "43609e92ce1b9368aa951b334dd354a2d0dd4d484931a5f83ae10e12a26c8ba9" dependencies = [ "proc-macro2", "quote", @@ -235,32 +253,34 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.7" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4337eef8dfaf8572fe6b6b415d6ec25f9308c7bb09f2da63789209fb131363be" +checksum = "04d6864742e3a7662d024b51a94ea81c9af21db6faea2f9a6d2232bb97c6e53e" dependencies = [ - "base64", + "base64 0.21.5", + "bech32", + "bnum", "cosmwasm-crypto", "cosmwasm-derive", "derivative", "forward_ref", "hex", "schemars", - "serde 1.0.192", + "serde 1.0.193", "serde-json-wasm 0.5.1", "sha2 0.10.8", + "static_assertions 1.1.0", "thiserror", - "uint 0.9.5", ] [[package]] name = "cosmwasm-storage" -version = "1.2.7" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8601d284db8776e39fe99b3416516c5636ca73cef14666b7bb9648ca32c4b89" +checksum = "bd2b4ae72a03e8f56c85df59d172d51d2d7dc9cec6e2bc811e3fb60c588032a4" dependencies = [ "cosmwasm-std", - "serde 1.0.192", + "serde 1.0.193", ] [[package]] @@ -333,14 +353,14 @@ checksum = "c2eb84554bbfa6b66736abcd6a9bfdf237ee0ecb83910f746dff7f799093c80a" dependencies = [ "anyhow", "cosmwasm-std", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.2.0", "cw-utils 1.0.1", "derivative", "itertools", "k256 0.11.6", "prost 0.9.0", "schemars", - "serde 1.0.192", + "serde 1.0.193", "thiserror", ] @@ -352,18 +372,18 @@ checksum = "d9b6f91c0b94481a3e9ef1ceb183c37d00764f8751e39b45fc09f4d9b970d469" dependencies = [ "cosmwasm-std", "schemars", - "serde 1.0.192", + "serde 1.0.193", ] [[package]] name = "cw-storage-plus" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0e92a069d62067f3472c62e30adedb4cab1754725c0f2a682b3128d2bf3c79" +checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" dependencies = [ "cosmwasm-std", "schemars", - "serde 1.0.192", + "serde 1.0.193", ] [[package]] @@ -377,7 +397,7 @@ dependencies = [ "cw2 0.16.0", "schemars", "semver", - "serde 1.0.192", + "serde 1.0.193", "thiserror", ] @@ -392,7 +412,7 @@ dependencies = [ "cw2 1.1.0", "schemars", "semver", - "serde 1.0.192", + "serde 1.0.193", "thiserror", ] @@ -406,7 +426,7 @@ dependencies = [ "cosmwasm-std", "cw-storage-plus 0.16.0", "schemars", - "serde 1.0.192", + "serde 1.0.193", ] [[package]] @@ -417,9 +437,9 @@ checksum = "29ac2dc7a55ad64173ca1e0a46697c31b7a5c51342f55a1e84a724da4eb99908" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.2.0", "schemars", - "serde 1.0.192", + "serde 1.0.193", "thiserror", ] @@ -511,14 +531,14 @@ dependencies = [ [[package]] name = "dummy" -version = "1.0.0" +version = "1.1.0" dependencies = [ "cosmwasm-std", - "cw-storage-plus 0.16.0", + "cw-storage-plus 1.2.0", "cw2 0.16.0", - "injective-cosmwasm 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-cosmwasm", "schemars", - "serde 1.0.192", + "serde 1.0.193", "thiserror", ] @@ -564,7 +584,7 @@ dependencies = [ "hashbrown", "hex", "rand_core 0.6.4", - "serde 1.0.192", + "serde 1.0.193", "sha2 0.9.9", "zeroize", ] @@ -658,7 +678,7 @@ dependencies = [ "ethbloom", "ethereum-types-serialize", "fixed-hash 0.3.2", - "serde 1.0.192", + "serde 1.0.193", "uint 0.5.0", ] @@ -668,7 +688,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1873d77b32bc1891a79dad925f2acbc318ee942b38b9110f9dbc5fbeffcea350" dependencies = [ - "serde 1.0.192", + "serde 1.0.193", ] [[package]] @@ -805,7 +825,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" dependencies = [ - "serde 1.0.192", + "serde 1.0.193", ] [[package]] @@ -861,76 +881,44 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58e3cae7e99c7ff5a995da2cf78dd0a5383740eda71d98cf7b1910c301ac69b8" dependencies = [ - "serde 1.0.192", + "serde 1.0.193", ] [[package]] name = "injective-cosmwasm" -version = "0.2.17" +version = "0.2.18" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 0.16.0", + "cw-storage-plus 1.2.0", "ethereum-types", "hex", - "injective-math 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-math", "schemars", - "serde 1.0.192", - "serde-json-wasm 0.4.1", + "serde 1.0.193", + "serde-json-wasm 1.0.0", "serde_repr", "serde_test", "subtle-encoding", "tiny-keccak", ] -[[package]] -name = "injective-cosmwasm" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd6a4f3cf857a24f7603bdc9faf08ff8d7385dec809f3a2459fe9c403b9f3c1" -dependencies = [ - "cosmwasm-std", - "cw-storage-plus 0.16.0", - "ethereum-types", - "hex", - "injective-math 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "schemars", - "serde 1.0.192", - "serde_repr", - "subtle-encoding", - "tiny-keccak", -] - [[package]] name = "injective-math" -version = "0.2.3" +version = "0.2.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "ethereum-types", "primitive-types", "schemars", - "serde 1.0.192", - "subtle-encoding", -] - -[[package]] -name = "injective-math" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a377b42d309a85a5661ebcd50f9a218097efdc21c6e7709746ce07530bb9733" -dependencies = [ - "cosmwasm-std", - "ethereum-types", - "primitive-types", - "schemars", - "serde 1.0.192", + "serde 1.0.193", "subtle-encoding", ] [[package]] name = "injective-protobuf" -version = "0.2.1" +version = "0.2.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -939,29 +927,13 @@ dependencies = [ "protobuf", "protobuf-codegen-pure", "schemars", - "serde 1.0.192", - "subtle-encoding", -] - -[[package]] -name = "injective-protobuf" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48b6e4054ec0f985961f0f9db730118419c5b8903da36a4e5e219ff06874acd" -dependencies = [ - "cosmwasm-std", - "ethereum-types", - "num 0.4.1", - "protobuf", - "protobuf-codegen-pure", - "schemars", - "serde 1.0.192", + "serde 1.0.193", "subtle-encoding", ] [[package]] name = "injective-std" -version = "0.1.4" +version = "0.1.5" dependencies = [ "chrono", "cosmwasm-std", @@ -969,23 +941,23 @@ dependencies = [ "prost 0.11.9", "prost-types", "schemars", - "serde 1.0.192", + "serde 1.0.193", "serde-cw-value", ] [[package]] name = "injective-testing" -version = "0.1.5" +version = "0.1.6" dependencies = [ "anyhow", - "base64", + "base64 0.13.1", "cosmwasm-std", "cw-multi-test", - "injective-cosmwasm 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "injective-math 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-cosmwasm", + "injective-math", "rand 0.4.6", "secp256k1", - "serde 1.0.192", + "serde 1.0.193", "tiny-keccak", ] @@ -1467,22 +1439,22 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "schemars" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "enumset", "schemars_derive", - "serde 1.0.192", + "serde 1.0.193", "serde_json 1.0.108", ] [[package]] name = "schemars_derive" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -1550,9 +1522,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] @@ -1563,32 +1535,32 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75d32da6b8ed758b7d850b6c3c08f1d7df51a4df3cb201296e63e34a78e99d4" dependencies = [ - "serde 1.0.192", + "serde 1.0.193", ] [[package]] name = "serde-json-wasm" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" +checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" dependencies = [ - "serde 1.0.192", + "serde 1.0.193", ] [[package]] name = "serde-json-wasm" -version = "0.5.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" +checksum = "83c37d03f3b0f6b5f77c11af1e7c772de1c9af83e50bef7bb6069601900ba67b" dependencies = [ - "serde 1.0.192", + "serde 1.0.193", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -1624,7 +1596,7 @@ checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", - "serde 1.0.192", + "serde 1.0.193", ] [[package]] @@ -1644,7 +1616,7 @@ version = "1.0.176" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a2f49ace1498612d14f7e0b8245519584db8299541dfe31a06374a828d620ab" dependencies = [ - "serde 1.0.192", + "serde 1.0.193", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6a707c49..a3df4fb8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,22 +1,25 @@ [workspace] -members = ["packages/*", "contracts/*"] +members = [ "contracts/*", "packages/*" ] resolver = "2" [profile.release.package.injective-cosmwasm] codegen-units = 1 -incremental = false +incremental = false [profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true +codegen-units = 1 +debug = false debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true +incremental = false +lto = true +opt-level = 3 +overflow-checks = true +panic = 'abort' +rpath = false [patch.crates-io] -#cw-multi-test = { path = "../cw-multi-test" } -#cw-multi-test = { git = "https://github.com/InjectiveLabs/cw-multi-test.git", branch ="feature/custom_address_generator" } +# injective-cosmwasm = { path = "./packages/injective-cosmwasm" } +# injective-math = { path = "./packages/injective-math" } +# injective-protobuf = { path = "./packages/injective-protobuf" } +# injective-std = { path = "./packages/injective-std" } +# injective-testing = { path = "./packages/injective-testing" } diff --git a/NOTICE b/NOTICE index 66798b47..8cf246dd 100644 --- a/NOTICE +++ b/NOTICE @@ -1,4 +1,4 @@ -Copyright 2022 Albert Chon +Copyright 2024 Injective Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/contracts/atomic-order-example/Cargo.toml b/contracts/atomic-order-example/Cargo.toml index 47437848..8a75b928 100644 --- a/contracts/atomic-order-example/Cargo.toml +++ b/contracts/atomic-order-example/Cargo.toml @@ -1,25 +1,25 @@ [package] -name = "atomic-order-example" -version = "0.1.0" -authors = ["Antoni Mysliborski "] +authors = [ "Markus Waas " ] edition = "2021" +name = "atomic-order-example" +version = "0.2.0" exclude = [ - # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. - "contract.wasm", - "hash.txt", + # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. + "contract.wasm", + "hash.txt", ] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -crate-type = ["cdylib", "rlib"] +crate-type = [ "cdylib", "rlib" ] [features] # for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] +backtraces = [ "cosmwasm-std/backtraces" ] # use library feature to disable all instantiate/execute/query exports -library = [] +library = [ ] [package.metadata.scripts] optimize = """docker run --rm -v "$(pwd)":/code \ @@ -29,19 +29,19 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -cosmwasm-std = { version = "1.2.7", features = [ "abort", "iterator", "stargate" ] } -cosmwasm-storage = { version = "1.2.7", features = [ "iterator" ] } -cw-storage-plus = { version = "0.16.0" } -cw2 = { version = "0.16.0" } -cw-utils = { version = "0.16.0" } -schemars = { version = "0.8.8", features = [ "enumset" ] } -serde = { version = "1.0.137", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.31" } -injective-cosmwasm = { version = "0.2.17" } -injective-math = { version = "0.2.3" } -protobuf = { version = "2.28.0", features = ["with-bytes"] } -injective-protobuf = { version = "0.2.1" } +cosmwasm-std = { version = "1.5.0", features = [ "abort", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "iterator", "stargate" ] } +cosmwasm-storage = { version = "1.5.0", features = [ "iterator" ] } +cw-storage-plus = { version = "1.2.0" } +cw-utils = { version = "0.16.0" } +cw2 = { version = "0.16.0" } +injective-cosmwasm = { version = "0.2.18", path = "../../packages/injective-cosmwasm" } +injective-math = { version = "0.2.4", path = "../../packages/injective-math" } +injective-protobuf = { version = "0.2.2", path = "../../packages/injective-protobuf" } +protobuf = { version = "2.28.0", features = [ "with-bytes" ] } +schemars = { version = "0.8.8", features = [ "enumset" ] } +serde = { version = "1.0.137", default-features = false, features = [ "derive" ] } +thiserror = { version = "1.0.31" } [dev-dependencies] -cosmwasm-schema = { version = "1.2.7" } -cw-multi-test = { version = "0.16.2" } +cosmwasm-schema = { version = "1.5.0" } +cw-multi-test = { version = "0.16.2" } diff --git a/contracts/atomic-order-example/NOTICE b/contracts/atomic-order-example/NOTICE index 67258e4c..8cf246dd 100644 --- a/contracts/atomic-order-example/NOTICE +++ b/contracts/atomic-order-example/NOTICE @@ -1,4 +1,4 @@ -Copyright 2022 Antoni Mysliborski +Copyright 2024 Injective Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/contracts/atomic-order-example/src/helpers.rs b/contracts/atomic-order-example/src/helpers.rs index 30567ade..3f3fe182 100644 --- a/contracts/atomic-order-example/src/helpers.rs +++ b/contracts/atomic-order-example/src/helpers.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdResult, SubMsg, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, CosmosMsg, StdResult, SubMsg, WasmMsg}; use injective_cosmwasm::InjectiveMsgWrapper; use injective_math::FPDecimal; use schemars::JsonSchema; @@ -17,7 +17,7 @@ impl CwTemplateContract { } pub fn call>(&self, msg: T) -> StdResult { - let msg = to_binary(&msg.into())?; + let msg = to_json_binary(&msg.into())?; Ok(WasmMsg::Execute { contract_addr: self.addr().into(), msg, diff --git a/contracts/atomic-order-example/src/tests.rs b/contracts/atomic-order-example/src/tests.rs index d4ef719f..7dc618c7 100644 --- a/contracts/atomic-order-example/src/tests.rs +++ b/contracts/atomic-order-example/src/tests.rs @@ -2,8 +2,8 @@ use std::str::FromStr; use cosmwasm_std::testing::{mock_info, MockApi, MockStorage}; use cosmwasm_std::{ - coins, to_binary, BankMsg, Binary, ContractResult, CosmosMsg, OwnedDeps, QuerierResult, Reply, - SubMsgResponse, SubMsgResult, SystemResult, Uint128, + coins, to_json_binary, BankMsg, Binary, ContractResult, CosmosMsg, OwnedDeps, QuerierResult, + Reply, SubMsgResponse, SubMsgResult, SystemResult, Uint128, }; use injective_cosmwasm::InjectiveMsg::CreateSpotMarketOrder; @@ -138,7 +138,7 @@ fn create_spot_market_handler() -> impl HandlesMarketIdQuery { min_quantity_tick_size: FPDecimal::from_str("1000000000000000").unwrap(), }), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Temp() diff --git a/contracts/dummy/Cargo.toml b/contracts/dummy/Cargo.toml index a1d6102a..d5586880 100644 --- a/contracts/dummy/Cargo.toml +++ b/contracts/dummy/Cargo.toml @@ -1,25 +1,25 @@ [package] -name = "dummy" -version = "1.0.0" -authors = ["Bartek Tofel "] -edition = "2018" +authors = [ "Markus Waas " ] +edition = "2021" +name = "dummy" +version = "1.1.0" exclude = [ - # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. - "contract.wasm", - "hash.txt", + # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. + "contract.wasm", + "hash.txt", ] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -crate-type = ["cdylib", "rlib"] +crate-type = [ "cdylib", "rlib" ] [features] # for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] +backtraces = [ "cosmwasm-std/backtraces" ] # use library feature to disable all instantiate/execute/query exports -library = [] +library = [ ] [package.metadata.scripts] optimize = """docker run --rm -v "$(pwd)":/code \ @@ -29,10 +29,10 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -cosmwasm-std = { version = "1.2.7", features = [ "abort", "iterator", "stargate" ] } -cw-storage-plus = { version = "0.16.0" } -cw2 = { version = "0.16.0" } -serde = { version = "1.0.136", default-features = false, features = ["derive"] } -schemars = "0.8.8" -thiserror = { version = "1.0.30" } -injective-cosmwasm = { version = "0.2.17" } +cosmwasm-std = { version = "1.5.0", features = [ "abort", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "iterator", "stargate" ] } +cw-storage-plus = { version = "1.2.0" } +cw2 = { version = "0.16.0" } +injective-cosmwasm = { version = "0.2.18", path = "../../packages/injective-cosmwasm" } +schemars = "0.8.8" +serde = { version = "1.0.136", default-features = false, features = [ "derive" ] } +thiserror = { version = "1.0.30" } diff --git a/contracts/dummy/NOTICE b/contracts/dummy/NOTICE index f9345247..42f6b337 100644 --- a/contracts/dummy/NOTICE +++ b/contracts/dummy/NOTICE @@ -1,4 +1,4 @@ -Copyright 2022 Venkatesh Mankena +Copyright 2024 InjectiveLabs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/contracts/dummy/src/contract.rs b/contracts/dummy/src/contract.rs index 2776b61e..b1c2378f 100644 --- a/contracts/dummy/src/contract.rs +++ b/contracts/dummy/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, + to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, }; use cw2::set_contract_version; use cw_storage_plus::Item; @@ -44,7 +44,7 @@ pub fn execute( match msg { ExecuteMsg::Ping { .. } => { let mut response = Response::new(); - response.data = Some(to_binary("pong")?); + response.data = Some(to_json_binary("pong")?); Ok(response) } ExecuteMsg::Error { .. } => Err(ContractError::Std(StdError::generic_err("oh no!"))), @@ -71,15 +71,15 @@ pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> Result StdResult { match msg { - QueryMsg::Ping { .. } => to_binary("pong"), + QueryMsg::Ping { .. } => to_json_binary("pong"), QueryMsg::Error { .. } => Err(StdError::generic_err("oh no!")), QueryMsg::Runs {} => { let runs_count = COUNTER.load(deps.storage)?; - to_binary(&format!("{runs_count}")) + to_json_binary(&format!("{runs_count}")) } QueryMsg::Active {} => { let is_active = ACTIVE.load(deps.storage)?; - to_binary(&format!("{is_active}")) + to_json_binary(&format!("{is_active}")) } } } diff --git a/packages/injective-cosmwasm/Cargo.toml b/packages/injective-cosmwasm/Cargo.toml index 65ef006b..4ba81d20 100644 --- a/packages/injective-cosmwasm/Cargo.toml +++ b/packages/injective-cosmwasm/Cargo.toml @@ -1,32 +1,27 @@ [package] -authors = [ - "Albert Chon ", - "Bartek Tofel ", - "F Grabner ", - "Markus Waas ", -] +authors = [ "Albert Chon ", "F Grabner ", "Markus Waas " ] description = "Bindings for CosmWasm contracts to call into custom modules of Injective Core" -edition = "2018" -license = "Apache-2.0" -name = "injective-cosmwasm" -readme = "README.md" -repository = "https://github.com/InjectiveLabs/cw-injective/tree/master/packages/bindings" -version = "0.2.17" +edition = "2021" +license = "Apache-2.0" +name = "injective-cosmwasm" +readme = "README.md" +repository = "https://github.com/InjectiveLabs/cw-injective/tree/dev/packages/injective-cosmwasm" +version = "0.2.18" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "=1.2.7", features = [ "abort", "iterator", "stargate" ] } -cw-storage-plus = { version = "=0.16.0" } -ethereum-types = { version = "0.5.2" } +cosmwasm-std = { version = "1.5.0", features = [ "abort", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "iterator", "stargate" ] } +cw-storage-plus = { version = "1.2.0" } +ethereum-types = { version = "0.5.2" } hex = { version = "0.4.3", features = [ "serde" ] } -injective-math = { version = "0.2.3" } -schemars = "0.8.8" -serde = { version = "1.0.136", default-features = false, features = [ "derive" ] } -serde_repr = "0.1" +injective-math = { version = "0.2.4", path = "../injective-math" } +schemars = "0.8.16" +serde = { version = "1.0.193", default-features = false, features = [ "derive" ] } +serde_repr = "0.1.17" subtle-encoding = { version = "0.5.1", features = [ "bech32-preview" ] } tiny-keccak = "1.2.1" [dev-dependencies] -cosmwasm-schema = { version = "=1.2.7" } -serde-json-wasm = { version = "0.4.1" } -serde_test = { version = "1.0.166" } +cosmwasm-schema = { version = "1.5.0" } +serde-json-wasm = { version = "1.0.0" } +serde_test = { version = "1.0.176" } diff --git a/packages/injective-cosmwasm/README.md b/packages/injective-cosmwasm/README.md index c5457df0..d5809d9e 100644 --- a/packages/injective-cosmwasm/README.md +++ b/packages/injective-cosmwasm/README.md @@ -1 +1,264 @@ # injective-cosmwasm + +
+

+ +

+

β—¦ injective-cosmwasm

+ +

+Rust +

+
+ +--- + +## πŸ“– Table of Contents + +- [πŸ“– Table of Contents](#-table-of-contents) +- [πŸ“ Overview](#-overview) +- [πŸ“¦ Features](#-features) +- [πŸ“‚ repository Structure](#-repository-structure) +- [βš™οΈ Modules](#modules) +- [πŸš€ Getting Started](#-getting-started) + - [πŸ”§ Installation](#-installation) + - [πŸ€– Running ](#-running-) + - [πŸ§ͺ Tests](#-tests) +- [πŸ›£ Roadmap](#-roadmap) +- [🀝 Contributing](#-contributing) +- [πŸ“„ License](#-license) +- [πŸ‘ Acknowledgments](#-acknowledgments) + +--- + +## πŸ“ Overview + +`injective-cosmwasm` is designed for integration with the Injective chain, thereby enabling smart contract interactions and complex financial operations. It is a Rust-based library to be used with CosmWasm smart contract. It provides bindings for Injective-specific queries and messages, as well as some helpers. + +--- + +## πŸ“¦ Features + +Exception: + +--- + +## πŸ“‚ Repository Structure + +```sh +└── / + β”œβ”€β”€ Cargo.toml + └── src/ + β”œβ”€β”€ authz/ + β”‚ β”œβ”€β”€ mod.rs + β”‚ └── response.rs + β”œβ”€β”€ exchange/ + β”‚ β”œβ”€β”€ cancel.rs + β”‚ β”œβ”€β”€ derivative.rs + β”‚ β”œβ”€β”€ derivative_market.rs + β”‚ β”œβ”€β”€ market.rs + β”‚ β”œβ”€β”€ mod.rs + β”‚ β”œβ”€β”€ order.rs + β”‚ β”œβ”€β”€ privileged_action.rs + β”‚ β”œβ”€β”€ response.rs + β”‚ β”œβ”€β”€ spot.rs + β”‚ β”œβ”€β”€ spot_market.rs + β”‚ β”œβ”€β”€ subaccount.rs + β”‚ └── types.rs + β”œβ”€β”€ exchange_mock_querier.rs + β”œβ”€β”€ lib.rs + β”œβ”€β”€ msg.rs + β”œβ”€β”€ oracle/ + β”‚ β”œβ”€β”€ mod.rs + β”‚ β”œβ”€β”€ response.rs + β”‚ β”œβ”€β”€ types.rs + β”‚ └── volatility.rs + β”œβ”€β”€ querier.rs + β”œβ”€β”€ query.rs + β”œβ”€β”€ route.rs + β”œβ”€β”€ test_helpers.rs + β”œβ”€β”€ tokenfactory/ + β”‚ β”œβ”€β”€ mod.rs + β”‚ β”œβ”€β”€ response.rs + β”‚ └── types.rs + β”œβ”€β”€ vesting/ + └── wasmx/ + β”œβ”€β”€ mod.rs + β”œβ”€β”€ response.rs + └── types.rs + +``` + +--- + +## βš™οΈ Modules + +
Root + +| File | Summary | +| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [Cargo.toml]({file_path}) | The Rust code configures a package named `injective-cosmwasm`, designed to provide bindings for CosmWasm contracts to interact with Injective Core's custom modules. Authored by contributors from InjectiveLabs, it is open-source with an Apache 2.0 license. The library uses the 2021 edition of Rust and includes various dependencies for blockchain and serialization functionality, such as `cosmwasm-std` and `serde`. It supports features like aborting, iterators, and Stargate, with compatibility for multiple CosmWasm versions. | + +
+ +
Src + +| File | Summary | +| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [route.rs]({file_path}) | The code defines an `InjectiveRoute` enum that represents different query route paths for an Injective protocol, such as `Authz`, `Exchange`, `Tokenfactory`, `Staking`, `Oracle`, and `Wasmx`. It is serialized using a case-insensitive format suitable for URL path segments and can be used to match query types with their respective modules within the project directory. The provided directory tree suggests the project is a Rust-based trading/financial application with a focus on areas like authorization, market exchange, and oracles. | +| [lib.rs]({file_path}) | The code is a Rust module that defines the public interface and dependencies for a trading platform on a blockchain that supports injective protocols. It exports types, messages, and queries for working with derivative and spot markets, including order creation, cancellation, and position management. The module also handles oracle price feeds, market queries, and authz (authorization) functionalities. Utilities for testing are included but gated behind a non-WASM target condition. Core features like market data, account management, and trade execution are encapsulated within separate submodules. The platform interfaces with an external Injective blockchain protocol through a specified query and messaging system. | +| [query.rs]({file_path}) | This Rust code defines a custom query system for the Injective Protocol, handling queries related to authorization (authz), exchange operations (including spot and derivative markets, orders, cancellations, positions, and pricing), staking, oracle data coordination, and specific web assembly module information (wasmx). It models a range of requests encapsulated in `InjectiveQuery`, which can query various parameters and states within the trading platform. These include user permissions, market specifics, order books, trade volume, pricing, oracle volatility, and contractual details, all accessed through a `InjectiveQueryWrapper` with distinct routing for each query type. | +| [test_helpers.rs]({file_path}) | The `test_helpers.rs` module in a Rust project provides testing utilities for a blockchain-based exchange platform. It includes constants for test market IDs and contract addresses, along with functions to generate a mock testing environment (`inj_mock_env`), manipulate dependencies (`OwnedDepsExt`), and create a `MockApi`, `MockStorage`, and custom querier (`inj_mock_deps`). Additionally, it provides a way to create mock spot market instances (`create_mock_spot_market`) with predefined parameters for testing market operations. The module is architected for non-WebAssembly targets and leverages the `cosmwasm_std` and `injective_math` crates for blockchain and mathematical operations, respectively. | +| [msg.rs]({file_path}) | The code provides a set of message constructors for a blockchain-related application, specifically for the Cosmos SDK with customizations for the Injective protocol. It defines an `InjectiveMsg` enum with various transaction types for managing subaccounts, token transfers, order creation/cancellation, market operations, and administrative actions for both spot and derivative markets. Additionally, it furnishes functions to create Cosmos messages wrapped in `InjectiveMsgWrapper` to be dispatched within the blockchain network. The code handles deposit, withdrawal, subaccount transfer, spot and derivative market orders, liquidation, reward opt-out, and contract activation, among other functionalities. It includes custom serialization and integration with the blockchain's query and execution layers. | +| [querier.rs]({file_path}) | The provided Rust code defines a `InjectiveQuerier` struct that offers various methods for querying blockchain data, interfacing with modules such as `Authz`, `Exchange`, `Oracle`, `Tokenfactory`, and `Wasmx`. These methods assemble requests, querying for things like grant permissions, exchange parameters, market information, deposited funds, order books, market volatilities, and oracle prices. The querier is designed for an environment where access to the blockchain state is facilitated through a wrapper that translates these queries into requests that can be understood by the underlying infrastructure. The code ensures type safety and modular interaction with different parts of the blockchain. | +| [exchange_mock_querier.rs]({file_path}) | This Rust module provides a mock querier (`WasmMockQuerier`) to simulate blockchain queries during testing of a trading platform. The querier can handle various financial and blockchain-related queries including market data (spot and derivatives), order books, account balances, token supplies, and oracle prices. It uses mock API and storage to mimic the behavior of a blockchain, leveraging the `InjectiveQueryWrapper` type to represent custom query functionality specific to the Injective protocol. | + +
+ +
Wasmx + +| File | Summary | +| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [response.rs]({file_path}) | The provided Rust project structure implements a trading exchange with authorization, market handling (spot and derivative), subaccounts, and an oracle for data. It includes a mock querier for testing and auxiliary modules for message routing, querying, and helpers. The code snippet defines a serializable response type for querying contract registration information within the `wasmx` module, including an optional `RegisteredContract`. | +| [types.rs]({file_path}) | The code defines data structures in Rust for managing smart contracts on a blockchain platform. It includes an `enum` for funding modes (`FundingMode`) with options like `SelfFunded` and `GrantOnly`, and a `struct` (`RegisteredContract`) describing contract properties such as gas limits, prices, executability, and administrative controls. The `RegisteredContract` also includes optional fields for specifying code identifiers and administrative or granter addresses, with serialization supported by `serde` and `JsonSchema` for JSON compatibility. | +| [mod.rs]({file_path}) | This Rust project is structured into multiple modules that handle different aspects of a trading platform. The core functionalities likely include authorization (`authz`), market trading operations for both spot and derivatives (`exchange`), querying off-chain data (`oracle`), mocks for testing (`exchange_mock_querier`), message handling (`msg`), and abstractions for smart contract interactions (`wasmx`). Each module contains types and responses specific to its domain. The main library entry point is `lib.rs`, while `mod.rs` files serve as module declarations. | + +
+ +
Exchange + +| File | Summary | +| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [response.rs]({file_path}) | The Rust code defines serialization for various response structures used in a crypto exchange platform. These responses include exchange parameters, subaccount deposits, positions, market info (spot and derivatives), order details, market prices, volatility statistics, staked amounts, order books, aggregate volumes, denom decimals, and fee multipliers. Each structure is serializable, using libraries `serde` and `schemars`, and contains optional or vector-typed properties depending on the expected data, to be returned in crypto exchange-related queries. | +| [types.rs]({file_path}) | The code in `types.rs` defines several data structures for a cryptocurrency exchange system using CosmWasm, which is a smart contracting platform compatible with the Cosmos ecosystem. Key structures include:-`Params`: Configures exchange parameters such as fees, margin ratios, and access levels for different trading and listing operations.-`Deposit`: Represents a subaccount's deposit details with available and total balances.-`DenomDecimals`: Stores decimal precision for a currency denomination.-`PriceLevel`: Represents a price level with price (p) and quantity (q).-`VolumeByType`: Distinguishes between maker and taker trading volumes.-`MarketVolume`: Combines `VolumeByType` with a market identifier.-`MarketType`: Enum distinguishing Spot and Derivative markets.-`AtomicMarketOrderAccessLevel`: Enum for market order access control.-`MarketId`: Represents a market ID with checks for a 0x prefix and fixed length.-`SubaccountId`: Represents a subaccount ID with similar validation as `MarketId`.-`ShortSubaccountId`: Shortened subaccount ID for quick access, with validation and serialization methods.-`Hash`: Encapsulates a 32-byte hash, allowing for hexadecimal conversion.The code ensures data integrity through custom serialization/deserialization logic and provides helper functions and methods for data manipulation involving market and subaccount IDs. It also includes thorough unit tests to validate the correctness of these components. | +| [market.rs]({file_path}) | The `market.rs` file defines a `MarketStatus` enum representing various states of a market, and a `GenericMarket` trait outlining the essential functionality for a market entity in a financial exchange system. This includes retrieving market identifiers, status, ticker information, fee rates, and minimum quote increments. The `MarketStatus` has five states, including an `Unspecified` default. The properties and actions related to markets are given in terms of abstract operations, likely to be implemented by specific market types. | +| [order.rs]({file_path}) | The code provides structures and functionality for managing and querying order data within a cryptocurrency exchange system built on the Cosmos SDK. It includes enums for `OrderSide` and `OrderType` with serialization options; structures like `OrderData`, `ShortOrderData`, `OrderInfo`, and `ShortOrderInfo` for holding order details with conversion implementations; traits `GenericOrder` and `GenericTrimmedOrder` defining common behaviors for various order types; and a test case ensuring correct serialization of `OrderType`. It utilizes external libraries like `cosmwasm_std`, `injective_math`, and `serde` for blockchain interaction, precise decimal arithmetic, and JSON serialization respectively. | +| [derivative_market.rs]({file_path}) | The provided Rust code defines data structures and an implementation for managing derivative markets within a trading platform. It includes details for perpetual markets such as funding rates and intervals, and comprehensive market information like ticker, fees, margin ratios, and status. Derivative markets can also be perpetual, and their pricing is linked to an oracle system. The structures are serializable and include traits for accessing key market parameters such as fees, ticker, and status, ensuring integration with broader system functionalities. | +| [cancel.rs]({file_path}) | The provided Rust module `cancel.rs` defines an enumeration `CancellationStrategy` with serialization capabilities, representing strategies for order cancellation within a trading exchange context. The strategies include canceling unspecified orders, from worst to best, and from best to worst price conditions. This code is part of a larger project structure focused on cryptocurrency exchange operations, including authorization, market types, order management, and auxiliary services. | +| [subaccount.rs]({file_path}) | The code defines functions for managing subaccount IDs within a trading system, specifically converting between human-readable, Bech32 Cosmos addresses and Ethereum hex addresses. It generates a unique subaccount ID from a Cosmos address, using an optional nonce. It also checks whether a subaccount ID is a default one, based on its nonce, and converts subaccount IDs to either Ethereum or Bech32 Cosmos addresses. The included tests validate these conversion operations. Error handling assumes valid inputs and fails otherwise. | +| [spot_market.rs]({file_path}) | The provided Rust code defines a `SpotMarket` struct with properties for a financial spot market, including fees, denominations, and tick sizes, and implements the `GenericMarket` trait for common market operations. It also includes a function `calculate_spot_market_id` to generate a market ID based on the concatenation of base and quote denominations using a Keccak hash. A test verifies the ID generation correctness for a given base and quote. The entire code is part of an exchange module within a larger application, likely related to cryptocurrency trading. | +| [mod.rs]({file_path}) | The provided code structure represents a Rust project with a focus on cryptocurrency exchange functionality. The `exchange` module, defined in `src/exchange/mod.rs`, is a central part of the application, organizing related exchange features such as order management, market types (spot and derivative markets), subaccounts, and the cancellation and privileged actions on orders, among other things. Each feature has a dedicated module within the `exchange` directory suggesting a modular codebase designed for handling various aspects of trading operations within a cryptocurrency exchange platform. | +| [derivative.rs]({file_path}) | The Rust code defines data structures and methods for managing orders and positions in a derivatives exchange system. It includes types such as `Position`, `DerivativePosition`, `DerivativeOrder`, `EffectivePosition`, `ShortDerivativeOrder`, `DerivativeLimitOrder`, and `DerivativeMarketOrder`, along with traits `GenericOrder` and `GenericTrimmedOrder`. Positions calculate value with or without funding, apply funding, and are identified by market and subaccount. Orders include order types, price, quantity, margin, and optional trigger prices. Orders can be checked for validity, whether they are buy/sell, reduce-only, post-only, or atomic, and can be converted to shortened forms. Functionality for placing, managing, and valuing derivative trading contracts is encapsulated, featuring operations like creating new orders, calculating position or order values, and applying funding adjustments. | +| [spot.rs]({file_path}) | The code defines data structures and behaviors for different kinds of spot market orders in a trading platform, using Rust with libraries for blockchain-related functionalities. `SpotLimitOrder` and `SpotMarketOrder` represent limit and market orders with properties like order type, price, quantity, fillability, and a trigger price. `SpotOrder` encapsulates basic order details without fillable quantity, while `ShortSpotOrder` presents a more concise version of `SpotOrder`. Conversions between order types are supported. Order trait implementations provide common behaviors to determine order characteristics (e.g., buy/sell, type, price). `MsgCreateSpotMarketOrderResponse` wraps the response for creating a market order, including the order hash and execution results. | +| [privileged_action.rs]({file_path}) | The Rust module `privileged_action.rs` defines data structures for representing synthetic trades and position transfers in a financial exchange context, utilizing custom fixed-point decimal types for precision. `SyntheticTrade` holds trade details, `SyntheticTradeAction` aggregates user and contract trades, while `PositionTransferAction` describes the transfer of a position from one subaccount to another. `PrivilegedAction` optionally combines synthetic trades and position transfers. Additionally, there's a utility function `coins_to_string` to convert a list of `Coin` objects to a comma-separated string. | + +
+ +
Oracle + +| File | Summary | +| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [response.rs]({file_path}) | The Rust code defines two data structures for oracle responses, `OraclePriceResponse` and `PythPriceResponse`, which contain optional fields representing the state of price pairs and Pyth price, respectively. Both structures are serializable, facilitating compatibility with JSON-based protocols and schema generation for API documentation. This is part of a larger financial trading platform, as indicated by the directory structure including modules for authorization, market exchange types, oracles, and token factory. | +| [types.rs]({file_path}) | The provided code defines data structures for querying and handling oracle price data within a Rust-based blockchain or financial application. It includes types for representing oracle information, historical options, and responses, including volatility and pricing data. There is also a variety of oracle types, along with Pyth-specific types, which encapsulate individual price attestations, market status, and aggregated pricing data. The common theme is serialization and schema support for these structures, likely for communication over a network or interaction with a blockchain. | +| [volatility.rs]({file_path}) | The `volatility.rs` module defines structures to model and serialize metadata statistics, trade history options, price, and trade records pertaining to an oracle in a Rust project focused on exchange operations. These entities encompass data such as count, sample size, mean, timestamps, price statistics, trade grouping, raw history inclusion, and quantity of traded assets, leveraging `FPDecimal` for financial precision. | +| [mod.rs]({file_path}) | The directory structure indicates a Rust project with multiple modules, focused on a trading exchange with features for spot and derivative markets, authorization, and an oracle for external data. The `src` directory contains the main library and modules, each with response handlers and type definitions. The `oracle/mod.rs` file serves as the module declaration for the oracle, pulling in response handling, types, and volatility-related functionality. | + +
+ +
Tokenfactory + +| File | Summary | +| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [response.rs]({file_path}) | The code defines two Rust data structures representing responses for a blockchain-based token factory module, using standard serialization libraries. `TokenFactoryDenomSupplyResponse` encapsulates the total supply of a token denomination, while `TokenFactoryCreateDenomFeeResponse` details the fee required to create a new token denomination, both as vectors of `Coin` structures. These structures are part of a larger financial trading platform, as denoted by sibling directories such as authz, exchange, and oracle. | +| [types.rs]({file_path}) | The provided directory tree structure outlines a Rust project that includes a Cargo.toml for dependency management. The source folder (src) contains several modules, including authz, exchange, oracle, tokenfactory, vesting, and wasmx, each dedicated to different functionalities such as authorization, trading mechanisms, queries to oracles, token factory operations, vesting schedules, and interactions with WebAssembly modules, respectively. The specified file (src/tokenfactory/types.rs) likely contains type definitions for the tokenfactory module, which would be used for creating and managing tokens within the system. | +| [mod.rs]({file_path}) | The code represents a modular Rust project structure for a trading platform with authorization, exchange functionality including derivative and spot markets, and an oracle for data services. Components include market management, order processing, privileged actions, types definitions, mock queriers, messaging, queries, routing, and token factory management. The specific file `src/tokenfactory/mod.rs` declares the `response` module as part of the token factory subsystem. | + +
+ +
Authz + +| File | Summary | +| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [response.rs]({file_path}) | The code defines Rust data structures for representing and serializing authorization grants and associated responses, including pagination. It includes the `Grant` structure detailing an authorization with its expiration, and `GrantAuthorization` which extends `Grant` with granter and grantee information. Additionally, `PageResponse` facilitates paginated results, while `GrantsResponse`, `GranteeGrantsResponse`, and `GranterGrantsResponse` wrap grant data with pagination details. The structures use Serde for serialization/deserialization and Schemars for JSON schema representations. | +| [mod.rs]({file_path}) | The code structure indicates a Rust project with a focus on a cryptocurrency exchange platform. Specifically, `src/authz/mod.rs` implies the authorization module may handle permissions and security, and it imports `response.rs` which might define response structs or enums for authorization operations. Other directories like `exchange`, `oracle`, and `tokenfactory` suggest functionalities for trading, market data, and token management, respectively, while `vesting` and `wasmx` imply features for token vesting and possibly WebAssembly integration. | + +
+ +--- + +## πŸš€ Getting Started + +**_Dependencies_** + +Please ensure you have the following dependencies installed on your system: + +`- ℹ️ Dependency 1` + +`- ℹ️ Dependency 2` + +`- ℹ️ ...` + +### πŸ”§ Installation + +1. Clone the repository: + +```sh +git clone ../ +``` + +2. Change to the project directory: + +```sh +cd +``` + +3. Install the dependencies: + +```sh +cargo build +``` + +### πŸ€– Running + +```sh +cargo run +``` + +### πŸ§ͺ Tests + +```sh +cargo test +``` + +--- + +## 🀝 Contributing + +Contributions are welcome! Here are several ways you can contribute: + +- **[Submit Pull Requests](https://github.com/local//blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs. +- **[Join the Discussions](https://github.com/local//discussions)**: Share your insights, provide feedback, or ask questions. +- **[Report Issues](https://github.com/local//issues)**: Submit bugs found or log feature requests for LOCAL. + +#### _Contributing Guidelines_ + +
+Click to expand + +1. **Fork the Repository**: Start by forking the project repository to your GitHub account. +2. **Clone Locally**: Clone the forked repository to your local machine using a Git client. + ```sh + git clone + ``` +3. **Create a New Branch**: Always work on a new branch, giving it a descriptive name. + ```sh + git checkout -b new-feature-x + ``` +4. **Make Your Changes**: Develop and test your changes locally. +5. **Commit Your Changes**: Commit with a clear and concise message describing your updates. + ```sh + git commit -m 'Implemented new feature x.' + ``` +6. **Push to GitHub**: Push the changes to your forked repository. + ```sh + git push origin new-feature-x + ``` +7. **Submit a Pull Request**: Create a PR against the original project repository. Clearly describe the changes and their motivations. + +Once your PR is reviewed and approved, it will be merged into the main branch. + +
+ +[**Return**](#Top) + +--- diff --git a/packages/injective-cosmwasm/src/exchange/types.rs b/packages/injective-cosmwasm/src/exchange/types.rs index 0d172657..dba3ff0c 100644 --- a/packages/injective-cosmwasm/src/exchange/types.rs +++ b/packages/injective-cosmwasm/src/exchange/types.rs @@ -404,24 +404,6 @@ impl AsRef for SubaccountId { } } -impl<'a> PrimaryKey<'a> for &'a SubaccountId { - type Prefix = (); - type SubPrefix = (); - type Suffix = Self; - type SuperSuffix = Self; - - fn key(&self) -> Vec { - // this is simple, we don't add more prefixes - vec![Key::Ref(self.as_ref().as_bytes())] - } -} - -impl<'a> Prefixer<'a> for &'a SubaccountId { - fn prefix(&self) -> Vec { - vec![Key::Ref(self.as_bytes())] - } -} - #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, JsonSchema)] pub struct Hash([u8; 32]); diff --git a/packages/injective-cosmwasm/src/exchange_mock_querier.rs b/packages/injective-cosmwasm/src/exchange_mock_querier.rs index 1020ab24..42081c72 100644 --- a/packages/injective-cosmwasm/src/exchange_mock_querier.rs +++ b/packages/injective-cosmwasm/src/exchange_mock_querier.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use cosmwasm_std::testing::{MockApi, MockStorage}; use cosmwasm_std::{ - from_slice, to_binary, Addr, AllBalanceResponse, BalanceResponse, BankQuery, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, + from_json, to_json_binary, Addr, AllBalanceResponse, BalanceResponse, BankQuery, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, WasmQuery, }; @@ -49,7 +49,7 @@ fn default_subaccount_deposit_response_handler() -> QuerierResult { total_balance: FPDecimal::from(10_000_000_000u128), }, }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_spot_market_response_handler(market_id: MarketId) -> QuerierResult { @@ -67,22 +67,22 @@ fn default_spot_market_response_handler(market_id: MarketId) -> QuerierResult { min_quantity_tick_size: FPDecimal::from_str("1000000000000000.0").unwrap(), }), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_trader_spot_orders_response_handler() -> QuerierResult { let response = TraderSpotOrdersResponse { orders: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_trader_spot_orders_to_cancel_up_to_amount_response_handler() -> QuerierResult { let response = TraderSpotOrdersResponse { orders: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_trader_derivative_orders_to_cancel_up_to_amount_response_handler() -> QuerierResult { let response = TraderDerivativeOrdersResponse { orders: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_derivative_market_response_handler(market_id: MarketId) -> QuerierResult { @@ -109,7 +109,7 @@ fn default_derivative_market_response_handler(market_id: MarketId) -> QuerierRes mark_price: FPDecimal::ONE, }), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_subaccount_positions_response_handler() -> QuerierResult { @@ -118,37 +118,37 @@ fn default_subaccount_positions_response_handler() -> QuerierResult { fn default_subaccount_position_in_market_response_handler() -> QuerierResult { let response = SubaccountPositionInMarketResponse { state: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_subaccount_effective_position_in_market_response_handler() -> QuerierResult { let response = SubaccountEffectivePositionInMarketResponse { state: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_trader_derivative_orders_response_handler() -> QuerierResult { let response = TraderDerivativeOrdersResponse { orders: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_trader_transient_spot_orders_response_handler() -> QuerierResult { let response = TraderSpotOrdersResponse { orders: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_trader_transient_derivative_orders_response_handler() -> QuerierResult { let response = TraderDerivativeOrdersResponse { orders: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_perpetual_market_info_response_handler() -> QuerierResult { let response = PerpetualMarketInfoResponse { info: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_perpetual_market_funding_response_handler() -> QuerierResult { let response = PerpetualMarketFundingResponse { state: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_market_volatility_response_handler() -> QuerierResult { @@ -157,7 +157,7 @@ fn default_market_volatility_response_handler() -> QuerierResult { history_metadata: None, raw_history: None, }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_spot_market_mid_price_and_tob_response_handler() -> QuerierResult { @@ -166,7 +166,7 @@ fn default_spot_market_mid_price_and_tob_response_handler() -> QuerierResult { best_buy_price: None, best_sell_price: None, }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_derivative_market_mid_price_and_tob_response_handler() -> QuerierResult { @@ -175,7 +175,7 @@ fn default_derivative_market_mid_price_and_tob_response_handler() -> QuerierResu best_buy_price: None, best_sell_price: None, }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_aggregate_market_volume_handler() -> QuerierResult { @@ -185,7 +185,7 @@ fn default_aggregate_market_volume_handler() -> QuerierResult { taker_volume: FPDecimal::from(100u128), }, }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_aggregate_account_volume_handler() -> QuerierResult { @@ -207,17 +207,17 @@ fn default_aggregate_account_volume_handler() -> QuerierResult { }, ], }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_denom_decimal_handler() -> QuerierResult { let response = QueryDenomDecimalResponse { decimals: 6 }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_denom_decimals_handler() -> QuerierResult { let response = QueryDenomDecimalsResponse { denom_decimals: vec![] }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_oracle_volatility_response_handler() -> QuerierResult { @@ -226,7 +226,7 @@ fn default_oracle_volatility_response_handler() -> QuerierResult { history_metadata: None, raw_history: None, }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_pyth_price_response_handler() -> QuerierResult { @@ -244,40 +244,40 @@ fn default_pyth_price_response_handler() -> QuerierResult { }, }), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_token_factory_denom_total_supply_handler() -> QuerierResult { let response = TokenFactoryDenomSupplyResponse { total_supply: Uint128::from(1000u128), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_token_factory_denom_creation_fee_handler() -> QuerierResult { let response = TokenFactoryCreateDenomFeeResponse { fee: vec![Coin::new(10, "inj")], }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_contract_registration_info_response_handler() -> QuerierResult { let response = QueryContractRegistrationInfoResponse { contract: None }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_balance_bank_query_handler(denom: impl Into) -> QuerierResult { let response = BalanceResponse { amount: Coin::new(1000000000000000, denom), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_all_balances_bank_query_handler() -> QuerierResult { let response = AllBalanceResponse { amount: vec![Coin::new(1000000000000000, "inj")], }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_exchange_params_response_handler() -> QuerierResult { @@ -311,7 +311,7 @@ fn default_exchange_params_response_handler() -> QuerierResult { is_instant_derivative_market_launch_enabled: Some(true), }), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_spot_market_orderbook_response_handler() -> QuerierResult { @@ -322,7 +322,7 @@ fn default_spot_market_orderbook_response_handler() -> QuerierResult { PriceLevel::new(12u128.into(), 10u128.into()), ], }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_derivative_market_orderbook_response_handler() -> QuerierResult { @@ -333,14 +333,14 @@ fn default_derivative_market_orderbook_response_handler() -> QuerierResult { PriceLevel::new(12u128.into(), 10u128.into()), ], }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } fn default_market_atomic_execution_fee_multiplier_response_handler() -> QuerierResult { let response = QueryMarketAtomicExecutionFeeMultiplierResponse { multiplier: FPDecimal::from_str("2.0").unwrap(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } pub trait HandlesSmartQuery { @@ -503,7 +503,7 @@ pub struct WasmMockQuerier { impl Querier for WasmMockQuerier { fn raw_query(&self, bin_request: &[u8]) -> QuerierResult { - let request: QueryRequest = match from_slice(bin_request) { + let request: QueryRequest = match from_json(bin_request) { Ok(v) => v, Err(e) => { return SystemResult::Err(SystemError::InvalidRequest { @@ -781,7 +781,8 @@ impl TestDeposit { pub mod handlers { use cosmwasm_std::{ - to_binary, AllBalanceResponse, BalanceResponse, Binary, Coin, ContractResult, QuerierResult, StdResult, SystemError, SystemResult, Uint128, + to_json_binary, AllBalanceResponse, BalanceResponse, Binary, Coin, ContractResult, QuerierResult, StdResult, SystemError, SystemResult, + Uint128, }; use std::collections::HashMap; @@ -825,7 +826,7 @@ pub mod handlers { total_balance: matching_coins.first().unwrap().amount, }, }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { coins })) @@ -850,7 +851,7 @@ pub mod handlers { let response = SubaccountDepositResponse { deposits: matching_deposits.first().unwrap().deposit.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { deposits })) @@ -875,7 +876,7 @@ pub mod handlers { let response = SpotMarketResponse { market: self.market.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { market })) @@ -896,7 +897,7 @@ pub mod handlers { buys_price_level: if order_side != OrderSide::Sell { price_levels.clone() } else { vec![] }, sells_price_level: if order_side != OrderSide::Buy { price_levels } else { vec![] }, }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { orderbooks })) @@ -912,7 +913,7 @@ pub mod handlers { let response = SpotMarketResponse { market: self.markets.get(&market_id).cloned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } @@ -945,7 +946,7 @@ pub mod handlers { let response = TraderSpotOrdersResponse { orders: self.orders.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { orders, assertion })) @@ -976,7 +977,7 @@ pub mod handlers { let response = TraderDerivativeOrdersResponse { orders: self.orders.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { orders, assertion })) @@ -1001,7 +1002,7 @@ pub mod handlers { mark_price: self.mark_price.to_owned(), }), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { market, info, mark_price })) @@ -1016,7 +1017,7 @@ pub mod handlers { let response = TraderSpotOrdersResponse { orders: self.orders.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { orders })) @@ -1033,7 +1034,7 @@ pub mod handlers { let response = TraderDerivativeOrdersResponse { orders: self.orders.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { orders })) @@ -1051,7 +1052,7 @@ pub mod handlers { let response = SubaccountEffectivePositionInMarketResponse { state: self.position.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } @@ -1068,7 +1069,7 @@ pub mod handlers { let response = SubaccountPositionInMarketResponse { state: self.position.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } @@ -1092,7 +1093,7 @@ pub mod handlers { best_buy_price: self.best_buy_price.to_owned(), best_sell_price: self.best_sell_price.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { @@ -1124,7 +1125,7 @@ pub mod handlers { history_metadata: self.history_metadata.to_owned(), raw_history: self.raw_history.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { @@ -1165,7 +1166,7 @@ pub mod handlers { quote_timestamp: self.quote_timestamp.to_owned(), }), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { @@ -1186,7 +1187,7 @@ pub mod handlers { impl HandlesDenomSupplyQuery for Temp { fn handle(&self, _denom: String) -> QuerierResult { let response = TokenFactoryDenomSupplyResponse { total_supply: self.supply }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { supply })) @@ -1199,7 +1200,7 @@ pub mod handlers { impl HandlesFeeQuery for Temp { fn handle(&self) -> QuerierResult { let response = TokenFactoryCreateDenomFeeResponse { fee: self.fee.to_owned() }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { fee })) @@ -1214,7 +1215,7 @@ pub mod handlers { let response = QueryContractRegistrationInfoResponse { contract: self.contract.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { contract })) @@ -1231,7 +1232,7 @@ pub mod handlers { let balance = balances.iter().find(|b| -> bool { b.denom == denom }).unwrap_or(&empty); let res = BalanceResponse { amount: balance.to_owned() }; - SystemResult::Ok(ContractResult::from(to_binary(&res))) + SystemResult::Ok(ContractResult::from(to_json_binary(&res))) } } Some(Box::new(Temp { balances })) @@ -1247,7 +1248,7 @@ pub mod handlers { amount: self.balances.to_owned(), }; - SystemResult::Ok(ContractResult::from(to_binary(&res))) + SystemResult::Ok(ContractResult::from(to_json_binary(&res))) } } Some(Box::new(Temp { balances })) @@ -1260,7 +1261,7 @@ pub mod handlers { impl HandlesMarketIdQuery for Temp { fn handle(&self, _market_id: MarketId) -> QuerierResult { let response = QueryMarketAtomicExecutionFeeMultiplierResponse { multiplier: self.multiplier }; - SystemResult::Ok(ContractResult::from(to_binary(&response))) + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } } Some(Box::new(Temp { multiplier })) diff --git a/packages/injective-math/Cargo.toml b/packages/injective-math/Cargo.toml index 132af934..15123d31 100644 --- a/packages/injective-math/Cargo.toml +++ b/packages/injective-math/Cargo.toml @@ -1,12 +1,12 @@ [package] authors = [ "Markus Waas " ] description = "Math library for CosmWasm contracts in Injective Protocol" -edition = "2018" +edition = "2021" license = "Apache-2.0" name = "injective-math" readme = "README.md" -repository = "https://github.com/InjectiveLabs/cw-injective/tree/master/packages/injective-math" -version = "0.2.3" +repository = "https://github.com/InjectiveLabs/cw-injective/tree/dev/packages/injective-math" +version = "0.2.4" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,12 +15,12 @@ version = "0.2.3" backtraces = [ "cosmwasm-std/backtraces" ] [dependencies] -primitive-types = {version= "0.12.2" ,default-features = false} -cosmwasm-std = { version = "=1.2.7", features = [ "abort", "iterator", "stargate" ] } -ethereum-types = { version = "0.5.2" } +cosmwasm-std = { version = "1.5.0", features = [ "abort", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "iterator", "stargate" ] } +ethereum-types = { version = "0.5.2" } +primitive-types = { version = "0.12.2", default-features = false } schemars = "0.8.8" -serde = { version = "1.0.136", default-features = false, features = [ "derive" ] } +serde = { version = "1.0.193", default-features = false, features = [ "derive" ] } subtle-encoding = { version = "0.5.1", features = [ "bech32-preview" ] } [dev-dependencies] -cosmwasm-schema = { version = "=1.2.7" } +cosmwasm-schema = { version = "1.5.0" } diff --git a/packages/injective-math/README.md b/packages/injective-math/README.md index 212c4b65..c50703c3 100644 --- a/packages/injective-math/README.md +++ b/packages/injective-math/README.md @@ -1 +1,232 @@ # injective-math + +
+

+ +

+

β—¦ injective-math

+ +

+Rust +

+
+ +--- + +## πŸ“– Table of Contents + +- [πŸ“– Table of Contents](#-table-of-contents) +- [πŸ“ Overview](#-overview) +- [πŸ“¦ Features](#-features) +- [πŸ“‚ repository Structure](#-repository-structure) +- [βš™οΈ Modules](#modules) +- [πŸš€ Getting Started](#-getting-started) + - [πŸ”§ Installation](#-installation) + - [πŸ€– Running ](#-running-) + - [πŸ§ͺ Tests](#-tests) +- [πŸ›£ Roadmap](#-roadmap) +- [🀝 Contributing](#-contributing) +- [πŸ“„ License](#-license) +- [πŸ‘ Acknowledgments](#-acknowledgments) + +--- + +## πŸ“ Overview + +The repository hosts an advanced mathematical library primarily designed for financial calculations and scientific computing, with specific compatibility for CosmWasm contracts within the Injective Protocol ecosystem. It features a custom fixed-point decimal type (`FPDecimal`) supporting arithmetic, comparison, display formatting, serialization, root-finding algorithms, and vector operations. High precision and robust error handling are key attributes, which cater to the stringent accuracy requirements in financial transactions and smart contract development. Moreover, the inclusion of root-finding techniques and utilities for large-number arithmetic underscore its comprehensive nature in tackling a broad spectrum of mathematical challenges. + +--- + +## πŸ“¦ Features + +| | Feature | Description | +| --- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| βš™οΈ | **Architecture** | A Rust-based library focused on high-precision arithmetic for fixed-point decimals, suitable for blockchain-related mathematical computations. | +| πŸ“„ | **Documentation** | Documentation within the code summarizes functionalities of the financial calculation library and its mathematical utilities. Incomplete at a high level. | +| πŸ”— | **Dependencies** | External dependencies include `cosmwasm-std`, `ethereum-types`, and `serde` among others, configured for WebAssembly and blockchain integration. | +| 🧩 | **Modularity** | Highly modular with separate files for arithmetic, comparison, scaling, rooting, vector computations, serialization, error handling, and more. | +| πŸ§ͺ | **Testing** | Library includes unit tests for various mathematical functions, although test coverage is not assessed in the provided details. | +| ⚑️ | **Performance** | No explicit performance metrics provided, but the use of Rust and fixed-point arithmetic suggests a focus on computational efficiency. | +| πŸ” | **Security** | Specific security measures aren't mentioned, but the controlled arithmetic mitigates certain numerical risks. Serialized data handling via `serde` requires scrutiny. | +| πŸ”€ | **Version Control** | Versioning follows semantic versioning with the current version at 0.2.3; version control strategies not specified in the details. | +| πŸ”Œ | **Integrations** | Designed for integration with WebAssembly and the Injective Protocol, implying good interoperability within blockchain ecosystems. | +| πŸ“Ά | **Scalability** | The code structure and Rust usage imply scalability; however, real-world scalability is not explicit within the summaries. | + +The analysis above was generated based on the provided directory structure and code summaries for a Rust project focused on providing a library for fixed-point decimal arithmetic, primarily targeting blockchain applications. This interpretation of the provided data reflects a strong modular design, accompanied by a well-thought-out file structure to organize a wide range of mathematical computing features. It seems to target performance through Rust's efficiency and fine-grained error and type handling. Furthermore, the presence of serialization and deserialization capabilities via `serde` supports flexible data compatibility. Nevertheless, a deeper analysis, especially including a review of actual performance metrics, test coverage, security audits, and scalability testing, would be needed to provide a more precise evaluation. + +--- + +## πŸ“‚ Repository Structure + +```sh +└── / + β”œβ”€β”€ .cargo/ + β”‚ └── config + β”œβ”€β”€ Cargo.toml + └── src/ + β”œβ”€β”€ fp_decimal/ + β”‚ β”œβ”€β”€ arithmetic.rs + β”‚ β”œβ”€β”€ comparison.rs + β”‚ β”œβ”€β”€ display.rs + β”‚ β”œβ”€β”€ error.rs + β”‚ β”œβ”€β”€ exp.rs + β”‚ β”œβ”€β”€ factorial.rs + β”‚ β”œβ”€β”€ from_str.rs + β”‚ β”œβ”€β”€ hyper.rs + β”‚ β”œβ”€β”€ log.rs + β”‚ β”œβ”€β”€ mod.rs + β”‚ β”œβ”€β”€ round.rs + β”‚ β”œβ”€β”€ scale.rs + β”‚ β”œβ”€β”€ serde.rs + β”‚ β”œβ”€β”€ trigonometry.rs + β”‚ └── utils.rs + β”œβ”€β”€ lib.rs + β”œβ”€β”€ root_findings.rs + β”œβ”€β”€ utils.rs + └── vector.rs + +``` + +--- + +## βš™οΈ Modules + +
Root + +| File | Summary | +| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [Cargo.toml]({file_path}) | The code represents a Rust project manifest for injective-math, a mathematical library tailored for CosmWasm contracts on the Injective Protocol. It specifies the package's metadata, including the author, license, description, and repository link. The project is configured for the Rust 2021 edition and has version 0.2.3. Features enable additional testing capabilities, and dependencies include specific versions of cosmwasm-std, ethereum-types, and others, with some having optional features. The project structure indicates modules for fixed-point decimals, utilities, root-finding algorithms, and vector operations. | + +
+ +
.cargo + +| File | Summary | +| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [config]({file_path}) | This Rust project includes custom configurations and an extensive floating-point decimal library. The `.cargo/config` file defines build and test aliases for targeting WebAssembly and enabling features like backtraces. The `src` directory structure suggests the library provides a wide range of numerical operations, error handling, serialization support, and utilities, along with additional functionalities for root-finding and vector manipulation, indicating a focus on mathematical and scientific computing. | + +
+ +
Src + +| File | Summary | +| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [vector.rs]({file_path}) | The provided Rust code defines a set of arithmetic operations for vectors of `FPDecimal` (a fixed-point decimal type). These operations include summing elements, dot product, element-wise multiplication and division by a constant, element-wise addition and subtraction, and computing the absolute values of elements within a vector. These functions facilitate vector-based calculations with fixed-point precision. | +| [lib.rs]({file_path}) | The code provides utilities for financial calculations with fixed-point decimals. It includes functions to calculate asset cluster imbalance using portfolio weights, prices, and inventories (`imbalance`), and to convert arrays of different integer types (`u32`, `Uint128`) and strings to arrays of `FPDecimal` objects (`int32_vec_to_fpdec`, `int_vec_to_fpdec`, `str_vec_to_fpdec`). The `imbalance` function performs elemental multiplications, a dot product, and scales for optimal capital allocation comparison. | +| [root_findings.rs]({file_path}) | The code implements root-finding algorithmsβ€”Newton's, discrete Newton's, and Halley's methodsβ€”for functions returning `FPDecimal` (a fixed-point decimal type). It supports iterating until a specified precision (`abs_error`) or number of iterations (`max_iter`) is met. The `newton` function calculates roots using a function and its derivative. The `discrete_newton` method approximates derivatives and solves for discrete functions. `halleys` extends Newton's method with the second derivative for faster convergence. It includes no support for complex numbers and test cases validating functionality. | +| [utils.rs]({file_path}) | The provided Rust code is part of a financial calculation library, consisting of utility functions for operating on fixed-precision decimal (FPDecimal) numbers. It includes functionalities like parsing decimals and integers within specified ranges, rounding to ticks with specific precision, and ensuring values fall within given bands. It handles errors and validation for inputs and avoids division by zero. The code is organized with tests verifying behaviors like flooring, rounding, division, and tick adjustments for precise financial operations. | + +
+ +
Fp_decimal + +| File | Summary | +| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [display.rs]({file_path}) | The code defines a `Display` trait implementation for `FPDecimal`, a fixed-point decimal type, formatting it as a string with optional negative sign, integer part, and fractional part, omitting any trailing zeros in the fraction. It includes tests validating the correct string representation of positive, negative, and fractional `FPDecimal` values. | +| [serde.rs]({file_path}) | The `serde.rs` module provides serialization and deserialization implementations for `FPDecimal`, a custom fixed-precision decimal type, using Serde, a Rust serialization framework. Serialization converts `FPDecimal` instances into decimal strings, while deserialization constructs `FPDecimal` from string-encoded decimal values, with robust error handling for parsing failures. The module includes a custom visitor `FPDecimalVisitor` for deserialization tailored to the `FPDecimal` type, ensuring compatibility with Serde's data model. | +| [error.rs]({file_path}) | The provided code defines a Rust module structure for a numerical library, with a core directory focused on fixed-point decimal operations (`fp_decimal`). It includes functionality for arithmetic, comparison, display formatting, error handling, exponentiation, factorial calculation, string conversion, hyperbolic functions, logarithms, rounding, scaling, serialization, and trigonometry, among other utilities. The `error.rs` file within `fp_decimal` defines an error enumeration (`FPDecimalError`) for handling undefined and unsupported operations within the library. | +| [hyper.rs]({file_path}) | The code defines hyperbolic trigonometric functions (`sinh`, `cosh`, `tanh`) for a fixed-point decimal data type `FPDecimal` in a Rust module. It includes private functions with detailed implementations (`_sinh`, `_cosh`, `_tanh`) and corresponding public methods that call these functions, passing the instance as an argument. The implementation uses exponential functions, addition, subtraction, and division operations specific to `FPDecimal`. Unit tests confirm that these functions produce expected results for the value of 1. | +| [log.rs]({file_path}) | The `log.rs` module provides a natural logarithm function specifically for `FPDecimal` values, handling base `e` (Euler's number) and its powers up to \(e^{11}\), as well as their reciprocals, mapping them to their corresponding integral `FPDecimal` representations (0 through 11 and-1, respectively). Other values do not return a result, indicating a limitation in the logarithmic function's implementation for arbitrary `FPDecimal` instances. | +| [arithmetic.rs]({file_path}) | The provided Rust code defines arithmetic operations for a fixed-point decimal represented by the `FPDecimal` struct within a numerical library, supporting addition, subtraction, multiplication, division, and modulus calculations. It handles numbers with potential sign differences and precision management. The implementation employs Rust's traits such as `Add`, `Sub`, `Mul`, `Div`, and their assign variants to integrate with native operators (`+`, `-`, `*`, `/`, etc.). Additional utility functions allow for absolute value determination, calculating absolute differences, and aggregation via `Sum`. Complex multiplication and division preserve precision, and various tests ensure the functionality's reliability and correctness. | +| [from_str.rs]({file_path}) | The provided code is part of a Rust module that defines the `FromStr` trait implementation for a `FPDecimal` type, allowing the creation of this custom fixed-point decimal type from a string representation. It parses decimal strings (like `1.23`) without performing rounding, errors on invalid input, and supports up to 18 fractional digits. The `FPDecimal` struct has a `must_from_str` method that panics if the conversion fails. Unit tests validate parsing for negative, zero, and other decimal strings, ensuring accurate conversion to the internal representation. | +| [scale.rs]({file_path}) | The `scale.rs` code defines a trait `Scaled` for the `FPDecimal` type, allowing decimal scaling operations by multiplying by a power of ten. It includes an implementation to adjust the scale of `FPDecimal` instances and a function `dec_scale_factor` returning a set scaling factor of 10^18. Two tests verify functionality: one checks correct scaling up and down, and the other confirms the predefined factor value. | +| [exp.rs]({file_path}) | The provided Rust code defines an `exp_taylor_expansion` method for the `FPDecimal` type, which computes an approximate value for the exponentiation a^b using the first 25 terms of the Taylor series expansion. The method calculates the natural logarithm of `a`, scales it by `b`, and iteratively constructs terms of the series by multiplying the numerator by the base and the denominator by consecutive integers from 2 to 25. It returns a vector of `FPDecimal` objects representing each term of the expansion. | +| [mod.rs]({file_path}) | This Rust code defines a `FPDecimal` struct for fixed-point arithmetic, with conversions from standard integer and floating-point data types, as well as custom conversions for blockchain-related types like `Decimal256`, `Uint128`, and `Uint256`. It supports unary negation, provides constants for mathematical values, has utility functions for checking its state (zero, integer, negative), and handles overflow conditions. Unit tests affirm the correctness of constants, conversions, sign handling, integer checks, and rounding methods. The tree structure shows it being part of a larger library focused on expanded arithmetic and scientific computations. | +| [trigonometry.rs]({file_path}) | The provided Rust code defines a `FPDecimal` struct with methods to calculate sine and cosine functions imprecisely using Taylor series expansion, and an angle normalization method (`_change_range`) that wraps input angles into the range [0, 2Ο€]. The sine (`_sin`) and cosine (`_cos`) methods call `_change_range` to normalize angles and handle specific angle cases directly for efficiency. Tests verify the accuracy within a 1% margin using an `almost_eq` function, demonstrating tests for 0, 1, and-1 angle inputs for both sine and cosine functions. | +| [factorial.rs]({file_path}) | The code provides a `FPDecimal` struct with methods for calculating factorials and the gamma function. The factorial methods support positive and negative integers, using recursion, returning `FPDecimal::ONE` for zero input. The gamma function evaluates for non-integer values using a pre-calculated constants table, employing Horner's method for polynomial evaluation. Unit tests validate factorial computations for 9 and-9, ensuring correct parsing and method functionality within the `FPDecimal` context. | +| [comparison.rs]({file_path}) | The provided code defines Rust traits to compare `FPDecimal` instances, which seemingly represent fixed-point decimal numbers with `num` and `sign` attributes. The `Ord`, `PartialOrd`, and `PartialEq` traits are implemented to enable comparisons via standard operators (`<`, `<=`, `>`, `>=`, `==`, and `!=`). Additional methods `maximum` and `minimum` return the greater or lesser of two `FPDecimal` instances, respectively. Unit tests validate the correctness of these comparisons and methods. | +| [utils.rs]({file_path}) | The code snippet is from a Rust project structured to handle high-precision arithmetic operations, with a particular focus on a module named `fp_decimal`. The project is configured for Cargo (Rust's package manager), indicated by `.cargo/config` and `Cargo.toml` files. The `fp_decimal` directory under `src/` contains several Rust files (`*.rs`), each likely handling a different aspect of fixed-point decimal operations such as arithmetic, comparison, formatting, error handling, exponentiation, factorial calculation, parsing, logarithmic functions, and more. The presence of `serde.rs` suggests serialization/deserialization capabilities. The `FPDecimal` type and `U256` (a 256-bit unsigned integer type, probably from an external `bigint` library) are imported in `utils.rs`, indicating utility functions leveraging large-integer support. | +| [round.rs]({file_path}) | The provided directory tree and file path indicate a Rust project structure with a focus on fixed-precision decimal arithmetic. The code in `src/fp_decimal/round.rs` suggests implementation of rounding functions within a module `fp_decimal` of a numerical library, possibly providing precise arithmetic operations (e.g., addition, multiplication), special functions (e.g., exponentiation, logarithms), and utilities for handling fixed-precision decimal numbers, with `FPDecimal` as the main type and `U256` hinting at a 256-bit underlying numeric representation. The module may also support serialization with `serde.rs`. | + +
+ +--- + +## πŸš€ Getting Started + +**_Dependencies_** + +Please ensure you have the following dependencies installed on your system: + +`- ℹ️ Dependency 1` + +`- ℹ️ Dependency 2` + +`- ℹ️ ...` + +### πŸ”§ Installation + +1. Clone the repository: + +```sh +git clone ../ +``` + +2. Change to the project directory: + +```sh +cd +``` + +3. Install the dependencies: + +```sh +cargo build +``` + +### πŸ€– Running + +```sh +cargo run +``` + +### πŸ§ͺ Tests + +```sh +cargo test +``` + +--- + +## 🀝 Contributing + +Contributions are welcome! Here are several ways you can contribute: + +- **[Submit Pull Requests](https://github.com/local//blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs. +- **[Join the Discussions](https://github.com/local//discussions)**: Share your insights, provide feedback, or ask questions. +- **[Report Issues](https://github.com/local//issues)**: Submit bugs found or log feature requests for LOCAL. + +#### _Contributing Guidelines_ + +
+Click to expand + +1. **Fork the Repository**: Start by forking the project repository to your GitHub account. +2. **Clone Locally**: Clone the forked repository to your local machine using a Git client. + ```sh + git clone + ``` +3. **Create a New Branch**: Always work on a new branch, giving it a descriptive name. + ```sh + git checkout -b new-feature-x + ``` +4. **Make Your Changes**: Develop and test your changes locally. +5. **Commit Your Changes**: Commit with a clear and concise message describing your updates. + ```sh + git commit -m 'Implemented new feature x.' + ``` +6. **Push to GitHub**: Push the changes to your forked repository. + ```sh + git push origin new-feature-x + ``` +7. **Submit a Pull Request**: Create a PR against the original project repository. Clearly describe the changes and their motivations. + +Once your PR is reviewed and approved, it will be merged into the main branch. + +
+ +--- + +[**Return**](#Top) + +--- diff --git a/packages/injective-protobuf/Cargo.toml b/packages/injective-protobuf/Cargo.toml index e6bf58aa..f4d5bf35 100644 --- a/packages/injective-protobuf/Cargo.toml +++ b/packages/injective-protobuf/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "injective-protobuf" -version = "0.2.1" -authors = ["Mauro Lacy "] -edition = "2018" +authors = [ "Mauro Lacy " ] description = "Protobug parsing for Injective Protocol" -repository = "https://github.com/InjectiveLabs/cw-injective/tree/master/packages/injective-protobuf" -license = "Apache-2.0" -readme = "README.md" +edition = "2021" +license = "Apache-2.0" +name = "injective-protobuf" +readme = "README.md" +repository = "https://github.com/InjectiveLabs/cw-injective/tree/master/packages/injective-protobuf" +version = "0.2.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,16 +15,16 @@ protobuf-codegen-pure = "2" [features] # for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] +backtraces = [ "cosmwasm-std/backtraces" ] [dependencies] -cosmwasm-std = { version = "=1.2.7", features = [ "abort", "iterator", "stargate" ] } -schemars = "0.8.8" -serde = { version = "1.0.136", default-features = false, features = ["derive"] } -ethereum-types = "0.5.2" -subtle-encoding = { version = "0.5.1", features = ["bech32-preview"] } -num = "0.4.0" -protobuf = { version = "2", features = ["with-bytes"] } +cosmwasm-std = { version = "1.5.0", features = [ "abort", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "iterator", "stargate" ] } +ethereum-types = "0.5.2" +num = "0.4.0" +protobuf = { version = "2", features = [ "with-bytes" ] } +schemars = "0.8.8" +serde = { version = "1.0.136", default-features = false, features = [ "derive" ] } +subtle-encoding = { version = "0.5.1", features = [ "bech32-preview" ] } [dev-dependencies] -cosmwasm-schema = { version = "=1.2.7" } +cosmwasm-schema = { version = "1.5.0" } diff --git a/packages/injective-std/Cargo.toml b/packages/injective-std/Cargo.toml index 3d055849..eed32942 100644 --- a/packages/injective-std/Cargo.toml +++ b/packages/injective-std/Cargo.toml @@ -1,20 +1,20 @@ [package] description = "Standard library for Injective with CosmWasm support included" -edition = "2021" -license = "MIT OR Apache-2.0" -name = "injective-std" -repository = "https://github.com/InjectiveLabs/cw-injective/tree/master/packages/injective-std" -version = "0.1.4" -readme = "README.md" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "injective-std" +readme = "README.md" +repository = "https://github.com/InjectiveLabs/cw-injective/tree/master/packages/injective-std" +version = "0.1.5" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -chrono = {version = "0.4.24"} -cosmwasm-std = { version = "=1.2.7", features = [ "abort", "iterator", "stargate" ] } -osmosis-std-derive = {version = "0.15.2"} -prost = { version = "0.11.9" } -prost-types = {version = "0.11.9", default-features = false} -schemars = "0.8.8" -serde = {version = "1.0", default-features = false, features = ["derive"]} -serde-cw-value = { version = "0.7.0" } +chrono = { version = "0.4.24" } +cosmwasm-std = { version = "1.5.0", features = [ "abort", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "iterator", "stargate" ] } +osmosis-std-derive = { version = "0.15.2" } +prost = { version = "0.11.9" } +prost-types = { version = "0.11.9", default-features = false } +schemars = "0.8.8" +serde = { version = "1.0", default-features = false, features = [ "derive" ] } +serde-cw-value = { version = "0.7.0" } diff --git a/packages/injective-testing/Cargo.toml b/packages/injective-testing/Cargo.toml index bc28b8cf..cab90008 100644 --- a/packages/injective-testing/Cargo.toml +++ b/packages/injective-testing/Cargo.toml @@ -1,20 +1,20 @@ [package] -authors = [ "Bartek Tofel " ] +authors = [ "Markus Waas " ] description = "Testing utils for Injective Cosmwasm and core modules" edition = "2021" license = "Apache-2.0" name = "injective-testing" repository = "https://github.com/InjectiveLabs/cw-injective/tree/master/packages/injective-testing" -version = "0.1.5" +version = "0.1.6" [dependencies] -anyhow = { version = "1.0.66" } -base64 = { version = "0.13.1" } -cosmwasm-std = { version = "=1.2.7", features = [ "abort", "iterator", "stargate" ] } -cw-multi-test = { version = "0.16.2" } -injective-cosmwasm = { version = "0.2.17" } -injective-math = { version = "0.2.3" } -rand = { version = "0.4.6" } -secp256k1 = { version = "0.6.2" } -serde = { version = "1.0.137", default-features = false, features = ["derive"] } -tiny-keccak = { version = "1.2.1" } +anyhow = { version = "1.0.66" } +base64 = { version = "0.13.1" } +cosmwasm-std = { version = "1.5.0", features = [ "abort", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "iterator", "stargate" ] } +cw-multi-test = { version = "0.16.2" } +injective-cosmwasm = { version = "0.2.18", path = "../injective-cosmwasm" } +injective-math = { version = "0.2.4", path = "../injective-math" } +rand = { version = "0.4.6" } +secp256k1 = { version = "0.6.2" } +serde = { version = "1.0.137", default-features = false, features = [ "derive" ] } +tiny-keccak = { version = "1.2.1" } diff --git a/packages/injective-testing/src/chain_mock.rs b/packages/injective-testing/src/chain_mock.rs index 14f8e80e..c66bfc9d 100644 --- a/packages/injective-testing/src/chain_mock.rs +++ b/packages/injective-testing/src/chain_mock.rs @@ -1,6 +1,6 @@ use anyhow::{bail, Result as AnyResult}; use cosmwasm_std::{testing::MockApi, Addr, Api, Binary, BlockInfo, Coin, CustomQuery, Empty, MemoryStorage, Querier, Storage}; -use cosmwasm_std::{to_binary, StdError}; +use cosmwasm_std::{to_json_binary, StdError}; use cw_multi_test::{AddressGenerator, App}; use cw_multi_test::{AppResponse, BankKeeper, BasicAppBuilder, CosmosRouter, DistributionKeeper, Module, Router, StakeKeeper, WasmKeeper}; use injective_cosmwasm::{InjectiveMsgWrapper, InjectiveQueryWrapper}; @@ -84,7 +84,7 @@ pub struct ExecuteResponseContainer { impl ExecuteResponseContainer { pub fn with_ok_response(payload: &T) -> Self { ExecuteResponseContainer { - response: Some(Ok(Some(to_binary(payload).unwrap()))), + response: Some(Ok(Some(to_json_binary(payload).unwrap()))), } } @@ -108,7 +108,7 @@ pub struct QueryResponseContainer { impl QueryResponseContainer { pub fn with_ok_response(payload: &T) -> Self { QueryResponseContainer { - response: Some(Ok(to_binary(payload).unwrap())), + response: Some(Ok(to_json_binary(payload).unwrap())), } }