Skip to content

Commit

Permalink
Merge pull request #51 from scrtlabs/cosmwasm-v1.0
Browse files Browse the repository at this point in the history
Cosmwasm v1.0
  • Loading branch information
toml01 authored Oct 25, 2022
2 parents 0d5f2bf + 284a56b commit 5c46e2d
Show file tree
Hide file tree
Showing 35 changed files with 1,457 additions and 1,414 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
rust: [stable]
make:
- name: Clippy
task: "cargo clippy"
task: "cargo clippy --all --all-features -- -D warnings"
- name: Unit tests
task: "cargo test --all --all-features"
include:
Expand Down
62 changes: 37 additions & 25 deletions Releases.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
# Release notes for the Secret Toolkit

## v0.6.0

This release upgrades all `secret-toolkit` packages to be compatible with Cosmwasm v1.0 (Secret Network v1.4).
The APIs remains the same, but it is necessary to upgrade the contract's `cosmwasm` dependencies to `v1.0.0`.

### Breaking

- This version will not work with `cosmwasm v0.10`. It is necessary to upgrade to `cosmwasm v1` in order to use this release.

## v0.5.0

This release includes some minor fixed to the storage package which required some breaking changes.
We are releasing these breaking changes because we reached the conclusion that the current interfaces
are prone to bugs, or inefficient. Unless you are using these specific interfaces, you should be able to upgrade from 0.4 without issues.

### Breaking

- Removed the implementations of Clone for storage types which are not useful and may cause data corruption if used incorrectly.
- Changed `Keymap::insert` to take the item by reference rather than by value. This should reduce the cost of calling that function by avoiding cloning.

### Features

- Changed the implementation of the `add_prefix` methods in the storage package to use length prefixing, which should help avoid namespace collisions.

## secret-toolkit-storage v0.4.2
Expand Down Expand Up @@ -65,28 +77,28 @@ A full guide to using the new `storage` types can be found
* docs.rs documentation now includes all sub-crates.
* BUGFIX: `secret-toolkit::snip721::Metadata` was severely out of date with the SNIP-721 specification, and not useful.
It is now compatible with deployed SNIP-721 contracts.
* Added `types` module under the `util` package, to standardize often used types.
* Added `secret-toolkit::viewing_key`, which can be imported by enabling the `viewing-key` feature.
* Added `secret-toolkit::permit::PubKey::canonical_address()`.
* Types in `secret-toolkit::permit::Permit` are now generic over the type of permissions they accept.
* Added the `maxheap` type to the incubator.
* Added `secret-toolkit::utils::feature_toggle` which allow managing feature flags in your contract.
- Added `types` module under the `util` package, to standardize often used types.
- Added `secret-toolkit::viewing_key`, which can be imported by enabling the `viewing-key` feature.
- Added `secret-toolkit::permit::PubKey::canonical_address()`.
- Types in `secret-toolkit::permit::Permit` are now generic over the type of permissions they accept.
- Added the `maxheap` type to the incubator.
- Added `secret-toolkit::utils::feature_toggle` which allow managing feature flags in your contract.

### Breaking

* `secret-toolkit::permit::validate()` Now supports validating any type of Cosmos address.
Interface changes: Now takes a reference to the current token address instead
of taking it by value and an optional hrp string.
In addition, it returns a String and not HumanAddr.
* Renamed `secret-toolkit::permit::Permission` to `secret-toolkit::permit::TokenPermission`.
* `secret-toolkit-crypto` now has features `["hash", "rng" and "ecc-secp256k1"]` which are all off by default - enable those you need.
* `secret-toolkit-crypto::secp256k1::PublicKey::parse` now returns `StdResult<Self>`.
* Changes to `secret-toolkit::crypto::secp256k1::PrivateKey::sign`:
* The `data` argument is now any slice of bytes, and not the hash of a slice of data.
* the `Api` from `deps.api` is now required as the second argument as we now use the precompiled implementation.
* Changes to `secret-toolkit::crypto::secp256k1::PublicKey::verify`:
* the `Api` from `deps.api` is now required as the third argument as we now use the precompiled implementation.
* `secret-toolkit-incubator` now has features `["cashmap", "generational-store"]` which are all off by default.
- Renamed `secret-toolkit::permit::Permission` to `secret-toolkit::permit::TokenPermission`.
- `secret-toolkit-crypto` now has features `["hash", "rng" and "ecc-secp256k1"]` which are all off by default - enable those you need.
- `secret-toolkit-crypto::secp256k1::PublicKey::parse` now returns `StdResult<Self>`.
- Changes to `secret-toolkit::crypto::secp256k1::PrivateKey::sign`:
- The `data` argument is now any slice of bytes, and not the hash of a slice of data.
- the `Api` from `deps.api` is now required as the second argument as we now use the precompiled implementation.
- Changes to `secret-toolkit::crypto::secp256k1::PublicKey::verify`:
- the `Api` from `deps.api` is now required as the third argument as we now use the precompiled implementation.
- `secret-toolkit-incubator` now has features `["cashmap", "generational-store"]` which are all off by default.

## v0.2.0

Expand All @@ -103,11 +115,11 @@ This version is also the first released to [crates.io](https://crates.io)!
which are wrappers that automatically deserializes base64 strings to `T`.
It can be used in message types' fields instead of `Binary` when the contents of the string
should have more specific contents.
* Added `storage::DequeStore` - Similar to `AppendStore` but allows pushing and popping on both ends
* Added the `secret-toolkit::incubator` package intended for experimental features. It contains:
* `CashMap` - A hashmap like storage abstraction
* `GenerationalIndex` - A generational index storage abstraction
* The various subpackages can now be selected using feature flags. The default flags are `["serialization", "snip20", "snip721", "storage", "utils"]`
- Added `storage::DequeStore` - Similar to `AppendStore` but allows pushing and popping on both ends
- Added the `secret-toolkit::incubator` package intended for experimental features. It contains:
- `CashMap` - A hashmap like storage abstraction
- `GenerationalIndex` - A generational index storage abstraction
- The various subpackages can now be selected using feature flags. The default flags are `["serialization", "snip20", "snip721", "storage", "utils"]`
while `["crypto", "permit", "incubator"]` are left disabled by default.

## v0.1.1
Expand All @@ -118,16 +130,16 @@ This version is also the first released to [crates.io](https://crates.io)!

This is the first release of `secret-toolkit`. It supports:

* `secret-toolkit::snip20` - Helper types and functions for interaction with
- `secret-toolkit::snip20` - Helper types and functions for interaction with
SNIP-20 contracts.
* `secret-toolkit::snip721` - Helper types and functions for interaction with
- `secret-toolkit::snip721` - Helper types and functions for interaction with
SNIP-721 contracts.
* `secret-toolkit::crypto` - Wrappers for known-to-work crypto primitives from
- `secret-toolkit::crypto` - Wrappers for known-to-work crypto primitives from
ecosystem libraries. We include implementations for Sha256, Secp256k1 keys,
and ChaChaRng.
* `secret-toolkit::storage` - Types implementing useful storage managements
- `secret-toolkit::storage` - Types implementing useful storage managements
techniques: `AppendStore` and `TypedStore`, using `bincode2` by default.
* `secret-toolkit::serialization` - marker types for overriding the storage
- `secret-toolkit::serialization` - marker types for overriding the storage
format used by types in `secret-toolkit::storage`. `Json` and `Bincode2`.
* `secret-toolkit::utils` - General utilities for writing contract code.
* `padding` - tools for padding queries and responses.
Expand Down
4 changes: 2 additions & 2 deletions packages/crypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "secret-toolkit-crypto"
version = "0.3.0"
version = "0.6.0"
edition = "2018"
authors = ["SCRT Labs <[email protected]>"]
license-file = "../../LICENSE"
Expand All @@ -23,7 +23,7 @@ rand_chacha = { version = "0.2.2", default-features = false, optional = true }
rand_core = { version = "0.5.1", default-features = false, optional = true }
sha2 = { version = "0.9.1", default-features = false, optional = true }
secp256k1 = { version = "0.21.3", optional = true }
cosmwasm-std = { package = "secret-cosmwasm-std", version = "0.10" }
cosmwasm-std = { package = "secret-cosmwasm-std", version = "1.0.0" }

[dev-dependencies]
secp256k1-test = { package = "secp256k1", version = "0.17", features = [
Expand Down
10 changes: 5 additions & 5 deletions packages/crypto/src/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,20 @@ mod tests {
}

#[test]
#[ignore] // Crypto functions are not implemented in `MockApi`
fn test_sign() {
let s = Secp256k1::new();
let (secp_privkey, _) = s.generate_keypair(&mut thread_rng());
let mock_api = MockApi::new(20);
let mock_api = MockApi::default();

let mut privkey = [0u8; PRIVATE_KEY_SIZE];
privkey.copy_from_slice(&secp_privkey[..]);

let data = sha_256(b"test");
let data = b"test";
let data_hash = sha_256(data);
let pk = PrivateKey::parse(&privkey).unwrap();
let signature = pk.sign(&data, mock_api);
let signature = pk.sign(data, mock_api);

let pubkey = pk.pubkey();
assert!(pubkey.verify(&data, signature, mock_api));
assert!(pubkey.verify(&data_hash, signature, mock_api));
}
}
8 changes: 4 additions & 4 deletions packages/incubator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "secret-toolkit-incubator"
version = "0.4.0"
version = "0.6.0"
edition = "2018"
authors = ["SCRT Labs <[email protected]>"]
license-file = "../../LICENSE"
Expand All @@ -15,9 +15,9 @@ all-features = true

[dependencies]
serde = { version = "1.0", optional = true }
cosmwasm-std = { package = "secret-cosmwasm-std", version = "0.10", optional = true }
cosmwasm-storage = { package = "secret-cosmwasm-storage", version = "0.10", optional = true }
secret-toolkit-serialization = { version = "0.3", path = "../serialization", optional = true }
cosmwasm-std = { package = "secret-cosmwasm-std", version = "1.0.0", optional = true }
cosmwasm-storage = { package = "secret-cosmwasm-storage", version = "1.0.0", optional = true }
secret-toolkit-serialization = { version = "0.6", path = "../serialization", optional = true }

[features]
generational-store = ["secret-toolkit-serialization", "serde", "cosmwasm-std"]
Expand Down
Loading

0 comments on commit 5c46e2d

Please sign in to comment.