From d012560ea1278ac3f203b5f7623c72be80f43060 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 10 Dec 2021 23:06:19 +0100 Subject: [PATCH 001/352] Introduce range_raw over Prefix --- packages/storage-plus/src/indexes/multi.rs | 18 ++++--- packages/storage-plus/src/indexes/unique.rs | 60 ++++++++++++++------- packages/storage-plus/src/prefix.rs | 43 +++++++++++---- 3 files changed, 87 insertions(+), 34 deletions(-) diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 4b8bd5c8e..1ee2373d2 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -144,29 +144,32 @@ where IK: PrimaryKey<'a> + Prefixer<'a>, { pub fn prefix(&self, p: IK) -> Prefix, T> { - Prefix::with_deserialization_function( + Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), self.pk_namespace, deserialize_multi_v, + deserialize_multi_v, ) } pub fn sub_prefix(&self, p: IK::Prefix) -> Prefix, T> { - Prefix::with_deserialization_function( + Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), self.pk_namespace, deserialize_multi_v, + deserialize_multi_v, ) } fn no_prefix(&self) -> Prefix, T> { - Prefix::with_deserialization_function( + Prefix::with_deserialization_functions( self.idx_namespace, &[], self.pk_namespace, deserialize_multi_v, + deserialize_multi_v, ) } @@ -257,20 +260,22 @@ where IK: PrimaryKey<'a> + Prefixer<'a>, { pub fn prefix_de(&self, p: IK) -> Prefix { - Prefix::with_deserialization_function( + Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), self.pk_namespace, deserialize_multi_kv::, + deserialize_multi_v, ) } pub fn sub_prefix_de(&self, p: IK::Prefix) -> Prefix { - Prefix::with_deserialization_function( + Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), self.pk_namespace, deserialize_multi_kv::, + deserialize_multi_v, ) } } @@ -336,11 +341,12 @@ where } fn no_prefix_de(&self) -> Prefix { - Prefix::with_deserialization_function( + Prefix::with_deserialization_functions( self.idx_namespace, &[], self.pk_namespace, deserialize_multi_kv::, + deserialize_multi_v, ) } } diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index 13d033475..922f3f647 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -113,21 +113,33 @@ where } pub fn prefix(&self, p: IK::Prefix) -> Prefix, T> { - Prefix::with_deserialization_function(self.idx_namespace, &p.prefix(), &[], |_, _, kv| { - deserialize_unique_v(kv) - }) + Prefix::with_deserialization_functions( + self.idx_namespace, + &p.prefix(), + &[], + |_, _, kv| deserialize_unique_v(kv), + |_, _, kv| deserialize_unique_v(kv), + ) } pub fn sub_prefix(&self, p: IK::SubPrefix) -> Prefix, T> { - Prefix::with_deserialization_function(self.idx_namespace, &p.prefix(), &[], |_, _, kv| { - deserialize_unique_v(kv) - }) + Prefix::with_deserialization_functions( + self.idx_namespace, + &p.prefix(), + &[], + |_, _, kv| deserialize_unique_v(kv), + |_, _, kv| deserialize_unique_v(kv), + ) } fn no_prefix(&self) -> Prefix, T> { - Prefix::with_deserialization_function(self.idx_namespace, &[], &[], |_, _, kv| { - deserialize_unique_v(kv) - }) + Prefix::with_deserialization_functions( + self.idx_namespace, + &[], + &[], + |_, _, kv| deserialize_unique_v(kv), + |_, _, kv| deserialize_unique_v(kv), + ) } /// returns all items that match this secondary index, always by pk Ascending @@ -233,20 +245,32 @@ where } pub fn prefix_de(&self, p: IK::Prefix) -> Prefix { - Prefix::with_deserialization_function(self.idx_namespace, &p.prefix(), &[], |_, _, kv| { - deserialize_unique_kv::(kv) - }) + Prefix::with_deserialization_functions( + self.idx_namespace, + &p.prefix(), + &[], + |_, _, kv| deserialize_unique_kv::(kv), + |_, _, kv| deserialize_unique_v(kv), + ) } pub fn sub_prefix_de(&self, p: IK::SubPrefix) -> Prefix { - Prefix::with_deserialization_function(self.idx_namespace, &p.prefix(), &[], |_, _, kv| { - deserialize_unique_kv::(kv) - }) + Prefix::with_deserialization_functions( + self.idx_namespace, + &p.prefix(), + &[], + |_, _, kv| deserialize_unique_kv::(kv), + |_, _, kv| deserialize_unique_v(kv), + ) } fn no_prefix_de(&self) -> Prefix { - Prefix::with_deserialization_function(self.idx_namespace, &[], &[], |_, _, kv| { - deserialize_unique_kv::(kv) - }) + Prefix::with_deserialization_functions( + self.idx_namespace, + &[], + &[], + |_, _, kv| deserialize_unique_kv::(kv), + |_, _, kv| deserialize_unique_v(kv), + ) } } diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 808d62638..4356830c2 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -67,10 +67,11 @@ impl<'a, K: Prefixer<'a>> PrefixBound<'a, K> { } } +type DeserializeVFn = fn(&dyn Storage, &[u8], Record) -> StdResult>; + type DeserializeKvFn = fn(&dyn Storage, &[u8], Record) -> StdResult<(::Output, T)>; -#[allow(dead_code)] pub fn default_deserializer_v( _: &dyn Storage, _: &[u8], @@ -98,7 +99,8 @@ where // see https://doc.rust-lang.org/std/marker/struct.PhantomData.html#unused-type-parameters for why this is needed data: PhantomData, pk_name: Vec, - de_fn: DeserializeKvFn, + de_fn_kv: DeserializeKvFn, + de_fn_v: DeserializeVFn, } impl Deref for Prefix @@ -119,29 +121,49 @@ where T: Serialize + DeserializeOwned, { pub fn new(top_name: &[u8], sub_names: &[Key]) -> Self { - Prefix::with_deserialization_function( + Prefix::with_deserialization_functions( top_name, sub_names, &[], default_deserializer_kv::, + default_deserializer_v, ) } - pub fn with_deserialization_function( + pub fn with_deserialization_functions( top_name: &[u8], sub_names: &[Key], pk_name: &[u8], - de_fn: DeserializeKvFn, + de_fn_kv: DeserializeKvFn, + de_fn_v: DeserializeVFn, ) -> Self { let storage_prefix = nested_namespaces_with_key(&[top_name], sub_names, b""); Prefix { storage_prefix, data: PhantomData, pk_name: pk_name.to_vec(), - de_fn, + de_fn_kv, + de_fn_v, } } + pub fn range_raw<'a>( + &self, + store: &'a dyn Storage, + min: Option, + max: Option, + order: Order, + ) -> Box>> + 'a> + where + T: 'a, + { + let de_fn = self.de_fn_v; + let pk_name = self.pk_name.clone(); + let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) + .map(move |kv| (de_fn)(store, &*pk_name, kv)); + Box::new(mapped) + } + pub fn range<'a>( &self, store: &'a dyn Storage, @@ -153,7 +175,7 @@ where T: 'a, K::Output: 'a, { - let de_fn = self.de_fn; + let de_fn = self.de_fn_kv; let pk_name = self.pk_name.clone(); let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) .map(move |kv| (de_fn)(store, &*pk_name, kv)); @@ -183,7 +205,7 @@ where T: 'a, K::Output: 'static, { - let de_fn = self.de_fn; + let de_fn = self.de_fn_kv; let pk_name = self.pk_name.clone(); let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) .map(move |kv| (de_fn)(store, &*pk_name, kv)); @@ -201,7 +223,7 @@ where T: 'a, K::Output: 'static, { - let de_fn = self.de_fn; + let de_fn = self.de_fn_kv; let pk_name = self.pk_name.clone(); let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) .map(move |kv| (de_fn)(store, &*pk_name, kv).map(|(k, _)| Ok(k))) @@ -326,7 +348,8 @@ mod test { storage_prefix: b"foo".to_vec(), data: PhantomData::, pk_name: vec![], - de_fn: |_, _, kv| deserialize_kv::, u64>(kv), + de_fn_kv: |_, _, kv| deserialize_kv::, u64>(kv), + de_fn_v: |_, _, kv| deserialize_v(kv), }; // set some data, we care about "foo" prefix From c7d1723f5c3357221b5f9725538898a4a60d1a84 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 10 Dec 2021 23:18:12 +0100 Subject: [PATCH 002/352] Replace prefix() + range() by prefix_de() + range_raw() Remove prefix() --- contracts/cw1155-base/src/contract.rs | 8 +++--- contracts/cw20-base/src/enumerable.rs | 4 +-- contracts/cw20-ics20/src/contract.rs | 4 +-- contracts/cw3-fixed-multisig/src/contract.rs | 4 +-- contracts/cw3-flex-multisig/src/contract.rs | 4 +-- packages/storage-plus/src/map.rs | 27 ++++++++------------ packages/storage-plus/src/snapshot/map.rs | 4 --- packages/storage-plus/src/snapshot/mod.rs | 8 +++--- 8 files changed, 27 insertions(+), 36 deletions(-) diff --git a/contracts/cw1155-base/src/contract.rs b/contracts/cw1155-base/src/contract.rs index d52940a7a..4c2296464 100644 --- a/contracts/cw1155-base/src/contract.rs +++ b/contracts/cw1155-base/src/contract.rs @@ -497,8 +497,8 @@ fn query_all_approvals( let start = start_after.map(|addr| Bound::exclusive(addr.as_ref())); let operators = APPROVES - .prefix(&owner) - .range(deps.storage, start, None, Order::Ascending) + .prefix_de(&owner) + .range_raw(deps.storage, start, None, Order::Ascending) .filter(|r| include_expired || r.is_err() || !r.as_ref().unwrap().1.is_expired(&env.block)) .take(limit) .map(parse_approval) @@ -516,8 +516,8 @@ fn query_tokens( let start = start_after.map(Bound::exclusive); let tokens = BALANCES - .prefix(&owner) - .range(deps.storage, start, None, Order::Ascending) + .prefix_de(&owner) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| item.map(|(k, _)| String::from_utf8(k).unwrap())) .collect::>()?; diff --git a/contracts/cw20-base/src/enumerable.rs b/contracts/cw20-base/src/enumerable.rs index 2f97be5fa..1bdb46a94 100644 --- a/contracts/cw20-base/src/enumerable.rs +++ b/contracts/cw20-base/src/enumerable.rs @@ -19,8 +19,8 @@ pub fn query_all_allowances( let start = start_after.map(Bound::exclusive); let allowances: StdResult> = ALLOWANCES - .prefix(&owner_addr) - .range(deps.storage, start, None, Order::Ascending) + .prefix_de(&owner_addr) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { let (k, v) = item?; diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index a8834eb96..ca959f473 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -165,8 +165,8 @@ pub fn query_channel(deps: Deps, id: String) -> StdResult { let info = CHANNEL_INFO.load(deps.storage, &id)?; // this returns Vec<(outstanding, total)> let state: StdResult> = CHANNEL_STATE - .prefix(&id) - .range(deps.storage, None, None, Order::Ascending) + .prefix_de(&id) + .range_raw(deps.storage, None, None, Order::Ascending) .map(|r| { let (k, v) = r?; let denom = String::from_utf8(k)?; diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 287946334..ce739f702 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -386,8 +386,8 @@ fn list_votes( let start = start_after.map(Bound::exclusive); let votes: StdResult> = BALLOTS - .prefix(proposal_id) - .range(deps.storage, start, None, Order::Ascending) + .prefix_de(proposal_id) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { let (key, ballot) = item?; diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index eafc2b221..c1b3f695b 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -383,8 +383,8 @@ fn list_votes( let start = addr.map(|addr| Bound::exclusive(addr.as_ref())); let votes: StdResult> = BALLOTS - .prefix(proposal_id) - .range(deps.storage, start, None, Order::Ascending) + .prefix_de(proposal_id) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { let (voter, ballot) = item?; diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 2b623e82f..9058e8037 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -49,11 +49,6 @@ where ) } - #[cfg(feature = "iterator")] - pub fn prefix(&self, p: K::Prefix) -> Prefix, T> { - Prefix::new(self.namespace, &p.prefix()) - } - #[cfg(feature = "iterator")] pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix, T> { Prefix::new(self.namespace, &p.prefix()) @@ -611,8 +606,8 @@ mod test { // let's try to iterate over a prefix let all: StdResult> = ALLOWANCE - .prefix(b"owner") - .range(&store, None, None, Order::Ascending) + .prefix_de(b"owner") + .range_raw(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -713,8 +708,8 @@ mod test { // let's iterate over a prefix let all: StdResult> = TRIPLE - .prefix((b"owner", 9)) - .range(&store, None, None, Order::Ascending) + .prefix_de((b"owner", 9)) + .range_raw(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -981,8 +976,8 @@ mod test { // get all under one key let all: StdResult> = ALLOWANCE - .prefix(b"owner") - .range(&store, None, None, Order::Ascending) + .prefix_de(b"owner") + .range_raw(&store, None, None, Order::Ascending) .collect(); assert_eq!( all?, @@ -991,8 +986,8 @@ mod test { // Or ranges between two items (even reverse) let all: StdResult> = ALLOWANCE - .prefix(b"owner") - .range( + .prefix_de(b"owner") + .range_raw( &store, Some(Bound::Exclusive(b"spender1".to_vec())), Some(Bound::Inclusive(b"spender2".to_vec())), @@ -1021,8 +1016,8 @@ mod test { // typical range under one prefix as a control let fives = AGES - .prefix(5) - .range(&store, None, None, Order::Ascending) + .prefix_de(5) + .range_raw(&store, None, None, Order::Ascending) .collect::>>() .unwrap(); assert_eq!(fives.len(), 2); @@ -1119,7 +1114,7 @@ mod test { ); let keys: Vec<_> = AGES - .no_prefix() + .no_prefix_de() .keys_de(&store, None, None, Order::Ascending) .collect(); println!("keys: {:?}", keys); diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index fb5a4c864..87cfc703b 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -69,10 +69,6 @@ where self.primary.key(k) } - pub fn prefix(&self, p: K::Prefix) -> Prefix, T> { - self.primary.prefix(p) - } - pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix, T> { self.primary.sub_prefix(p) } diff --git a/packages/storage-plus/src/snapshot/mod.rs b/packages/storage-plus/src/snapshot/mod.rs index d0418ce2c..e8a587d1f 100644 --- a/packages/storage-plus/src/snapshot/mod.rs +++ b/packages/storage-plus/src/snapshot/mod.rs @@ -87,8 +87,8 @@ where let start = Bound::inclusive(height); let first = self .changelog - .prefix(k.clone()) - .range(store, Some(start), None, Order::Ascending) + .prefix_de(k.clone()) + .range_raw(store, Some(start), None, Order::Ascending) .next() .transpose()?; if first.is_none() { @@ -146,8 +146,8 @@ where let start = Bound::inclusive_int(height); let first = self .changelog - .prefix(key) - .range(store, Some(start), None, Order::Ascending) + .prefix_de(key) + .range_raw(store, Some(start), None, Order::Ascending) .next(); if let Some(r) = first { From 7069f39b9b4459e13f51752e5e5a872ba25899a6 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 10 Dec 2021 23:22:37 +0100 Subject: [PATCH 003/352] Replace sub_prefix() + range() by sub_prefix_de() + range_raw() Remove sub_prefix() --- packages/storage-plus/src/map.rs | 9 ++------- packages/storage-plus/src/snapshot/map.rs | 4 ---- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 9058e8037..1e7471074 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -49,11 +49,6 @@ where ) } - #[cfg(feature = "iterator")] - pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix, T> { - Prefix::new(self.namespace, &p.prefix()) - } - #[cfg(feature = "iterator")] pub(crate) fn no_prefix(&self) -> Prefix, T> { Prefix::new(self.namespace, &[]) @@ -723,8 +718,8 @@ mod test { // let's iterate over a sub prefix let all: StdResult> = TRIPLE - .sub_prefix(b"owner") - .range(&store, None, None, Order::Ascending) + .sub_prefix_de(b"owner") + .range_raw(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(3, all.len()); diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index 87cfc703b..9086083a6 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -69,10 +69,6 @@ where self.primary.key(k) } - pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix, T> { - self.primary.sub_prefix(p) - } - fn no_prefix(&self) -> Prefix, T> { self.primary.no_prefix() } From 376cc58fad564121b90e996da92b4e9559069e6d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 10 Dec 2021 23:40:27 +0100 Subject: [PATCH 004/352] Replace no_prefix() + range() by no_prefix() + range_raw() --- packages/storage-plus/src/map.rs | 2 +- packages/storage-plus/src/snapshot/map.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 1e7471074..33526fd7c 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -164,7 +164,7 @@ where where T: 'c, { - self.no_prefix().range(store, min, max, order) + self.no_prefix().range_raw(store, min, max, order) } pub fn keys<'c>( diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index 9086083a6..24b03ccc0 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -174,7 +174,7 @@ where where T: 'c, { - self.no_prefix().range(store, min, max, order) + self.no_prefix().range_raw(store, min, max, order) } } From e047a906ce2f873c8a3bae5b15cb4c071c3ae5ba Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 10 Dec 2021 23:45:58 +0100 Subject: [PATCH 005/352] Rename keys to keys_raw --- contracts/cw20-atomic-swap/src/state.rs | 2 +- contracts/cw20-base/src/enumerable.rs | 2 +- contracts/cw20-escrow/src/state.rs | 2 +- packages/storage-plus/src/indexed_map.rs | 2 +- packages/storage-plus/src/indexed_snapshot.rs | 2 +- packages/storage-plus/src/indexes/multi.rs | 6 +++--- packages/storage-plus/src/indexes/unique.rs | 2 +- packages/storage-plus/src/map.rs | 7 +++---- packages/storage-plus/src/prefix.rs | 2 +- 9 files changed, 13 insertions(+), 14 deletions(-) diff --git a/contracts/cw20-atomic-swap/src/state.rs b/contracts/cw20-atomic-swap/src/state.rs index ac67aa6b0..7df449e9d 100644 --- a/contracts/cw20-atomic-swap/src/state.rs +++ b/contracts/cw20-atomic-swap/src/state.rs @@ -32,7 +32,7 @@ pub fn all_swap_ids( limit: usize, ) -> StdResult> { SWAPS - .keys(storage, start, None, Order::Ascending) + .keys_raw(storage, start, None, Order::Ascending) .take(limit) .map(|k| String::from_utf8(k).map_err(|_| StdError::invalid_utf8("Parsing swap id"))) .collect() diff --git a/contracts/cw20-base/src/enumerable.rs b/contracts/cw20-base/src/enumerable.rs index 1bdb46a94..319097ac3 100644 --- a/contracts/cw20-base/src/enumerable.rs +++ b/contracts/cw20-base/src/enumerable.rs @@ -45,7 +45,7 @@ pub fn query_all_accounts( let start = start_after.map(Bound::exclusive); let accounts: Result, _> = BALANCES - .keys(deps.storage, start, None, Order::Ascending) + .keys_raw(deps.storage, start, None, Order::Ascending) .map(String::from_utf8) .take(limit) .collect(); diff --git a/contracts/cw20-escrow/src/state.rs b/contracts/cw20-escrow/src/state.rs index 4539f826c..c09dcd3e2 100644 --- a/contracts/cw20-escrow/src/state.rs +++ b/contracts/cw20-escrow/src/state.rs @@ -95,7 +95,7 @@ pub const ESCROWS: Map<&str, Escrow> = Map::new("escrow"); /// This returns the list of ids for all registered escrows pub fn all_escrow_ids(storage: &dyn Storage) -> StdResult> { ESCROWS - .keys(storage, None, None, Order::Ascending) + .keys_raw(storage, None, None, Order::Ascending) .map(|k| String::from_utf8(k).map_err(|_| StdError::invalid_utf8("parsing escrow key"))) .collect() } diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 580182a31..aa6e0d8c7 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -828,7 +828,7 @@ mod test { map.idx .name .prefix(name.to_string()) - .keys(store, None, None, Order::Ascending) + .keys_raw(store, None, None, Order::Ascending) .count() }; diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 8b4470927..dc99fa3f5 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -819,7 +819,7 @@ mod test { map.idx .name .prefix(name.as_bytes().to_vec()) - .keys(store, None, None, Order::Ascending) + .keys_raw(store, None, None, Order::Ascending) .count() }; diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 1ee2373d2..44e99c819 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -180,14 +180,14 @@ where #[cfg(test)] pub fn count(&self, store: &dyn Storage, p: IK) -> usize { let prefix = self.prefix(p); - prefix.keys(store, None, None, Order::Ascending).count() + prefix.keys_raw(store, None, None, Order::Ascending).count() } #[cfg(test)] pub fn all_pks(&self, store: &dyn Storage, p: IK) -> Vec> { let prefix = self.prefix(p); prefix - .keys(store, None, None, Order::Ascending) + .keys_raw(store, None, None, Order::Ascending) .collect::>>() } @@ -226,7 +226,7 @@ where max: Option, order: Order, ) -> Box> + 'c> { - self.no_prefix().keys(store, min, max, order) + self.no_prefix().keys_raw(store, min, max, order) } /// While `range` over a `prefix` fixes the prefix to one element and iterates over the diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index 922f3f647..7b02ea7c2 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -180,7 +180,7 @@ where max: Option, order: Order, ) -> Box> + 'c> { - self.no_prefix().keys(store, min, max, order) + self.no_prefix().keys_raw(store, min, max, order) } } diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 33526fd7c..568684834 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -167,7 +167,7 @@ where self.no_prefix().range_raw(store, min, max, order) } - pub fn keys<'c>( + pub fn keys_raw<'c>( &self, store: &'c dyn Storage, min: Option, @@ -177,7 +177,7 @@ where where T: 'c, { - self.no_prefix().keys(store, min, max, order) + self.no_prefix().keys_raw(store, min, max, order) } } @@ -1019,8 +1019,7 @@ mod test { assert_eq!(fives, vec![(vec![7, 8, 9], 789), (vec![9, 8, 7], 987)]); let keys: Vec<_> = AGES - .no_prefix() - .keys(&store, None, None, Order::Ascending) + .keys_raw(&store, None, None, Order::Ascending) .collect(); println!("keys: {:?}", keys); diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 4356830c2..8a4335b25 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -182,7 +182,7 @@ where Box::new(mapped) } - pub fn keys<'a>( + pub fn keys_raw<'a>( &self, store: &'a dyn Storage, min: Option, From d0fd20e283c7e5dd98d619f4c6a99910df8eb241 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 07:33:51 +0100 Subject: [PATCH 006/352] Rename range to range_raw --- contracts/cw1-subkeys/src/contract.rs | 4 ++-- contracts/cw1155-base/src/contract.rs | 2 +- contracts/cw20-ics20/src/contract.rs | 2 +- contracts/cw3-fixed-multisig/src/contract.rs | 6 +++--- contracts/cw3-flex-multisig/src/contract.rs | 4 ++-- packages/controllers/src/claim.rs | 2 +- packages/multi-test/src/wasm.rs | 2 +- packages/storage-plus/src/map.rs | 22 +++++++++++++------- packages/storage-plus/src/snapshot/mod.rs | 2 +- packages/utils/src/pagination.rs | 4 ++-- 10 files changed, 28 insertions(+), 22 deletions(-) diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/contract.rs index f20a65ec6..84304be68 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs @@ -410,7 +410,7 @@ pub fn query_all_allowances( let start = start_after.map(Bound::exclusive); let res: StdResult> = ALLOWANCES - .range(deps.storage, start, None, Order::Ascending) + .range_raw(deps.storage, start, None, Order::Ascending) .filter(|item| { if let Ok((_, allow)) = item { !allow.expires.is_expired(&env.block) @@ -442,7 +442,7 @@ pub fn query_all_permissions( let start = start_after.map(Bound::exclusive); let res: StdResult> = PERMISSIONS - .range(deps.storage, start, None, Order::Ascending) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { item.and_then(|(k, perm)| { diff --git a/contracts/cw1155-base/src/contract.rs b/contracts/cw1155-base/src/contract.rs index 4c2296464..75c6ebbdf 100644 --- a/contracts/cw1155-base/src/contract.rs +++ b/contracts/cw1155-base/src/contract.rs @@ -532,7 +532,7 @@ fn query_all_tokens( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive); let tokens = TOKENS - .range(deps.storage, start, None, Order::Ascending) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| item.map(|(k, _)| String::from_utf8(k).unwrap())) .collect::>()?; diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index ca959f473..d3c3f3f0b 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -152,7 +152,7 @@ fn query_port(deps: Deps) -> StdResult { fn query_list(deps: Deps) -> StdResult { let channels: StdResult> = CHANNEL_INFO - .range(deps.storage, None, None, Order::Ascending) + .range_raw(deps.storage, None, None, Order::Ascending) .map(|r| r.map(|(_, v)| v)) .collect(); Ok(ListChannelsResponse { diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index ce739f702..f99882a1d 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -316,7 +316,7 @@ fn list_proposals( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive_int); let props: StdResult> = PROPOSALS - .range(deps.storage, start, None, Order::Ascending) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|p| map_proposal(&env.block, &threshold, p)) .collect(); @@ -339,7 +339,7 @@ fn reverse_proposals( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let end = start_before.map(Bound::exclusive_int); let props: StdResult> = PROPOSALS - .range(deps.storage, None, end, Order::Descending) + .range_raw(deps.storage, None, end, Order::Descending) .take(limit) .map(|p| map_proposal(&env.block, &threshold, p)) .collect(); @@ -417,7 +417,7 @@ fn list_voters( let start = start_after.map(Bound::exclusive); let voters: StdResult> = VOTERS - .range(deps.storage, start, None, Order::Ascending) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { let (key, weight) = item?; diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index c1b3f695b..b508331b4 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -318,7 +318,7 @@ fn list_proposals( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive_int); let props: StdResult> = PROPOSALS - .range(deps.storage, start, None, Order::Ascending) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|p| map_proposal(&env.block, p)) .collect(); @@ -335,7 +335,7 @@ fn reverse_proposals( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let end = start_before.map(Bound::exclusive_int); let props: StdResult> = PROPOSALS - .range(deps.storage, None, end, Order::Descending) + .range_raw(deps.storage, None, end, Order::Descending) .take(limit) .map(|p| map_proposal(&env.block, p)) .collect(); diff --git a/packages/controllers/src/claim.rs b/packages/controllers/src/claim.rs index 693fd2e7e..b4d1b502c 100644 --- a/packages/controllers/src/claim.rs +++ b/packages/controllers/src/claim.rs @@ -118,7 +118,7 @@ mod test { assert_eq!( claims .0 - .range(&deps.storage, None, None, Order::Ascending) + .range_raw(&deps.storage, None, None, Order::Ascending) .collect::>>() .unwrap() .len(), diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index 9b98bf509..1e1ef5872 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -791,7 +791,7 @@ where fn next_address(&self, storage: &dyn Storage) -> Addr { // FIXME: quite inefficient if we actually had 100s of contracts let count = CONTRACTS - .range(storage, None, None, Order::Ascending) + .range_raw(storage, None, None, Order::Ascending) .count(); // we make this longer so it is not rejected by tests Addr::unchecked(format!("Contract #{}", count.to_string())) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 568684834..5917a09c7 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -154,7 +154,7 @@ where Box::new(mapped) } - pub fn range<'c>( + pub fn range_raw<'c>( &self, store: &'c dyn Storage, min: Option, @@ -412,7 +412,9 @@ mod test { PEOPLE.save(&mut store, b"jim", &data2).unwrap(); // let's try to iterate! - let all: StdResult> = PEOPLE.range(&store, None, None, Order::Ascending).collect(); + let all: StdResult> = PEOPLE + .range_raw(&store, None, None, Order::Ascending) + .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); assert_eq!( @@ -425,7 +427,7 @@ mod test { // let's try to iterate over a range let all: StdResult> = PEOPLE - .range( + .range_raw( &store, Some(Bound::Inclusive(b"j".to_vec())), None, @@ -441,7 +443,7 @@ mod test { // let's try to iterate over a more restrictive range let all: StdResult> = PEOPLE - .range( + .range_raw( &store, Some(Bound::Inclusive(b"jo".to_vec())), None, @@ -586,7 +588,7 @@ mod test { // let's try to iterate! let all: StdResult> = ALLOWANCE - .range(&store, None, None, Order::Ascending) + .range_raw(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(3, all.len()); @@ -676,7 +678,9 @@ mod test { .unwrap(); // let's try to iterate! - let all: StdResult> = TRIPLE.range(&store, None, None, Order::Ascending).collect(); + let all: StdResult> = TRIPLE + .range_raw(&store, None, None, Order::Ascending) + .collect(); let all = all.unwrap(); assert_eq!(4, all.len()); assert_eq!( @@ -947,7 +951,9 @@ mod test { PEOPLE.save(&mut store, b"jim", &data2)?; // iterate over them all - let all: StdResult> = PEOPLE.range(&store, None, None, Order::Ascending).collect(); + let all: StdResult> = PEOPLE + .range_raw(&store, None, None, Order::Ascending) + .collect(); assert_eq!( all?, vec![(b"jim".to_vec(), data2), (b"john".to_vec(), data.clone())] @@ -955,7 +961,7 @@ mod test { // or just show what is after jim let all: StdResult> = PEOPLE - .range( + .range_raw( &store, Some(Bound::Exclusive(b"jim".to_vec())), None, diff --git a/packages/storage-plus/src/snapshot/mod.rs b/packages/storage-plus/src/snapshot/mod.rs index e8a587d1f..cdf3abc71 100644 --- a/packages/storage-plus/src/snapshot/mod.rs +++ b/packages/storage-plus/src/snapshot/mod.rs @@ -79,7 +79,7 @@ where // most recent checkpoint let checkpoint = self .checkpoints - .range(store, None, None, Order::Descending) + .range_raw(store, None, None, Order::Descending) .next() .transpose()?; if let Some((height, _)) = checkpoint { diff --git a/packages/utils/src/pagination.rs b/packages/utils/src/pagination.rs index 615993561..b346fb776 100644 --- a/packages/utils/src/pagination.rs +++ b/packages/utils/src/pagination.rs @@ -73,7 +73,7 @@ mod test { let start = calc_range_start(start_after).map(Bound::exclusive); let holders: Vec<(String, usize)> = HOLDERS - .range(&deps.storage, start, None, Order::Ascending) + .range_raw(&deps.storage, start, None, Order::Ascending) .map(deser_holder_kv) .take(LIMIT) .collect(); @@ -102,7 +102,7 @@ mod test { let end = calc_range_end(end_before).map(Bound::exclusive); let holders: Vec<(String, usize)> = HOLDERS - .range(&deps.storage, None, end, Order::Descending) + .range_raw(&deps.storage, None, end, Order::Descending) .map(deser_holder_kv) .take(LIMIT) .collect(); From 05d185516cb2a374ded016a968e543cecd3a8798 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 07:44:54 +0100 Subject: [PATCH 007/352] Replace no_prefix() + range() by no_prefix() + range_raw() in indexes --- packages/storage-plus/src/indexes/multi.rs | 2 +- packages/storage-plus/src/indexes/unique.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 44e99c819..3d29a49df 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -216,7 +216,7 @@ where where T: 'c, { - self.no_prefix().range(store, min, max, order) + self.no_prefix().range_raw(store, min, max, order) } pub fn keys<'c>( diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index 7b02ea7c2..f579cf8bd 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -170,7 +170,7 @@ where where T: 'c, { - self.no_prefix().range(store, min, max, order) + self.no_prefix().range_raw(store, min, max, order) } pub fn keys<'c>( From 57c470fe6e60ff76b4ba44fc9f08ce5665ae56a1 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 08:28:12 +0100 Subject: [PATCH 008/352] Replace no_prefix() + range() by no_prefix() + range_raw() in indexed maps --- packages/storage-plus/src/indexed_map.rs | 2 +- packages/storage-plus/src/indexed_snapshot.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index aa6e0d8c7..3b0e59d40 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -164,7 +164,7 @@ where where T: 'c, { - self.no_prefix().range(store, min, max, order) + self.no_prefix().range_raw(store, min, max, order) } } diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index dc99fa3f5..1b4e6b206 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -209,7 +209,7 @@ where where T: 'c, { - self.no_prefix().range(store, min, max, order) + self.no_prefix().range_raw(store, min, max, order) } } From 249b35f5755c6d222901abf98a545c2305879f8f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 08:42:53 +0100 Subject: [PATCH 009/352] Replace prefix() + range() by prefix_de() + range_raw() in unique index Remove UniqueIndex::prefix() --- packages/storage-plus/src/indexed_map.rs | 4 ++-- packages/storage-plus/src/indexed_snapshot.rs | 4 ++-- packages/storage-plus/src/indexes/unique.rs | 10 ---------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 3b0e59d40..cab7ed47d 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -937,8 +937,8 @@ mod test { let res: StdResult> = map .idx .name_lastname - .prefix(b"Maria".to_vec()) - .range(&store, None, None, Order::Ascending) + .prefix_de(b"Maria".to_vec()) + .range_raw(&store, None, None, Order::Ascending) .collect(); let marias = res.unwrap(); diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 1b4e6b206..c62d2ff15 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -925,8 +925,8 @@ mod test { let res: StdResult> = map .idx .name_lastname - .prefix(b"Maria".to_vec()) - .range(&store, None, None, Order::Ascending) + .prefix_de(b"Maria".to_vec()) + .range_raw(&store, None, None, Order::Ascending) .collect(); let marias = res.unwrap(); diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index f579cf8bd..1075746e1 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -112,16 +112,6 @@ where k.joined_key() } - pub fn prefix(&self, p: IK::Prefix) -> Prefix, T> { - Prefix::with_deserialization_functions( - self.idx_namespace, - &p.prefix(), - &[], - |_, _, kv| deserialize_unique_v(kv), - |_, _, kv| deserialize_unique_v(kv), - ) - } - pub fn sub_prefix(&self, p: IK::SubPrefix) -> Prefix, T> { Prefix::with_deserialization_functions( self.idx_namespace, From a2b64b8beea8166a2f4628b82426ab738b00295a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 08:44:10 +0100 Subject: [PATCH 010/352] Remove UniqueIndex::sub_prefix --- packages/storage-plus/src/indexes/unique.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index 1075746e1..dc1a3e45d 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -112,16 +112,6 @@ where k.joined_key() } - pub fn sub_prefix(&self, p: IK::SubPrefix) -> Prefix, T> { - Prefix::with_deserialization_functions( - self.idx_namespace, - &p.prefix(), - &[], - |_, _, kv| deserialize_unique_v(kv), - |_, _, kv| deserialize_unique_v(kv), - ) - } - fn no_prefix(&self) -> Prefix, T> { Prefix::with_deserialization_functions( self.idx_namespace, From 40a587f2ba86422e9016956e3e3801e45065825b Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 09:10:57 +0100 Subject: [PATCH 011/352] Replace prefix() + range() by prefix_de() + range_raw() in multi index Remove MultiIndex::prefix() Adjust MultiIndex::no_prefix() trait bounds --- packages/storage-plus/src/indexed_map.rs | 26 ++++++++-------- packages/storage-plus/src/indexed_snapshot.rs | 26 ++++++++-------- packages/storage-plus/src/indexes/multi.rs | 31 +++++++++---------- 3 files changed, 41 insertions(+), 42 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index cab7ed47d..901694853 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -414,8 +414,8 @@ mod test { let count = map .idx .name - .prefix("Maria".to_string()) - .range(&store, None, None, Order::Ascending) + .prefix_de("Maria".to_string()) + .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(2, count); @@ -423,8 +423,8 @@ mod test { let marias: Vec<_> = map .idx .name - .prefix("Maria".to_string()) - .range(&store, None, None, Order::Ascending) + .prefix_de("Maria".to_string()) + .range_raw(&store, None, None, Order::Ascending) .collect::>() .unwrap(); assert_eq!(2, marias.len()); @@ -436,8 +436,8 @@ mod test { let count = map .idx .name - .prefix("Marib".to_string()) - .range(&store, None, None, Order::Ascending) + .prefix_de("Marib".to_string()) + .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -445,8 +445,8 @@ mod test { let count = map .idx .name - .prefix("Mari`".to_string()) - .range(&store, None, None, Order::Ascending) + .prefix_de("Mari`".to_string()) + .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -454,8 +454,8 @@ mod test { let count = map .idx .name - .prefix("Maria5".to_string()) - .range(&store, None, None, Order::Ascending) + .prefix_de("Maria5".to_string()) + .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -560,8 +560,8 @@ mod test { let marias: Vec<_> = map .idx .name - .prefix("Maria".to_string()) - .range(&store, None, None, Order::Descending) + .prefix_de("Maria".to_string()) + .range_raw(&store, None, None, Order::Descending) .collect::>() .unwrap(); let count = marias.len(); @@ -827,7 +827,7 @@ mod test { -> usize { map.idx .name - .prefix(name.to_string()) + .prefix_de(name.to_string()) .keys_raw(store, None, None, Order::Ascending) .count() }; diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index c62d2ff15..c022322be 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -430,8 +430,8 @@ mod test { let count = map .idx .name - .prefix(b"Maria".to_vec()) - .range(&store, None, None, Order::Ascending) + .prefix_de(b"Maria".to_vec()) + .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(2, count); @@ -439,8 +439,8 @@ mod test { let marias: Vec<_> = map .idx .name - .prefix(b"Maria".to_vec()) - .range(&store, None, None, Order::Ascending) + .prefix_de(b"Maria".to_vec()) + .range_raw(&store, None, None, Order::Ascending) .collect::>() .unwrap(); assert_eq!(2, marias.len()); @@ -452,8 +452,8 @@ mod test { let count = map .idx .name - .prefix(b"Marib".to_vec()) - .range(&store, None, None, Order::Ascending) + .prefix_de(b"Marib".to_vec()) + .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -461,8 +461,8 @@ mod test { let count = map .idx .name - .prefix(b"Mari`".to_vec()) - .range(&store, None, None, Order::Ascending) + .prefix_de(b"Mari`".to_vec()) + .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -470,8 +470,8 @@ mod test { let count = map .idx .name - .prefix(b"Maria5".to_vec()) - .range(&store, None, None, Order::Ascending) + .prefix_de(b"Maria5".to_vec()) + .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -532,8 +532,8 @@ mod test { let marias: Vec<_> = map .idx .name - .prefix(b"Maria".to_vec()) - .range(&store, None, None, Order::Descending) + .prefix_de(b"Maria".to_vec()) + .range_raw(&store, None, None, Order::Descending) .collect::>() .unwrap(); let count = marias.len(); @@ -818,7 +818,7 @@ mod test { -> usize { map.idx .name - .prefix(name.as_bytes().to_vec()) + .prefix_de(name.as_bytes().to_vec()) .keys_raw(store, None, None, Order::Ascending) .count() }; diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 3d29a49df..2e0dbbcd6 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -143,16 +143,23 @@ where T: Serialize + DeserializeOwned + Clone, IK: PrimaryKey<'a> + Prefixer<'a>, { - pub fn prefix(&self, p: IK) -> Prefix, T> { + fn no_prefix(&self) -> Prefix, T> { Prefix::with_deserialization_functions( self.idx_namespace, - &p.prefix(), + &[], self.pk_namespace, deserialize_multi_v, deserialize_multi_v, ) } +} +impl<'a, IK, T, PK> MultiIndex<'a, IK, T, PK> +where + PK: PrimaryKey<'a> + KeyDeserialize, + T: Serialize + DeserializeOwned + Clone, + IK: PrimaryKey<'a> + Prefixer<'a>, +{ pub fn sub_prefix(&self, p: IK::Prefix) -> Prefix, T> { Prefix::with_deserialization_functions( self.idx_namespace, @@ -163,29 +170,19 @@ where ) } - fn no_prefix(&self) -> Prefix, T> { - Prefix::with_deserialization_functions( - self.idx_namespace, - &[], - self.pk_namespace, - deserialize_multi_v, - deserialize_multi_v, - ) - } - pub fn index_key(&self, k: IK) -> Vec { k.joined_extra_key(b"") } #[cfg(test)] pub fn count(&self, store: &dyn Storage, p: IK) -> usize { - let prefix = self.prefix(p); + let prefix = self.prefix_de(p); prefix.keys_raw(store, None, None, Order::Ascending).count() } #[cfg(test)] pub fn all_pks(&self, store: &dyn Storage, p: IK) -> Vec> { - let prefix = self.prefix(p); + let prefix = self.prefix_de(p); prefix .keys_raw(store, None, None, Order::Ascending) .collect::>>() @@ -193,8 +190,10 @@ where #[cfg(test)] pub fn all_items(&self, store: &dyn Storage, p: IK) -> StdResult>> { - let prefix = self.prefix(p); - prefix.range(store, None, None, Order::Ascending).collect() + let prefix = self.prefix_de(p); + prefix + .range_raw(store, None, None, Order::Ascending) + .collect() } } From a2112abd3165fab5e308305899e95197831ba517 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 09:15:42 +0100 Subject: [PATCH 012/352] Replace sub_prefix() + range() by sub_prefix_de() + range_raw() in multi index Remove MultiIndex::sub_prefix --- packages/storage-plus/src/indexed_map.rs | 4 ++-- packages/storage-plus/src/indexed_snapshot.rs | 4 ++-- packages/storage-plus/src/indexes/multi.rs | 10 ---------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 901694853..592becca0 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -676,8 +676,8 @@ mod test { let marias: Vec<_> = map .idx .name_age - .sub_prefix(b"Maria".to_vec()) - .range(&store, None, None, Order::Descending) + .sub_prefix_de(b"Maria".to_vec()) + .range_raw(&store, None, None, Order::Descending) .collect::>() .unwrap(); let count = marias.len(); diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index c022322be..ff9655662 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -657,8 +657,8 @@ mod test { let marias: Vec<_> = map .idx .name_age - .sub_prefix(b"Maria".to_vec()) - .range(&store, None, None, Order::Descending) + .sub_prefix_de(b"Maria".to_vec()) + .range_raw(&store, None, None, Order::Descending) .collect::>() .unwrap(); let count = marias.len(); diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 2e0dbbcd6..ee574f45b 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -160,16 +160,6 @@ where T: Serialize + DeserializeOwned + Clone, IK: PrimaryKey<'a> + Prefixer<'a>, { - pub fn sub_prefix(&self, p: IK::Prefix) -> Prefix, T> { - Prefix::with_deserialization_functions( - self.idx_namespace, - &p.prefix(), - self.pk_namespace, - deserialize_multi_v, - deserialize_multi_v, - ) - } - pub fn index_key(&self, k: IK) -> Vec { k.joined_extra_key(b"") } From 69d26042860990021d81ae0922c3167b8e147f07 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 09:30:20 +0100 Subject: [PATCH 013/352] Remove Prefix::range --- packages/storage-plus/src/map.rs | 2 +- packages/storage-plus/src/prefix.rs | 44 +++++++++-------------------- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 5917a09c7..c1f2e4b4d 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -1104,7 +1104,7 @@ mod test { // typical range under one prefix as a control let fives = AGES .prefix_de(5) - .range(&store, None, None, Order::Ascending) + .range_de(&store, None, None, Order::Ascending) .collect::>>() .unwrap(); assert_eq!(fives.len(), 2); diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 8a4335b25..f522de923 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -164,24 +164,6 @@ where Box::new(mapped) } - pub fn range<'a>( - &self, - store: &'a dyn Storage, - min: Option, - max: Option, - order: Order, - ) -> Box> + 'a> - where - T: 'a, - K::Output: 'a, - { - let de_fn = self.de_fn_kv; - let pk_name = self.pk_name.clone(); - let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) - .map(move |kv| (de_fn)(store, &*pk_name, kv)); - Box::new(mapped) - } - pub fn keys_raw<'a>( &self, store: &'a dyn Storage, @@ -368,16 +350,18 @@ mod test { let expected_reversed: Vec<(Vec, u64)> = expected.iter().rev().cloned().collect(); // let's do the basic sanity check - let res: StdResult> = prefix.range(&store, None, None, Order::Ascending).collect(); + let res: StdResult> = prefix + .range_raw(&store, None, None, Order::Ascending) + .collect(); assert_eq!(&expected, &res.unwrap()); let res: StdResult> = prefix - .range(&store, None, None, Order::Descending) + .range_raw(&store, None, None, Order::Descending) .collect(); assert_eq!(&expected_reversed, &res.unwrap()); // now let's check some ascending ranges let res: StdResult> = prefix - .range( + .range_raw( &store, Some(Bound::Inclusive(b"ra".to_vec())), None, @@ -387,7 +371,7 @@ mod test { assert_eq!(&expected[1..], res.unwrap().as_slice()); // skip excluded let res: StdResult> = prefix - .range( + .range_raw( &store, Some(Bound::Exclusive(b"ra".to_vec())), None, @@ -397,7 +381,7 @@ mod test { assert_eq!(&expected[2..], res.unwrap().as_slice()); // if we exclude something a little lower, we get matched let res: StdResult> = prefix - .range( + .range_raw( &store, Some(Bound::Exclusive(b"r".to_vec())), None, @@ -408,7 +392,7 @@ mod test { // now let's check some descending ranges let res: StdResult> = prefix - .range( + .range_raw( &store, None, Some(Bound::Inclusive(b"ra".to_vec())), @@ -418,7 +402,7 @@ mod test { assert_eq!(&expected_reversed[1..], res.unwrap().as_slice()); // skip excluded let res: StdResult> = prefix - .range( + .range_raw( &store, None, Some(Bound::Exclusive(b"ra".to_vec())), @@ -428,7 +412,7 @@ mod test { assert_eq!(&expected_reversed[2..], res.unwrap().as_slice()); // if we exclude something a little higher, we get matched let res: StdResult> = prefix - .range( + .range_raw( &store, None, Some(Bound::Exclusive(b"rb".to_vec())), @@ -439,7 +423,7 @@ mod test { // now test when both sides are set let res: StdResult> = prefix - .range( + .range_raw( &store, Some(Bound::Inclusive(b"ra".to_vec())), Some(Bound::Exclusive(b"zi".to_vec())), @@ -449,7 +433,7 @@ mod test { assert_eq!(&expected[1..2], res.unwrap().as_slice()); // and descending let res: StdResult> = prefix - .range( + .range_raw( &store, Some(Bound::Inclusive(b"ra".to_vec())), Some(Bound::Exclusive(b"zi".to_vec())), @@ -459,7 +443,7 @@ mod test { assert_eq!(&expected[1..2], res.unwrap().as_slice()); // Include both sides let res: StdResult> = prefix - .range( + .range_raw( &store, Some(Bound::Inclusive(b"ra".to_vec())), Some(Bound::Inclusive(b"zi".to_vec())), @@ -469,7 +453,7 @@ mod test { assert_eq!(&expected_reversed[..2], res.unwrap().as_slice()); // Exclude both sides let res: StdResult> = prefix - .range( + .range_raw( &store, Some(Bound::Exclusive(b"ra".to_vec())), Some(Bound::Exclusive(b"zi".to_vec())), From e6e1926d342487504ff4ffd6f91f65d4e2179e32 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 10:07:29 +0100 Subject: [PATCH 014/352] Rename keys/range to keys_raw/range_raw in indexes --- packages/storage-plus/src/indexed_map.rs | 8 ++++---- packages/storage-plus/src/indexed_snapshot.rs | 2 +- packages/storage-plus/src/indexes/multi.rs | 4 ++-- packages/storage-plus/src/indexes/unique.rs | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 592becca0..bc9fb93a8 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -469,7 +469,7 @@ mod test { let count = map .idx .name - .range(&store, Some(Bound::inclusive(key)), None, Order::Ascending) + .range_raw(&store, Some(Bound::inclusive(key)), None, Order::Ascending) .count(); // gets from the first "Maria" until the end assert_eq!(4, count); @@ -484,7 +484,7 @@ mod test { let count = map .idx .name - .range(&store, Some(Bound::exclusive(key)), None, Order::Ascending) + .range_raw(&store, Some(Bound::exclusive(key)), None, Order::Ascending) .count(); // gets from the 2nd "Maria" until the end assert_eq!(3, count); @@ -497,7 +497,7 @@ mod test { let count = map .idx .age - .range( + .range_raw( &store, Some(Bound::inclusive(age_key)), None, @@ -871,7 +871,7 @@ mod test { let res: StdResult> = map .idx .age - .range(&store, None, None, Order::Ascending) + .range_raw(&store, None, None, Order::Ascending) .collect(); let ages = res.unwrap(); diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index ff9655662..1015333f4 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -863,7 +863,7 @@ mod test { let res: StdResult> = map .idx .age - .range(&store, None, None, Order::Ascending) + .range_raw(&store, None, None, Order::Ascending) .collect(); let ages = res.unwrap(); diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index ee574f45b..b1453752f 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -195,7 +195,7 @@ where { // I would prefer not to copy code from Prefix, but no other way // with lifetimes (create Prefix inside function and return ref = no no) - pub fn range<'c>( + pub fn range_raw<'c>( &'c self, store: &'c dyn Storage, min: Option, @@ -208,7 +208,7 @@ where self.no_prefix().range_raw(store, min, max, order) } - pub fn keys<'c>( + pub fn keys_raw<'c>( &'c self, store: &'c dyn Storage, min: Option, diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index dc1a3e45d..dcdb40744 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -140,7 +140,7 @@ where { // I would prefer not to copy code from Prefix, but no other way // with lifetimes (create Prefix inside function and return ref = no no) - pub fn range<'c>( + pub fn range_raw<'c>( &self, store: &'c dyn Storage, min: Option, @@ -153,7 +153,7 @@ where self.no_prefix().range_raw(store, min, max, order) } - pub fn keys<'c>( + pub fn keys_raw<'c>( &self, store: &'c dyn Storage, min: Option, From 938b897dadad520b5b458af62ab31f769a19f19d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 10:18:58 +0100 Subject: [PATCH 015/352] Rename keys/range to keys_raw/range_raw in indexed maps --- packages/storage-plus/src/indexed_map.rs | 12 +++++++++++- packages/storage-plus/src/indexed_snapshot.rs | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index bc9fb93a8..5d39e6cfb 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -154,7 +154,7 @@ where { // I would prefer not to copy code from Prefix, but no other way // with lifetimes (create Prefix inside function and return ref = no no) - pub fn range<'c>( + pub fn range_raw<'c>( &self, store: &'c dyn Storage, min: Option, @@ -166,6 +166,16 @@ where { self.no_prefix().range_raw(store, min, max, order) } + + pub fn keys_raw<'c>( + &self, + store: &'c dyn Storage, + min: Option, + max: Option, + order: cosmwasm_std::Order, + ) -> Box> + 'c> { + self.no_prefix().keys_raw(store, min, max, order) + } } #[cfg(feature = "iterator")] diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 1015333f4..4b291a7d3 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -199,7 +199,7 @@ where { // I would prefer not to copy code from Prefix, but no other way // with lifetimes (create Prefix inside function and return ref = no no) - pub fn range<'c>( + pub fn range_raw<'c>( &self, store: &'c dyn Storage, min: Option, @@ -211,6 +211,16 @@ where { self.no_prefix().range_raw(store, min, max, order) } + + pub fn keys_raw<'c>( + &self, + store: &'c dyn Storage, + min: Option, + max: Option, + order: cosmwasm_std::Order, + ) -> Box> + 'c> { + self.no_prefix().keys_raw(store, min, max, order) + } } #[cfg(feature = "iterator")] From 0e1af087216c96b2967bbb2d92b18ddbbe1acfa1 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 12:53:25 +0100 Subject: [PATCH 016/352] Rename keys/range to keys_raw/range_raw in snampshot map --- contracts/cw4-group/src/contract.rs | 2 +- contracts/cw4-stake/src/contract.rs | 2 +- packages/storage-plus/src/snapshot/map.rs | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/contracts/cw4-group/src/contract.rs b/contracts/cw4-group/src/contract.rs index 1600d020e..e0a34d3f1 100644 --- a/contracts/cw4-group/src/contract.rs +++ b/contracts/cw4-group/src/contract.rs @@ -193,7 +193,7 @@ fn list_members( let start = addr.map(|addr| Bound::exclusive(addr.to_string())); let members: StdResult> = MEMBERS - .range(deps.storage, start, None, Order::Ascending) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { let (key, weight) = item?; diff --git a/contracts/cw4-stake/src/contract.rs b/contracts/cw4-stake/src/contract.rs index 2b4d86774..20aa3b6f2 100644 --- a/contracts/cw4-stake/src/contract.rs +++ b/contracts/cw4-stake/src/contract.rs @@ -342,7 +342,7 @@ fn list_members( let start = addr.map(|addr| Bound::exclusive(addr.as_ref())); let members: StdResult> = MEMBERS - .range(deps.storage, start, None, Order::Ascending) + .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { let (key, weight) = item?; diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index 24b03ccc0..90e84e5fd 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -164,7 +164,7 @@ where { // I would prefer not to copy code from Prefix, but no other way // with lifetimes (create Prefix inside function and return ref = no no) - pub fn range<'c>( + pub fn range_raw<'c>( &self, store: &'c dyn Storage, min: Option, @@ -176,6 +176,19 @@ where { self.no_prefix().range_raw(store, min, max, order) } + + pub fn keys_raw<'c>( + &self, + store: &'c dyn Storage, + min: Option, + max: Option, + order: cosmwasm_std::Order, + ) -> Box> + 'c> + where + T: 'c, + { + self.no_prefix().keys_raw(store, min, max, order) + } } #[cfg(feature = "iterator")] From 3542f03f164c6352a810fb1e75127431168c4d6f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 12:54:39 +0100 Subject: [PATCH 017/352] Remove sub_/prefix() from indexed maps --- packages/storage-plus/src/indexed_map.rs | 10 ---------- packages/storage-plus/src/indexed_snapshot.rs | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 5d39e6cfb..8fb32463e 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -129,16 +129,6 @@ where self.primary.may_load(store, key) } - // use prefix to scan -> range - pub fn prefix(&self, p: K::Prefix) -> Prefix, T> { - Prefix::new(self.pk_namespace, &p.prefix()) - } - - // use sub_prefix to scan -> range - pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix, T> { - Prefix::new(self.pk_namespace, &p.prefix()) - } - // use no_prefix to scan -> range fn no_prefix(&self) -> Prefix, T> { Prefix::new(self.pk_namespace, &[]) diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 4b291a7d3..344c1eb81 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -174,16 +174,6 @@ where self.primary.may_load(store, key) } - // use prefix to scan -> range - pub fn prefix(&self, p: K::Prefix) -> Prefix, T> { - Prefix::new(self.pk_namespace, &p.prefix()) - } - - // use sub_prefix to scan -> range - pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix, T> { - Prefix::new(self.pk_namespace, &p.prefix()) - } - // use no_prefix to scan -> range pub fn no_prefix(&self) -> Prefix, T> { Prefix::new(self.pk_namespace, &[]) From 6fc2608d7e8eb46d5b1ba022f3baea5f26030b95 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 12:58:27 +0100 Subject: [PATCH 018/352] Rename prefix_range to prefix_range_raw --- packages/storage-plus/src/map.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index c1f2e4b4d..08581f170 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -138,7 +138,7 @@ where /// itself, and iterates over those (inclusively or exclusively, depending on `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. - pub fn prefix_range<'c>( + pub fn prefix_range_raw<'c>( &self, store: &'c dyn Storage, min: Option>, @@ -1031,7 +1031,7 @@ mod test { // using inclusive bounds both sides let include = AGES - .prefix_range( + .prefix_range_raw( &store, Some(PrefixBound::inclusive(3u32)), Some(PrefixBound::inclusive(7u32)), @@ -1045,7 +1045,7 @@ mod test { // using exclusive bounds both sides let exclude = AGES - .prefix_range( + .prefix_range_raw( &store, Some(PrefixBound::exclusive(3u32)), Some(PrefixBound::exclusive(7u32)), @@ -1059,7 +1059,7 @@ mod test { // using inclusive in descending let include = AGES - .prefix_range( + .prefix_range_raw( &store, Some(PrefixBound::inclusive(3u32)), Some(PrefixBound::inclusive(5u32)), @@ -1073,7 +1073,7 @@ mod test { // using exclusive in descending let include = AGES - .prefix_range( + .prefix_range_raw( &store, Some(PrefixBound::exclusive(2u32)), Some(PrefixBound::exclusive(5u32)), From 8a0d2eb73844b9621edf807b868d32389cfd35a4 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 13:03:09 +0100 Subject: [PATCH 019/352] Rename prefix_range to prefix_range_raw in indexed map --- packages/storage-plus/src/indexed_map.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 8fb32463e..f703bcbde 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -180,7 +180,7 @@ where /// itself, and iterates over those (inclusively or exclusively, depending on `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. - pub fn prefix_range<'c>( + pub fn prefix_range_raw<'c>( &self, store: &'c dyn Storage, min: Option>, @@ -1429,7 +1429,7 @@ mod test { let items: Vec<_> = map .idx .secondary - .prefix_range( + .prefix_range_raw( &store, None, Some(PrefixBound::inclusive(1u64)), From d58272896dabfa2078ac8f9f796268384e243b56 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 13:03:50 +0100 Subject: [PATCH 020/352] Rename prefix_range to prefix_range_raw in multi index --- packages/storage-plus/src/indexes/multi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index b1453752f..48822878e 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -224,7 +224,7 @@ where /// `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. - pub fn prefix_range<'c>( + pub fn prefix_range_raw<'c>( &'c self, store: &'c dyn Storage, min: Option>, From 2f6b4cb3bdeb5cf418360ecbae3e8bcde79e3361 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 13:30:27 +0100 Subject: [PATCH 021/352] Remove useless dereference --- packages/storage-plus/src/prefix.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index f522de923..5ce9bf159 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -160,7 +160,7 @@ where let de_fn = self.de_fn_v; let pk_name = self.pk_name.clone(); let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) - .map(move |kv| (de_fn)(store, &*pk_name, kv)); + .map(move |kv| (de_fn)(store, &pk_name, kv)); Box::new(mapped) } @@ -190,7 +190,7 @@ where let de_fn = self.de_fn_kv; let pk_name = self.pk_name.clone(); let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) - .map(move |kv| (de_fn)(store, &*pk_name, kv)); + .map(move |kv| (de_fn)(store, &pk_name, kv)); Box::new(mapped) } @@ -208,7 +208,7 @@ where let de_fn = self.de_fn_kv; let pk_name = self.pk_name.clone(); let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) - .map(move |kv| (de_fn)(store, &*pk_name, kv).map(|(k, _)| Ok(k))) + .map(move |kv| (de_fn)(store, &pk_name, kv).map(|(k, _)| Ok(k))) .flatten(); Box::new(mapped) } From bb3137c9590d74ce8d9a903d5e1d02334c97ec2a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 13:33:52 +0100 Subject: [PATCH 022/352] Rename keys_/range_de to keys/range in Prefix --- packages/storage-plus/src/indexed_map.rs | 18 +++++++++--------- packages/storage-plus/src/indexed_snapshot.rs | 14 +++++++------- packages/storage-plus/src/indexes/multi.rs | 4 ++-- packages/storage-plus/src/indexes/unique.rs | 4 ++-- packages/storage-plus/src/map.rs | 14 +++++++------- packages/storage-plus/src/prefix.rs | 4 ++-- packages/storage-plus/src/snapshot/map.rs | 8 ++++---- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index f703bcbde..89d0388c0 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -255,7 +255,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().range_de(store, min, max, order) + self.no_prefix_de().range(store, min, max, order) } pub fn keys_de<'c>( @@ -269,7 +269,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().keys_de(store, min, max, order) + self.no_prefix_de().keys(store, min, max, order) } fn no_prefix_de(&self) -> Prefix { @@ -617,7 +617,7 @@ mod test { .idx .name .prefix_de("Maria".to_string()) - .range_de(&store, None, None, Order::Descending) + .range(&store, None, None, Order::Descending) .collect::>() .unwrap(); let count = marias.len(); @@ -738,7 +738,7 @@ mod test { .idx .name_age .sub_prefix_de(b"Maria".to_vec()) - .range_de(&store, None, None, Order::Descending) + .range(&store, None, None, Order::Descending) .collect::>() .unwrap(); let count = marias.len(); @@ -967,7 +967,7 @@ mod test { .idx .name_lastname .prefix_de(b"Maria".to_vec()) - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let marias = res.unwrap(); @@ -1041,7 +1041,7 @@ mod test { // type checks let all: StdResult> = map .prefix_de(()) - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!( @@ -1100,7 +1100,7 @@ mod test { // let's prefix and iterate let result: StdResult> = map .prefix_de("2") - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let result = result.unwrap(); assert_eq!( @@ -1155,7 +1155,7 @@ mod test { // let's prefix and iterate let result: StdResult> = map .prefix_de(("1", "2")) - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let result = result.unwrap(); assert_eq!(result, [("5628".to_string(), data2),]); @@ -1207,7 +1207,7 @@ mod test { // let's sub-prefix and iterate let result: StdResult> = map .sub_prefix_de("1") - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let result = result.unwrap(); assert_eq!( diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 344c1eb81..415cac5cd 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -271,7 +271,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().range_de(store, min, max, order) + self.no_prefix_de().range(store, min, max, order) } pub fn keys_de<'c>( @@ -285,7 +285,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().keys_de(store, min, max, order) + self.no_prefix_de().keys(store, min, max, order) } fn no_prefix_de(&self) -> Prefix { @@ -593,7 +593,7 @@ mod test { .idx .name .prefix_de(b"Maria".to_vec()) - .range_de(&store, None, None, Order::Descending) + .range(&store, None, None, Order::Descending) .collect::>() .unwrap(); let count = marias.len(); @@ -724,7 +724,7 @@ mod test { .idx .name_age .sub_prefix_de(b"Maria".to_vec()) - .range_de(&store, None, None, Order::Descending) + .range(&store, None, None, Order::Descending) .collect::>() .unwrap(); let count = marias.len(); @@ -955,7 +955,7 @@ mod test { .idx .name_lastname .prefix_de(b"Maria".to_vec()) - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let marias = res.unwrap(); @@ -1029,7 +1029,7 @@ mod test { // type checks let all: StdResult> = map .prefix_de(()) - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!( @@ -1056,7 +1056,7 @@ mod test { // type checks let all: StdResult> = map .sub_prefix_de(()) - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!( diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 48822878e..99f46eaae 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -312,7 +312,7 @@ where T: 'c, PK::Output: 'static, { - self.no_prefix_de().range_de(store, min, max, order) + self.no_prefix_de().range(store, min, max, order) } pub fn keys_de<'c>( @@ -326,7 +326,7 @@ where T: 'c, PK::Output: 'static, { - self.no_prefix_de().keys_de(store, min, max, order) + self.no_prefix_de().keys(store, min, max, order) } fn no_prefix_de(&self) -> Prefix { diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index dcdb40744..38adff44a 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -207,7 +207,7 @@ where T: 'c, PK::Output: 'static, { - self.no_prefix_de().range_de(store, min, max, order) + self.no_prefix_de().range(store, min, max, order) } pub fn keys_de<'c>( @@ -221,7 +221,7 @@ where T: 'c, PK::Output: 'static, { - self.no_prefix_de().keys_de(store, min, max, order) + self.no_prefix_de().keys(store, min, max, order) } pub fn prefix_de(&self, p: IK::Prefix) -> Prefix { diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 08581f170..19818d343 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -222,7 +222,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().range_de(store, min, max, order) + self.no_prefix_de().range(store, min, max, order) } pub fn keys_de<'c>( @@ -236,7 +236,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().keys_de(store, min, max, order) + self.no_prefix_de().keys(store, min, max, order) } fn no_prefix_de(&self) -> Prefix { @@ -648,7 +648,7 @@ mod test { // let's try to iterate over a prefix_de let all: StdResult> = ALLOWANCE .prefix_de(b"owner") - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -776,7 +776,7 @@ mod test { // let's iterate over a sub_prefix_de let all: StdResult> = TRIPLE .sub_prefix_de(b"owner") - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(3, all.len()); @@ -792,7 +792,7 @@ mod test { // let's iterate over a prefix_de let all: StdResult> = TRIPLE .prefix_de((b"owner", 9)) - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -1104,7 +1104,7 @@ mod test { // typical range under one prefix as a control let fives = AGES .prefix_de(5) - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect::>>() .unwrap(); assert_eq!(fives.len(), 2); @@ -1115,7 +1115,7 @@ mod test { let keys: Vec<_> = AGES .no_prefix_de() - .keys_de(&store, None, None, Order::Ascending) + .keys(&store, None, None, Order::Ascending) .collect(); println!("keys: {:?}", keys); diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 5ce9bf159..5c210052a 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -176,7 +176,7 @@ where Box::new(mapped) } - pub fn range_de<'a>( + pub fn range<'a>( &self, store: &'a dyn Storage, min: Option, @@ -194,7 +194,7 @@ where Box::new(mapped) } - pub fn keys_de<'a>( + pub fn keys<'a>( &self, store: &'a dyn Storage, min: Option, diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index 90e84e5fd..8f50acaf6 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -232,7 +232,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().range_de(store, min, max, order) + self.no_prefix_de().range(store, min, max, order) } pub fn keys_de<'c>( @@ -246,7 +246,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().keys_de(store, min, max, order) + self.no_prefix_de().keys(store, min, max, order) } pub fn prefix_de(&self, p: K::Prefix) -> Prefix { @@ -557,7 +557,7 @@ mod tests { // let's prefix and iterate let all: StdResult> = EVERY_COMPOSITE_KEY .prefix_de("C") - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(1, all.len()); @@ -577,7 +577,7 @@ mod tests { // sub_prefix_de type checks let all: StdResult> = EVERY_COMPOSITE_KEY .sub_prefix_de(()) - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); From e06eb1456aef2ea6dc33dc14c277d73e85e00856 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:09:02 +0100 Subject: [PATCH 023/352] Rename prefix_/prefix_range_/keys_/range_de to prefix/prefix_range/keys/range in Map --- contracts/cw1155-base/src/contract.rs | 4 +- contracts/cw20-base/src/enumerable.rs | 2 +- contracts/cw20-ics20/src/contract.rs | 2 +- contracts/cw3-fixed-multisig/src/contract.rs | 2 +- contracts/cw3-flex-multisig/src/contract.rs | 2 +- packages/storage-plus/src/map.rs | 67 +++++++++----------- packages/storage-plus/src/snapshot/mod.rs | 4 +- 7 files changed, 38 insertions(+), 45 deletions(-) diff --git a/contracts/cw1155-base/src/contract.rs b/contracts/cw1155-base/src/contract.rs index 75c6ebbdf..74291b0f1 100644 --- a/contracts/cw1155-base/src/contract.rs +++ b/contracts/cw1155-base/src/contract.rs @@ -497,7 +497,7 @@ fn query_all_approvals( let start = start_after.map(|addr| Bound::exclusive(addr.as_ref())); let operators = APPROVES - .prefix_de(&owner) + .prefix(&owner) .range_raw(deps.storage, start, None, Order::Ascending) .filter(|r| include_expired || r.is_err() || !r.as_ref().unwrap().1.is_expired(&env.block)) .take(limit) @@ -516,7 +516,7 @@ fn query_tokens( let start = start_after.map(Bound::exclusive); let tokens = BALANCES - .prefix_de(&owner) + .prefix(&owner) .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| item.map(|(k, _)| String::from_utf8(k).unwrap())) diff --git a/contracts/cw20-base/src/enumerable.rs b/contracts/cw20-base/src/enumerable.rs index 319097ac3..7b6c526c8 100644 --- a/contracts/cw20-base/src/enumerable.rs +++ b/contracts/cw20-base/src/enumerable.rs @@ -19,7 +19,7 @@ pub fn query_all_allowances( let start = start_after.map(Bound::exclusive); let allowances: StdResult> = ALLOWANCES - .prefix_de(&owner_addr) + .prefix(&owner_addr) .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index d3c3f3f0b..03a806102 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -165,7 +165,7 @@ pub fn query_channel(deps: Deps, id: String) -> StdResult { let info = CHANNEL_INFO.load(deps.storage, &id)?; // this returns Vec<(outstanding, total)> let state: StdResult> = CHANNEL_STATE - .prefix_de(&id) + .prefix(&id) .range_raw(deps.storage, None, None, Order::Ascending) .map(|r| { let (k, v) = r?; diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index f99882a1d..48a600834 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -386,7 +386,7 @@ fn list_votes( let start = start_after.map(Bound::exclusive); let votes: StdResult> = BALLOTS - .prefix_de(proposal_id) + .prefix(proposal_id) .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index b508331b4..c7293d99c 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -383,7 +383,7 @@ fn list_votes( let start = addr.map(|addr| Bound::exclusive(addr.as_ref())); let votes: StdResult> = BALLOTS - .prefix_de(proposal_id) + .prefix(proposal_id) .range_raw(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 19818d343..602a1dc59 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -115,11 +115,11 @@ where T: Serialize + DeserializeOwned, K: PrimaryKey<'a>, { - pub fn sub_prefix_de(&self, p: K::SubPrefix) -> Prefix { + pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { Prefix::new(self.namespace, &p.prefix()) } - pub fn prefix_de(&self, p: K::Prefix) -> Prefix { + pub fn prefix(&self, p: K::Prefix) -> Prefix { Prefix::new(self.namespace, &p.prefix()) } } @@ -187,13 +187,13 @@ where T: Serialize + DeserializeOwned, K: PrimaryKey<'a> + KeyDeserialize, { - /// While `range_de` over a `prefix_de` fixes the prefix to one element and iterates over the - /// remaining, `prefix_range_de` accepts bounds for the lowest and highest elements of the + /// While `range` over a `prefix` fixes the prefix to one element and iterates over the + /// remaining, `prefix_range` accepts bounds for the lowest and highest elements of the /// `Prefix` itself, and iterates over those (inclusively or exclusively, depending on /// `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. - pub fn prefix_range_de<'c>( + pub fn prefix_range<'c>( &self, store: &'c dyn Storage, min: Option>, @@ -211,7 +211,7 @@ where Box::new(mapped) } - pub fn range_de<'c>( + pub fn range<'c>( &self, store: &'c dyn Storage, min: Option, @@ -225,7 +225,7 @@ where self.no_prefix_de().range(store, min, max, order) } - pub fn keys_de<'c>( + pub fn keys<'c>( &self, store: &'c dyn Storage, min: Option, @@ -474,9 +474,7 @@ mod test { PEOPLE.save(&mut store, b"jim", &data2).unwrap(); // let's try to iterate! - let all: StdResult> = PEOPLE - .range_de(&store, None, None, Order::Ascending) - .collect(); + let all: StdResult> = PEOPLE.range(&store, None, None, Order::Ascending).collect(); let all = all.unwrap(); assert_eq!(2, all.len()); assert_eq!( @@ -489,7 +487,7 @@ mod test { // let's try to iterate over a range let all: StdResult> = PEOPLE - .range_de( + .range( &store, Some(Bound::Inclusive(b"j".to_vec())), None, @@ -505,7 +503,7 @@ mod test { // let's try to iterate over a more restrictive range let all: StdResult> = PEOPLE - .range_de( + .range( &store, Some(Bound::Inclusive(b"jo".to_vec())), None, @@ -537,7 +535,7 @@ mod test { // let's try to iterate! let all: StdResult> = PEOPLE_ID - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -545,7 +543,7 @@ mod test { // let's try to iterate over a range let all: StdResult> = PEOPLE_ID - .range_de( + .range( &store, Some(Bound::inclusive_int(56u32)), None, @@ -558,7 +556,7 @@ mod test { // let's try to iterate over a more restrictive range let all: StdResult> = PEOPLE_ID - .range_de( + .range( &store, Some(Bound::inclusive_int(57u32)), None, @@ -603,7 +601,7 @@ mod test { // let's try to iterate over a prefix let all: StdResult> = ALLOWANCE - .prefix_de(b"owner") + .prefix(b"owner") .range_raw(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); @@ -632,7 +630,7 @@ mod test { // let's try to iterate! let all: StdResult> = ALLOWANCE - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(3, all.len()); @@ -647,7 +645,7 @@ mod test { // let's try to iterate over a prefix_de let all: StdResult> = ALLOWANCE - .prefix_de(b"owner") + .prefix(b"owner") .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); @@ -707,7 +705,7 @@ mod test { // let's iterate over a prefix let all: StdResult> = TRIPLE - .prefix_de((b"owner", 9)) + .prefix((b"owner", 9)) .range_raw(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); @@ -722,7 +720,7 @@ mod test { // let's iterate over a sub prefix let all: StdResult> = TRIPLE - .sub_prefix_de(b"owner") + .sub_prefix(b"owner") .range_raw(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); @@ -758,9 +756,7 @@ mod test { .unwrap(); // let's try to iterate! - let all: StdResult> = TRIPLE - .range_de(&store, None, None, Order::Ascending) - .collect(); + let all: StdResult> = TRIPLE.range(&store, None, None, Order::Ascending).collect(); let all = all.unwrap(); assert_eq!(4, all.len()); assert_eq!( @@ -775,7 +771,7 @@ mod test { // let's iterate over a sub_prefix_de let all: StdResult> = TRIPLE - .sub_prefix_de(b"owner") + .sub_prefix(b"owner") .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); @@ -791,7 +787,7 @@ mod test { // let's iterate over a prefix_de let all: StdResult> = TRIPLE - .prefix_de((b"owner", 9)) + .prefix((b"owner", 9)) .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); @@ -977,7 +973,7 @@ mod test { // get all under one key let all: StdResult> = ALLOWANCE - .prefix_de(b"owner") + .prefix(b"owner") .range_raw(&store, None, None, Order::Ascending) .collect(); assert_eq!( @@ -987,7 +983,7 @@ mod test { // Or ranges between two items (even reverse) let all: StdResult> = ALLOWANCE - .prefix_de(b"owner") + .prefix(b"owner") .range_raw( &store, Some(Bound::Exclusive(b"spender1".to_vec())), @@ -1017,7 +1013,7 @@ mod test { // typical range under one prefix as a control let fives = AGES - .prefix_de(5) + .prefix(5) .range_raw(&store, None, None, Order::Ascending) .collect::>>() .unwrap(); @@ -1103,7 +1099,7 @@ mod test { // typical range under one prefix as a control let fives = AGES - .prefix_de(5) + .prefix(5) .range(&store, None, None, Order::Ascending) .collect::>>() .unwrap(); @@ -1113,15 +1109,12 @@ mod test { vec![("789".to_string(), 789), ("987".to_string(), 987)] ); - let keys: Vec<_> = AGES - .no_prefix_de() - .keys(&store, None, None, Order::Ascending) - .collect(); + let keys: Vec<_> = AGES.keys(&store, None, None, Order::Ascending).collect(); println!("keys: {:?}", keys); // using inclusive bounds both sides let include = AGES - .prefix_range_de( + .prefix_range( &store, Some(PrefixBound::inclusive(3u32)), Some(PrefixBound::inclusive(7u32)), @@ -1135,7 +1128,7 @@ mod test { // using exclusive bounds both sides let exclude = AGES - .prefix_range_de( + .prefix_range( &store, Some(PrefixBound::exclusive(3u32)), Some(PrefixBound::exclusive(7u32)), @@ -1149,7 +1142,7 @@ mod test { // using inclusive in descending let include = AGES - .prefix_range_de( + .prefix_range( &store, Some(PrefixBound::inclusive(3u32)), Some(PrefixBound::inclusive(5u32)), @@ -1163,7 +1156,7 @@ mod test { // using exclusive in descending let include = AGES - .prefix_range_de( + .prefix_range( &store, Some(PrefixBound::exclusive(2u32)), Some(PrefixBound::exclusive(5u32)), diff --git a/packages/storage-plus/src/snapshot/mod.rs b/packages/storage-plus/src/snapshot/mod.rs index cdf3abc71..c20fe2e8d 100644 --- a/packages/storage-plus/src/snapshot/mod.rs +++ b/packages/storage-plus/src/snapshot/mod.rs @@ -87,7 +87,7 @@ where let start = Bound::inclusive(height); let first = self .changelog - .prefix_de(k.clone()) + .prefix(k.clone()) .range_raw(store, Some(start), None, Order::Ascending) .next() .transpose()?; @@ -146,7 +146,7 @@ where let start = Bound::inclusive_int(height); let first = self .changelog - .prefix_de(key) + .prefix(key) .range_raw(store, Some(start), None, Order::Ascending) .next(); From fb36916c17be2728839e6c5e3092ed5543a36f04 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:23:53 +0100 Subject: [PATCH 024/352] Rename prefix_/prefix_range_/keys_/range_de to prefix/prefix_range/keys/range in SnapshotMap --- packages/storage-plus/src/snapshot/map.rs | 30 +++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index 8f50acaf6..a7a3b03c0 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -197,13 +197,13 @@ where T: Serialize + DeserializeOwned, K: PrimaryKey<'a> + KeyDeserialize, { - /// While `range_de` over a `prefix_de` fixes the prefix to one element and iterates over the - /// remaining, `prefix_range_de` accepts bounds for the lowest and highest elements of the + /// While `range` over a `prefix` fixes the prefix to one element and iterates over the + /// remaining, `prefix_range` accepts bounds for the lowest and highest elements of the /// `Prefix` itself, and iterates over those (inclusively or exclusively, depending on /// `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. - pub fn prefix_range_de<'c>( + pub fn prefix_range<'c>( &self, store: &'c dyn Storage, min: Option>, @@ -221,7 +221,7 @@ where Box::new(mapped) } - pub fn range_de<'c>( + pub fn range<'c>( &self, store: &'c dyn Storage, min: Option, @@ -235,7 +235,7 @@ where self.no_prefix_de().range(store, min, max, order) } - pub fn keys_de<'c>( + pub fn keys<'c>( &self, store: &'c dyn Storage, min: Option, @@ -249,11 +249,11 @@ where self.no_prefix_de().keys(store, min, max, order) } - pub fn prefix_de(&self, p: K::Prefix) -> Prefix { + pub fn prefix(&self, p: K::Prefix) -> Prefix { Prefix::new(self.primary.namespace(), &p.prefix()) } - pub fn sub_prefix_de(&self, p: K::SubPrefix) -> Prefix { + pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { Prefix::new(self.primary.namespace(), &p.prefix()) } @@ -467,16 +467,14 @@ mod tests { init_data(&EVERY, &mut store); // let's try to iterate! - let all: StdResult> = EVERY - .range_de(&store, None, None, Order::Ascending) - .collect(); + let all: StdResult> = EVERY.range(&store, None, None, Order::Ascending).collect(); let all = all.unwrap(); assert_eq!(2, all.len()); assert_eq!(all, vec![("C".into(), 13), ("D".into(), 22)]); // let's try to iterate over a range let all: StdResult> = EVERY - .range_de( + .range( &store, Some(Bound::Inclusive(b"C".to_vec())), None, @@ -489,7 +487,7 @@ mod tests { // let's try to iterate over a more restrictive range let all: StdResult> = EVERY - .range_de( + .range( &store, Some(Bound::Inclusive(b"D".to_vec())), None, @@ -511,7 +509,7 @@ mod tests { // let's try to iterate! let all: StdResult> = EVERY_COMPOSITE_KEY - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -534,7 +532,7 @@ mod tests { // let's prefix-range and iterate let all: StdResult> = EVERY_COMPOSITE_KEY - .prefix_range_de( + .prefix_range( &store, None, Some(PrefixBound::exclusive("C")), @@ -556,7 +554,7 @@ mod tests { // let's prefix and iterate let all: StdResult> = EVERY_COMPOSITE_KEY - .prefix_de("C") + .prefix("C") .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); @@ -576,7 +574,7 @@ mod tests { // This is similar to calling range() directly, but added here for completeness / // sub_prefix_de type checks let all: StdResult> = EVERY_COMPOSITE_KEY - .sub_prefix_de(()) + .sub_prefix(()) .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); From 32c0aae45ff7eafbf90eacbfaf4a176f91471e9a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:34:09 +0100 Subject: [PATCH 025/352] Rename prefix_/prefix_range_/keys_/range_de to prefix/prefix_range/keys/range in IndexedMap --- packages/storage-plus/src/indexed_map.rs | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 89d0388c0..b3b9f0b39 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -204,11 +204,11 @@ where K: PrimaryKey<'a>, I: IndexList, { - pub fn sub_prefix_de(&self, p: K::SubPrefix) -> Prefix { + pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { Prefix::new(self.pk_namespace, &p.prefix()) } - pub fn prefix_de(&self, p: K::Prefix) -> Prefix { + pub fn prefix(&self, p: K::Prefix) -> Prefix { Prefix::new(self.pk_namespace, &p.prefix()) } } @@ -220,13 +220,13 @@ where K: PrimaryKey<'a> + KeyDeserialize, I: IndexList, { - /// While `range_de` over a `prefix_de` fixes the prefix to one element and iterates over the - /// remaining, `prefix_range_de` accepts bounds for the lowest and highest elements of the + /// While `range` over a `prefix` fixes the prefix to one element and iterates over the + /// remaining, `prefix_range` accepts bounds for the lowest and highest elements of the /// `Prefix` itself, and iterates over those (inclusively or exclusively, depending on /// `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. - pub fn prefix_range_de<'c>( + pub fn prefix_range<'c>( &self, store: &'c dyn Storage, min: Option>, @@ -244,7 +244,7 @@ where Box::new(mapped) } - pub fn range_de<'c>( + pub fn range<'c>( &self, store: &'c dyn Storage, min: Option, @@ -258,7 +258,7 @@ where self.no_prefix_de().range(store, min, max, order) } - pub fn keys_de<'c>( + pub fn keys<'c>( &self, store: &'c dyn Storage, min: Option, @@ -994,7 +994,7 @@ mod test { let (pks, datas) = save_data(&mut store, &map); // let's try to iterate! - let all: StdResult> = map.range_de(&store, None, None, Order::Ascending).collect(); + let all: StdResult> = map.range(&store, None, None, Order::Ascending).collect(); let all = all.unwrap(); assert_eq!( all, @@ -1007,7 +1007,7 @@ mod test { // let's try to iterate over a range let all: StdResult> = map - .range_de( + .range( &store, Some(Bound::Inclusive(b"3".to_vec())), None, @@ -1040,7 +1040,7 @@ mod test { // This is similar to calling range() directly, but added here for completeness / prefix_de // type checks let all: StdResult> = map - .prefix_de(()) + .prefix(()) .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); @@ -1099,7 +1099,7 @@ mod test { // let's prefix and iterate let result: StdResult> = map - .prefix_de("2") + .prefix("2") .range(&store, None, None, Order::Ascending) .collect(); let result = result.unwrap(); @@ -1154,7 +1154,7 @@ mod test { // let's prefix and iterate let result: StdResult> = map - .prefix_de(("1", "2")) + .prefix(("1", "2")) .range(&store, None, None, Order::Ascending) .collect(); let result = result.unwrap(); @@ -1206,7 +1206,7 @@ mod test { // let's sub-prefix and iterate let result: StdResult> = map - .sub_prefix_de("1") + .sub_prefix("1") .range(&store, None, None, Order::Ascending) .collect(); let result = result.unwrap(); @@ -1264,7 +1264,7 @@ mod test { // let's try to iterate! let result: StdResult> = map - .prefix_range_de( + .prefix_range( &store, Some(PrefixBound::inclusive("2")), None, @@ -1283,7 +1283,7 @@ mod test { // let's try to iterate over a range let result: StdResult> = map - .prefix_range_de( + .prefix_range( &store, Some(PrefixBound::inclusive("2")), Some(PrefixBound::exclusive("3")), @@ -1345,7 +1345,7 @@ mod test { // let's prefix-range and iterate let result: StdResult> = map - .prefix_range_de( + .prefix_range( &store, Some(PrefixBound::inclusive(("1", "2"))), None, @@ -1373,7 +1373,7 @@ mod test { // let's prefix-range over inclusive bounds on both sides let result: StdResult> = map - .prefix_range_de( + .prefix_range( &store, Some(PrefixBound::inclusive(("1", "2"))), Some(PrefixBound::inclusive(("2", "1"))), From 4db106febf3f1e053755c25343d77160dc9915dd Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:40:27 +0100 Subject: [PATCH 026/352] Rename prefix_/prefix_range_/keys_/range_de to prefix/prefix_range/keys/range in IndexedSnapshotMap --- packages/storage-plus/src/indexed_snapshot.rs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 415cac5cd..d9aae62ca 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -220,11 +220,11 @@ where K: PrimaryKey<'a>, I: IndexList, { - pub fn sub_prefix_de(&self, p: K::SubPrefix) -> Prefix { + pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { Prefix::new(self.pk_namespace, &p.prefix()) } - pub fn prefix_de(&self, p: K::Prefix) -> Prefix { + pub fn prefix(&self, p: K::Prefix) -> Prefix { Prefix::new(self.pk_namespace, &p.prefix()) } } @@ -236,13 +236,13 @@ where K: PrimaryKey<'a> + KeyDeserialize, I: IndexList, { - /// While `range_de` over a `prefix_de` fixes the prefix to one element and iterates over the - /// remaining, `prefix_range_de` accepts bounds for the lowest and highest elements of the + /// While `range` over a `prefix` fixes the prefix to one element and iterates over the + /// remaining, `prefix_range` accepts bounds for the lowest and highest elements of the /// `Prefix` itself, and iterates over those (inclusively or exclusively, depending on /// `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. - pub fn prefix_range_de<'c>( + pub fn prefix_range<'c>( &self, store: &'c dyn Storage, min: Option>, @@ -260,7 +260,7 @@ where Box::new(mapped) } - pub fn range_de<'c>( + pub fn range<'c>( &self, store: &'c dyn Storage, min: Option, @@ -274,7 +274,7 @@ where self.no_prefix_de().range(store, min, max, order) } - pub fn keys_de<'c>( + pub fn keys<'c>( &self, store: &'c dyn Storage, min: Option, @@ -982,7 +982,7 @@ mod test { let (pks, datas) = save_data(&mut store, &map); // let's try to iterate! - let all: StdResult> = map.range_de(&store, None, None, Order::Ascending).collect(); + let all: StdResult> = map.range(&store, None, None, Order::Ascending).collect(); let all = all.unwrap(); assert_eq!( all, @@ -995,7 +995,7 @@ mod test { // let's try to iterate over a range let all: StdResult> = map - .range_de( + .range( &store, Some(Bound::Inclusive(b"3".to_vec())), None, @@ -1028,7 +1028,7 @@ mod test { // This is similar to calling range() directly, but added here for completeness / prefix_de // type checks let all: StdResult> = map - .prefix_de(()) + .prefix(()) .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); @@ -1055,7 +1055,7 @@ mod test { // This is similar to calling range() directly, but added here for completeness / sub_prefix_de // type checks let all: StdResult> = map - .sub_prefix_de(()) + .sub_prefix(()) .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); @@ -1115,7 +1115,7 @@ mod test { // let's try to iterate! let result: StdResult> = map - .prefix_range_de( + .prefix_range( &store, Some(PrefixBound::inclusive("2")), None, @@ -1134,7 +1134,7 @@ mod test { // let's try to iterate over a range let result: StdResult> = map - .prefix_range_de( + .prefix_range( &store, Some(PrefixBound::inclusive("2")), Some(PrefixBound::exclusive("3")), From d835665429b206f7fcb2df26f5fa4405a96d6298 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:43:17 +0100 Subject: [PATCH 027/352] Rename prefix_/prefix_range_/keys_/range_de to prefix/prefix_range/keys/range in UniqueIndex --- packages/storage-plus/src/indexed_map.rs | 6 +++--- packages/storage-plus/src/indexed_snapshot.rs | 6 +++--- packages/storage-plus/src/indexes/unique.rs | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index b3b9f0b39..49f6afb2d 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -904,7 +904,7 @@ mod test { let res: StdResult> = map .idx .age - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let ages = res.unwrap(); @@ -937,7 +937,7 @@ mod test { let res: StdResult> = map .idx .name_lastname - .prefix_de(b"Maria".to_vec()) + .prefix(b"Maria".to_vec()) .range_raw(&store, None, None, Order::Ascending) .collect(); let marias = res.unwrap(); @@ -966,7 +966,7 @@ mod test { let res: StdResult> = map .idx .name_lastname - .prefix_de(b"Maria".to_vec()) + .prefix(b"Maria".to_vec()) .range(&store, None, None, Order::Ascending) .collect(); let marias = res.unwrap(); diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index d9aae62ca..4ac7e0d00 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -894,7 +894,7 @@ mod test { let res: StdResult> = map .idx .age - .range_de(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let ages = res.unwrap(); @@ -925,7 +925,7 @@ mod test { let res: StdResult> = map .idx .name_lastname - .prefix_de(b"Maria".to_vec()) + .prefix(b"Maria".to_vec()) .range_raw(&store, None, None, Order::Ascending) .collect(); let marias = res.unwrap(); @@ -954,7 +954,7 @@ mod test { let res: StdResult> = map .idx .name_lastname - .prefix_de(b"Maria".to_vec()) + .prefix(b"Maria".to_vec()) .range(&store, None, None, Order::Ascending) .collect(); let marias = res.unwrap(); diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index 38adff44a..7796f9d1f 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -171,13 +171,13 @@ where T: Serialize + DeserializeOwned + Clone, IK: PrimaryKey<'a>, { - /// While `range_de` over a `prefix_de` fixes the prefix to one element and iterates over the - /// remaining, `prefix_range_de` accepts bounds for the lowest and highest elements of the + /// While `range` over a `prefix` fixes the prefix to one element and iterates over the + /// remaining, `prefix_range` accepts bounds for the lowest and highest elements of the /// `Prefix` itself, and iterates over those (inclusively or exclusively, depending on /// `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. - pub fn prefix_range_de<'c>( + pub fn prefix_range<'c>( &self, store: &'c dyn Storage, min: Option>, @@ -196,7 +196,7 @@ where Box::new(mapped) } - pub fn range_de<'c>( + pub fn range<'c>( &self, store: &'c dyn Storage, min: Option, @@ -210,7 +210,7 @@ where self.no_prefix_de().range(store, min, max, order) } - pub fn keys_de<'c>( + pub fn keys<'c>( &self, store: &'c dyn Storage, min: Option, @@ -224,7 +224,7 @@ where self.no_prefix_de().keys(store, min, max, order) } - pub fn prefix_de(&self, p: IK::Prefix) -> Prefix { + pub fn prefix(&self, p: IK::Prefix) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), @@ -234,7 +234,7 @@ where ) } - pub fn sub_prefix_de(&self, p: IK::SubPrefix) -> Prefix { + pub fn sub_prefix(&self, p: IK::SubPrefix) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), From 72a2f4a492558a47226634f8523d14cc5ac22381 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:45:33 +0100 Subject: [PATCH 028/352] Rename prefix_/prefix_range_/keys_/range_de to prefix/prefix_range/keys/range in MultiIndex --- packages/storage-plus/src/indexed_map.rs | 20 +++++++++---------- packages/storage-plus/src/indexed_snapshot.rs | 20 +++++++++---------- packages/storage-plus/src/indexes/multi.rs | 20 +++++++++---------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 49f6afb2d..afa08da9f 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -414,7 +414,7 @@ mod test { let count = map .idx .name - .prefix_de("Maria".to_string()) + .prefix("Maria".to_string()) .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(2, count); @@ -423,7 +423,7 @@ mod test { let marias: Vec<_> = map .idx .name - .prefix_de("Maria".to_string()) + .prefix("Maria".to_string()) .range_raw(&store, None, None, Order::Ascending) .collect::>() .unwrap(); @@ -436,7 +436,7 @@ mod test { let count = map .idx .name - .prefix_de("Marib".to_string()) + .prefix("Marib".to_string()) .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -445,7 +445,7 @@ mod test { let count = map .idx .name - .prefix_de("Mari`".to_string()) + .prefix("Mari`".to_string()) .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -454,7 +454,7 @@ mod test { let count = map .idx .name - .prefix_de("Maria5".to_string()) + .prefix("Maria5".to_string()) .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -560,7 +560,7 @@ mod test { let marias: Vec<_> = map .idx .name - .prefix_de("Maria".to_string()) + .prefix("Maria".to_string()) .range_raw(&store, None, None, Order::Descending) .collect::>() .unwrap(); @@ -616,7 +616,7 @@ mod test { let marias: Vec<_> = map .idx .name - .prefix_de("Maria".to_string()) + .prefix("Maria".to_string()) .range(&store, None, None, Order::Descending) .collect::>() .unwrap(); @@ -676,7 +676,7 @@ mod test { let marias: Vec<_> = map .idx .name_age - .sub_prefix_de(b"Maria".to_vec()) + .sub_prefix(b"Maria".to_vec()) .range_raw(&store, None, None, Order::Descending) .collect::>() .unwrap(); @@ -737,7 +737,7 @@ mod test { let marias: Vec<_> = map .idx .name_age - .sub_prefix_de(b"Maria".to_vec()) + .sub_prefix(b"Maria".to_vec()) .range(&store, None, None, Order::Descending) .collect::>() .unwrap(); @@ -827,7 +827,7 @@ mod test { -> usize { map.idx .name - .prefix_de(name.to_string()) + .prefix(name.to_string()) .keys_raw(store, None, None, Order::Ascending) .count() }; diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 4ac7e0d00..955874880 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -430,7 +430,7 @@ mod test { let count = map .idx .name - .prefix_de(b"Maria".to_vec()) + .prefix(b"Maria".to_vec()) .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(2, count); @@ -439,7 +439,7 @@ mod test { let marias: Vec<_> = map .idx .name - .prefix_de(b"Maria".to_vec()) + .prefix(b"Maria".to_vec()) .range_raw(&store, None, None, Order::Ascending) .collect::>() .unwrap(); @@ -452,7 +452,7 @@ mod test { let count = map .idx .name - .prefix_de(b"Marib".to_vec()) + .prefix(b"Marib".to_vec()) .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -461,7 +461,7 @@ mod test { let count = map .idx .name - .prefix_de(b"Mari`".to_vec()) + .prefix(b"Mari`".to_vec()) .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -470,7 +470,7 @@ mod test { let count = map .idx .name - .prefix_de(b"Maria5".to_vec()) + .prefix(b"Maria5".to_vec()) .range_raw(&store, None, None, Order::Ascending) .count(); assert_eq!(0, count); @@ -532,7 +532,7 @@ mod test { let marias: Vec<_> = map .idx .name - .prefix_de(b"Maria".to_vec()) + .prefix(b"Maria".to_vec()) .range_raw(&store, None, None, Order::Descending) .collect::>() .unwrap(); @@ -592,7 +592,7 @@ mod test { let marias: Vec<_> = map .idx .name - .prefix_de(b"Maria".to_vec()) + .prefix(b"Maria".to_vec()) .range(&store, None, None, Order::Descending) .collect::>() .unwrap(); @@ -657,7 +657,7 @@ mod test { let marias: Vec<_> = map .idx .name_age - .sub_prefix_de(b"Maria".to_vec()) + .sub_prefix(b"Maria".to_vec()) .range_raw(&store, None, None, Order::Descending) .collect::>() .unwrap(); @@ -723,7 +723,7 @@ mod test { let marias: Vec<_> = map .idx .name_age - .sub_prefix_de(b"Maria".to_vec()) + .sub_prefix(b"Maria".to_vec()) .range(&store, None, None, Order::Descending) .collect::>() .unwrap(); @@ -818,7 +818,7 @@ mod test { -> usize { map.idx .name - .prefix_de(name.as_bytes().to_vec()) + .prefix(name.as_bytes().to_vec()) .keys_raw(store, None, None, Order::Ascending) .count() }; diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 99f46eaae..b9915e2b0 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -166,13 +166,13 @@ where #[cfg(test)] pub fn count(&self, store: &dyn Storage, p: IK) -> usize { - let prefix = self.prefix_de(p); + let prefix = self.prefix(p); prefix.keys_raw(store, None, None, Order::Ascending).count() } #[cfg(test)] pub fn all_pks(&self, store: &dyn Storage, p: IK) -> Vec> { - let prefix = self.prefix_de(p); + let prefix = self.prefix(p); prefix .keys_raw(store, None, None, Order::Ascending) .collect::>>() @@ -180,7 +180,7 @@ where #[cfg(test)] pub fn all_items(&self, store: &dyn Storage, p: IK) -> StdResult>> { - let prefix = self.prefix_de(p); + let prefix = self.prefix(p); prefix .range_raw(store, None, None, Order::Ascending) .collect() @@ -248,7 +248,7 @@ where T: Serialize + DeserializeOwned + Clone, IK: PrimaryKey<'a> + Prefixer<'a>, { - pub fn prefix_de(&self, p: IK) -> Prefix { + pub fn prefix(&self, p: IK) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), @@ -258,7 +258,7 @@ where ) } - pub fn sub_prefix_de(&self, p: IK::Prefix) -> Prefix { + pub fn sub_prefix(&self, p: IK::Prefix) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), @@ -276,13 +276,13 @@ where T: Serialize + DeserializeOwned + Clone, IK: PrimaryKey<'a> + KeyDeserialize + Prefixer<'a>, { - /// While `range_de` over a `prefix_de` fixes the prefix to one element and iterates over the - /// remaining, `prefix_range_de` accepts bounds for the lowest and highest elements of the + /// While `range` over a `prefix` fixes the prefix to one element and iterates over the + /// remaining, `prefix_range` accepts bounds for the lowest and highest elements of the /// `Prefix` itself, and iterates over those (inclusively or exclusively, depending on /// `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. - pub fn prefix_range_de<'c>( + pub fn prefix_range<'c>( &self, store: &'c dyn Storage, min: Option>, @@ -301,7 +301,7 @@ where Box::new(mapped) } - pub fn range_de<'c>( + pub fn range<'c>( &self, store: &'c dyn Storage, min: Option, @@ -315,7 +315,7 @@ where self.no_prefix_de().range(store, min, max, order) } - pub fn keys_de<'c>( + pub fn keys<'c>( &self, store: &'c dyn Storage, min: Option, From b2f46bc7d641b27c104aa71e63e131f1db9836dd Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:52:25 +0100 Subject: [PATCH 029/352] Rename no_prefix to no_prefix_raw, no_prefix_de to no_prefix in Map for consistency --- packages/storage-plus/src/map.rs | 12 ++++++------ packages/storage-plus/src/snapshot/map.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 602a1dc59..c7f7fc02c 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -50,7 +50,7 @@ where } #[cfg(feature = "iterator")] - pub(crate) fn no_prefix(&self) -> Prefix, T> { + pub(crate) fn no_prefix_raw(&self) -> Prefix, T> { Prefix::new(self.namespace, &[]) } @@ -164,7 +164,7 @@ where where T: 'c, { - self.no_prefix().range_raw(store, min, max, order) + self.no_prefix_raw().range_raw(store, min, max, order) } pub fn keys_raw<'c>( @@ -177,7 +177,7 @@ where where T: 'c, { - self.no_prefix().keys_raw(store, min, max, order) + self.no_prefix_raw().keys_raw(store, min, max, order) } } @@ -222,7 +222,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().range(store, min, max, order) + self.no_prefix().range(store, min, max, order) } pub fn keys<'c>( @@ -236,10 +236,10 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().keys(store, min, max, order) + self.no_prefix().keys(store, min, max, order) } - fn no_prefix_de(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::new(self.namespace, &[]) } } diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index a7a3b03c0..5d190be49 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -70,7 +70,7 @@ where } fn no_prefix(&self) -> Prefix, T> { - self.primary.no_prefix() + self.primary.no_prefix_raw() } /// load old value and store changelog From 7d7f42506b7707349dad11b9f194fb3ae6faa22a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:54:44 +0100 Subject: [PATCH 030/352] Rename no_prefix to no_prefix_raw, no_prefix_de to no_prefix in IndexedMap for consistency --- packages/storage-plus/src/indexed_map.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index afa08da9f..b67dadb9a 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -130,7 +130,7 @@ where } // use no_prefix to scan -> range - fn no_prefix(&self) -> Prefix, T> { + fn no_prefix_raw(&self) -> Prefix, T> { Prefix::new(self.pk_namespace, &[]) } } @@ -154,7 +154,7 @@ where where T: 'c, { - self.no_prefix().range_raw(store, min, max, order) + self.no_prefix_raw().range_raw(store, min, max, order) } pub fn keys_raw<'c>( @@ -164,7 +164,7 @@ where max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> { - self.no_prefix().keys_raw(store, min, max, order) + self.no_prefix_raw().keys_raw(store, min, max, order) } } @@ -255,7 +255,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().range(store, min, max, order) + self.no_prefix().range(store, min, max, order) } pub fn keys<'c>( @@ -269,10 +269,10 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().keys(store, min, max, order) + self.no_prefix().keys(store, min, max, order) } - fn no_prefix_de(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::new(self.pk_namespace, &[]) } } From 1f1a87a6a1f9592ab455362c1291795ae19eab3a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:56:13 +0100 Subject: [PATCH 031/352] Rename no_prefix to no_prefix_raw, no_prefix_de to no_prefix in SnapshotMap for consistency --- packages/storage-plus/src/snapshot/map.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index 5d190be49..030e08937 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -69,7 +69,7 @@ where self.primary.key(k) } - fn no_prefix(&self) -> Prefix, T> { + fn no_prefix_raw(&self) -> Prefix, T> { self.primary.no_prefix_raw() } @@ -174,7 +174,7 @@ where where T: 'c, { - self.no_prefix().range_raw(store, min, max, order) + self.no_prefix_raw().range_raw(store, min, max, order) } pub fn keys_raw<'c>( @@ -187,7 +187,7 @@ where where T: 'c, { - self.no_prefix().keys_raw(store, min, max, order) + self.no_prefix_raw().keys_raw(store, min, max, order) } } @@ -232,7 +232,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().range(store, min, max, order) + self.no_prefix().range(store, min, max, order) } pub fn keys<'c>( @@ -246,7 +246,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().keys(store, min, max, order) + self.no_prefix().keys(store, min, max, order) } pub fn prefix(&self, p: K::Prefix) -> Prefix { @@ -257,7 +257,7 @@ where Prefix::new(self.primary.namespace(), &p.prefix()) } - fn no_prefix_de(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::new(self.primary.namespace(), &[]) } } From 42d5db965f6792d16306d174203d268687fac0cc Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:57:57 +0100 Subject: [PATCH 032/352] Rename no_prefix to no_prefix_raw, no_prefix_de to no_prefix in IndexedSnapshotMap for consistency --- packages/storage-plus/src/indexed_snapshot.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 955874880..2b7914186 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -175,7 +175,7 @@ where } // use no_prefix to scan -> range - pub fn no_prefix(&self) -> Prefix, T> { + pub fn no_prefix_raw(&self) -> Prefix, T> { Prefix::new(self.pk_namespace, &[]) } } @@ -199,7 +199,7 @@ where where T: 'c, { - self.no_prefix().range_raw(store, min, max, order) + self.no_prefix_raw().range_raw(store, min, max, order) } pub fn keys_raw<'c>( @@ -209,7 +209,7 @@ where max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> { - self.no_prefix().keys_raw(store, min, max, order) + self.no_prefix_raw().keys_raw(store, min, max, order) } } @@ -271,7 +271,7 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().range(store, min, max, order) + self.no_prefix().range(store, min, max, order) } pub fn keys<'c>( @@ -285,10 +285,10 @@ where T: 'c, K::Output: 'static, { - self.no_prefix_de().keys(store, min, max, order) + self.no_prefix().keys(store, min, max, order) } - fn no_prefix_de(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::new(self.pk_namespace, &[]) } } From b37f1eb191b08257b55699481d17670bf044f082 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 18:59:49 +0100 Subject: [PATCH 033/352] Rename no_prefix to no_prefix_raw, no_prefix_de to no_prefix in UniqueIndex for consistency --- packages/storage-plus/src/indexes/unique.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index 7796f9d1f..06c266fa1 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -112,7 +112,7 @@ where k.joined_key() } - fn no_prefix(&self) -> Prefix, T> { + fn no_prefix_raw(&self) -> Prefix, T> { Prefix::with_deserialization_functions( self.idx_namespace, &[], @@ -150,7 +150,7 @@ where where T: 'c, { - self.no_prefix().range_raw(store, min, max, order) + self.no_prefix_raw().range_raw(store, min, max, order) } pub fn keys_raw<'c>( @@ -160,7 +160,7 @@ where max: Option, order: Order, ) -> Box> + 'c> { - self.no_prefix().keys_raw(store, min, max, order) + self.no_prefix_raw().keys_raw(store, min, max, order) } } @@ -207,7 +207,7 @@ where T: 'c, PK::Output: 'static, { - self.no_prefix_de().range(store, min, max, order) + self.no_prefix().range(store, min, max, order) } pub fn keys<'c>( @@ -221,7 +221,7 @@ where T: 'c, PK::Output: 'static, { - self.no_prefix_de().keys(store, min, max, order) + self.no_prefix().keys(store, min, max, order) } pub fn prefix(&self, p: IK::Prefix) -> Prefix { @@ -244,7 +244,7 @@ where ) } - fn no_prefix_de(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &[], From e7aabeac0ee8635cf7f94edeabad149f0331b380 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 19:00:50 +0100 Subject: [PATCH 034/352] Rename no_prefix to no_prefix_raw, no_prefix_de to no_prefix in MultiIndex for consistency --- packages/storage-plus/src/indexes/multi.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index b9915e2b0..499e7bb44 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -143,7 +143,7 @@ where T: Serialize + DeserializeOwned + Clone, IK: PrimaryKey<'a> + Prefixer<'a>, { - fn no_prefix(&self) -> Prefix, T> { + fn no_prefix_raw(&self) -> Prefix, T> { Prefix::with_deserialization_functions( self.idx_namespace, &[], @@ -205,7 +205,7 @@ where where T: 'c, { - self.no_prefix().range_raw(store, min, max, order) + self.no_prefix_raw().range_raw(store, min, max, order) } pub fn keys_raw<'c>( @@ -215,7 +215,7 @@ where max: Option, order: Order, ) -> Box> + 'c> { - self.no_prefix().keys_raw(store, min, max, order) + self.no_prefix_raw().keys_raw(store, min, max, order) } /// While `range` over a `prefix` fixes the prefix to one element and iterates over the @@ -312,7 +312,7 @@ where T: 'c, PK::Output: 'static, { - self.no_prefix_de().range(store, min, max, order) + self.no_prefix().range(store, min, max, order) } pub fn keys<'c>( @@ -326,10 +326,10 @@ where T: 'c, PK::Output: 'static, { - self.no_prefix_de().keys(store, min, max, order) + self.no_prefix().keys(store, min, max, order) } - fn no_prefix_de(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &[], From ed513e629cd6cdbf610e1cd8e0184df1b48da32c Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 20:30:14 +0100 Subject: [PATCH 035/352] Replace range_raw() plus manual deserialization by keys() --- packages/utils/src/pagination.rs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/packages/utils/src/pagination.rs b/packages/utils/src/pagination.rs index b346fb776..7af917acd 100644 --- a/packages/utils/src/pagination.rs +++ b/packages/utils/src/pagination.rs @@ -36,7 +36,7 @@ pub fn calc_range_start_string(start_after: Option) -> Option> { #[cfg(test)] mod test { use super::*; - use cosmwasm_std::{testing::mock_dependencies, Order, StdError}; + use cosmwasm_std::{testing::mock_dependencies, Order}; use cw_storage_plus::{Bound, Map}; pub const HOLDERS: Map<&Addr, usize> = Map::new("some_data"); @@ -46,12 +46,6 @@ mod test { Addr::unchecked(format!("addr{:0>8}", i)) } - fn deser_holder_kv(holder_kv: Result<(Vec, usize), StdError>) -> (String, usize) { - let (k_bytes, v) = holder_kv.unwrap(); - let key = std::str::from_utf8(&k_bytes).unwrap().to_string(); - (key, v) - } - #[test] fn calc_range_start_works_as_expected() { let total_elements_count = 100; @@ -72,15 +66,15 @@ mod test { let start = calc_range_start(start_after).map(Bound::exclusive); - let holders: Vec<(String, usize)> = HOLDERS - .range_raw(&deps.storage, start, None, Order::Ascending) - .map(deser_holder_kv) + let holders = HOLDERS + .keys(&deps.storage, start, None, Order::Ascending) .take(LIMIT) - .collect(); + .collect::>>() + .unwrap(); for (i, holder) in holders.into_iter().enumerate() { let global_index = j * LIMIT + i; - assert_eq!(holder.0, addr_from_i(global_index)); + assert_eq!(holder, addr_from_i(global_index)); } } } @@ -101,15 +95,15 @@ mod test { let end = calc_range_end(end_before).map(Bound::exclusive); - let holders: Vec<(String, usize)> = HOLDERS - .range_raw(&deps.storage, None, end, Order::Descending) - .map(deser_holder_kv) + let holders = HOLDERS + .keys(&deps.storage, None, end, Order::Descending) .take(LIMIT) - .collect(); + .collect::>>() + .unwrap(); for (i, holder) in holders.into_iter().enumerate() { let global_index = total_elements_count - i - j * LIMIT - 1; - assert_eq!(holder.0, addr_from_i(global_index)); + assert_eq!(holder, addr_from_i(global_index)); } } } From 8f00fb31f749775ab6a677b30c76ea2285acd18e Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 20:53:24 +0100 Subject: [PATCH 036/352] Replace range_raw() plus manual deserialization by range() --- contracts/cw1155-base/src/contract.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contracts/cw1155-base/src/contract.rs b/contracts/cw1155-base/src/contract.rs index 74291b0f1..b83ca5d41 100644 --- a/contracts/cw1155-base/src/contract.rs +++ b/contracts/cw1155-base/src/contract.rs @@ -1,7 +1,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Order, Record, Response, StdResult, - SubMsg, Uint128, + to_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Order, Response, StdResult, SubMsg, + Uint128, }; use cw_storage_plus::Bound; @@ -478,10 +478,10 @@ pub fn query(deps: Deps, env: Env, msg: Cw1155QueryMsg) -> StdResult { } } -fn parse_approval(item: StdResult>) -> StdResult { - item.and_then(|(k, expires)| { - let spender = String::from_utf8(k)?; - Ok(cw1155::Approval { spender, expires }) +fn build_approval(item: StdResult<(Addr, Expiration)>) -> StdResult { + item.map(|(addr, expires)| cw1155::Approval { + spender: addr.into(), + expires, }) } @@ -498,10 +498,10 @@ fn query_all_approvals( let operators = APPROVES .prefix(&owner) - .range_raw(deps.storage, start, None, Order::Ascending) + .range(deps.storage, start, None, Order::Ascending) .filter(|r| include_expired || r.is_err() || !r.as_ref().unwrap().1.is_expired(&env.block)) .take(limit) - .map(parse_approval) + .map(build_approval) .collect::>()?; Ok(ApprovedForAllResponse { operators }) } From 64f3a33f020170cede0ded3ddebbd34a3da7e2b1 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 20:53:58 +0100 Subject: [PATCH 037/352] Replace range_raw() plus manual deserialization by keys() --- contracts/cw1155-base/src/contract.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/contracts/cw1155-base/src/contract.rs b/contracts/cw1155-base/src/contract.rs index b83ca5d41..e3195cff3 100644 --- a/contracts/cw1155-base/src/contract.rs +++ b/contracts/cw1155-base/src/contract.rs @@ -517,9 +517,8 @@ fn query_tokens( let tokens = BALANCES .prefix(&owner) - .range_raw(deps.storage, start, None, Order::Ascending) + .keys(deps.storage, start, None, Order::Ascending) .take(limit) - .map(|item| item.map(|(k, _)| String::from_utf8(k).unwrap())) .collect::>()?; Ok(TokensResponse { tokens }) } @@ -532,9 +531,8 @@ fn query_all_tokens( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive); let tokens = TOKENS - .range_raw(deps.storage, start, None, Order::Ascending) + .keys(deps.storage, start, None, Order::Ascending) .take(limit) - .map(|item| item.map(|(k, _)| String::from_utf8(k).unwrap())) .collect::>()?; Ok(TokensResponse { tokens }) } From 3b4ba152bce41ba47ff4554d73fcded40a7f17ac Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 21:22:49 +0100 Subject: [PATCH 038/352] Replace range_raw() + deserialization by range() --- contracts/cw1-subkeys/src/contract.rs | 34 ++++++++++++--------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/contract.rs index 84304be68..fca7ee1a4 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs @@ -409,8 +409,8 @@ pub fn query_all_allowances( // we use raw addresses here.... let start = start_after.map(Bound::exclusive); - let res: StdResult> = ALLOWANCES - .range_raw(deps.storage, start, None, Order::Ascending) + let allowances = ALLOWANCES + .range(deps.storage, start, None, Order::Ascending) .filter(|item| { if let Ok((_, allow)) = item { !allow.expires.is_expired(&env.block) @@ -420,16 +420,14 @@ pub fn query_all_allowances( }) .take(limit) .map(|item| { - item.and_then(|(k, allow)| { - Ok(AllowanceInfo { - spender: String::from_utf8(k)?, - balance: allow.balance, - expires: allow.expires, - }) + item.map(|(addr, allow)| AllowanceInfo { + spender: addr.into(), + balance: allow.balance, + expires: allow.expires, }) }) - .collect(); - Ok(AllAllowancesResponse { allowances: res? }) + .collect::>>()?; + Ok(AllAllowancesResponse { allowances }) } // return a list of all permissions here @@ -441,19 +439,17 @@ pub fn query_all_permissions( let limit = calc_limit(limit); let start = start_after.map(Bound::exclusive); - let res: StdResult> = PERMISSIONS - .range_raw(deps.storage, start, None, Order::Ascending) + let permissions = PERMISSIONS + .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { - item.and_then(|(k, perm)| { - Ok(PermissionsInfo { - spender: String::from_utf8(k)?, - permissions: perm, - }) + item.map(|(addr, perm)| PermissionsInfo { + spender: addr.into(), + permissions: perm, }) }) - .collect(); - Ok(AllPermissionsResponse { permissions: res? }) + .collect::>>()?; + Ok(AllPermissionsResponse { permissions }) } // Migrate contract if version is lower than current version From d0d7c598fe460decd1aa1fd3d7c1f7299c80e0fc Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 21:33:41 +0100 Subject: [PATCH 039/352] Replace keys_raw() + deserialization by keys() --- contracts/cw20-atomic-swap/src/state.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contracts/cw20-atomic-swap/src/state.rs b/contracts/cw20-atomic-swap/src/state.rs index 7df449e9d..0a1202630 100644 --- a/contracts/cw20-atomic-swap/src/state.rs +++ b/contracts/cw20-atomic-swap/src/state.rs @@ -1,7 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{Addr, Binary, BlockInfo, Order, StdError, StdResult, Storage}; +use cosmwasm_std::{Addr, Binary, BlockInfo, Order, StdResult, Storage}; use cw_storage_plus::{Bound, Map}; use cw20::{Balance, Expiration}; @@ -32,9 +32,8 @@ pub fn all_swap_ids( limit: usize, ) -> StdResult> { SWAPS - .keys_raw(storage, start, None, Order::Ascending) + .keys(storage, start, None, Order::Ascending) .take(limit) - .map(|k| String::from_utf8(k).map_err(|_| StdError::invalid_utf8("Parsing swap id"))) .collect() } From 3c78f51601c1e89559f3de239a4cc10026ff7644 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 21:46:18 +0100 Subject: [PATCH 040/352] Replace range_raw() + deserialization by range() --- contracts/cw20-base/src/enumerable.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/contracts/cw20-base/src/enumerable.rs b/contracts/cw20-base/src/enumerable.rs index 7b6c526c8..d93903536 100644 --- a/contracts/cw20-base/src/enumerable.rs +++ b/contracts/cw20-base/src/enumerable.rs @@ -18,22 +18,19 @@ pub fn query_all_allowances( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive); - let allowances: StdResult> = ALLOWANCES + let allowances = ALLOWANCES .prefix(&owner_addr) - .range_raw(deps.storage, start, None, Order::Ascending) + .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { - let (k, v) = item?; - Ok(AllowanceInfo { - spender: String::from_utf8(k)?, - allowance: v.allowance, - expires: v.expires, + item.map(|(addr, allow)| AllowanceInfo { + spender: addr.into(), + allowance: allow.allowance, + expires: allow.expires, }) }) - .collect(); - Ok(AllAllowancesResponse { - allowances: allowances?, - }) + .collect::>()?; + Ok(AllAllowancesResponse { allowances }) } pub fn query_all_accounts( From c5eba5bf0464a338764bc1454a5da57c23807b13 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 21:47:38 +0100 Subject: [PATCH 041/352] Replace keys_raw() + deserialization by keys() --- contracts/cw20-base/src/enumerable.rs | 12 +++++------- contracts/cw20-escrow/src/state.rs | 5 ++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/contracts/cw20-base/src/enumerable.rs b/contracts/cw20-base/src/enumerable.rs index d93903536..cb7dc74fc 100644 --- a/contracts/cw20-base/src/enumerable.rs +++ b/contracts/cw20-base/src/enumerable.rs @@ -41,15 +41,13 @@ pub fn query_all_accounts( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive); - let accounts: Result, _> = BALANCES - .keys_raw(deps.storage, start, None, Order::Ascending) - .map(String::from_utf8) + let accounts = BALANCES + .keys(deps.storage, start, None, Order::Ascending) .take(limit) - .collect(); + .map(|item| item.map(Into::into)) + .collect::>()?; - Ok(AllAccountsResponse { - accounts: accounts?, - }) + Ok(AllAccountsResponse { accounts }) } #[cfg(test)] diff --git a/contracts/cw20-escrow/src/state.rs b/contracts/cw20-escrow/src/state.rs index c09dcd3e2..3940d6160 100644 --- a/contracts/cw20-escrow/src/state.rs +++ b/contracts/cw20-escrow/src/state.rs @@ -1,7 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{Addr, Coin, Env, Order, StdError, StdResult, Storage, Timestamp}; +use cosmwasm_std::{Addr, Coin, Env, Order, StdResult, Storage, Timestamp}; use cw_storage_plus::Map; use cw20::{Balance, Cw20CoinVerified}; @@ -95,8 +95,7 @@ pub const ESCROWS: Map<&str, Escrow> = Map::new("escrow"); /// This returns the list of ids for all registered escrows pub fn all_escrow_ids(storage: &dyn Storage) -> StdResult> { ESCROWS - .keys_raw(storage, None, None, Order::Ascending) - .map(|k| String::from_utf8(k).map_err(|_| StdError::invalid_utf8("parsing escrow key"))) + .keys(storage, None, None, Order::Ascending) .collect() } From 5f9da6bf5faa190d2c9311c98e37899713fdede9 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 22:04:17 +0100 Subject: [PATCH 042/352] Replace range_raw() + deserialization by range() Refactor raw_range iterator --- contracts/cw20-ics20/src/contract.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 03a806102..132c08dd6 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -151,32 +151,30 @@ fn query_port(deps: Deps) -> StdResult { } fn query_list(deps: Deps) -> StdResult { - let channels: StdResult> = CHANNEL_INFO + let channels = CHANNEL_INFO .range_raw(deps.storage, None, None, Order::Ascending) .map(|r| r.map(|(_, v)| v)) - .collect(); - Ok(ListChannelsResponse { - channels: channels?, - }) + .collect::>()?; + Ok(ListChannelsResponse { channels }) } // make public for ibc tests pub fn query_channel(deps: Deps, id: String) -> StdResult { let info = CHANNEL_INFO.load(deps.storage, &id)?; // this returns Vec<(outstanding, total)> - let state: StdResult> = CHANNEL_STATE + let state = CHANNEL_STATE .prefix(&id) - .range_raw(deps.storage, None, None, Order::Ascending) + .range(deps.storage, None, None, Order::Ascending) .map(|r| { - let (k, v) = r?; - let denom = String::from_utf8(k)?; - let outstanding = Amount::from_parts(denom.clone(), v.outstanding); - let total = Amount::from_parts(denom, v.total_sent); - Ok((outstanding, total)) + r.map(|(denom, v)| { + let outstanding = Amount::from_parts(denom.clone(), v.outstanding); + let total = Amount::from_parts(denom, v.total_sent); + (outstanding, total) + }) }) - .collect(); + .collect::>>()?; // we want (Vec, Vec) - let (balances, total_sent) = state?.into_iter().unzip(); + let (balances, total_sent) = state.into_iter().unzip(); Ok(ChannelResponse { info, From f04f1f3b519a6774cddcf6fb88f2183ccb4992e9 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 11 Dec 2021 22:56:59 +0100 Subject: [PATCH 043/352] Replace range_raw() + deserialization by range() --- contracts/cw3-fixed-multisig/src/contract.rs | 69 ++++++++++---------- contracts/cw3-flex-multisig/src/contract.rs | 52 +++++++-------- contracts/cw4-group/src/contract.rs | 13 ++-- contracts/cw4-stake/src/contract.rs | 13 ++-- 4 files changed, 70 insertions(+), 77 deletions(-) diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 48a600834..2f2ef70d5 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -17,9 +17,7 @@ use utils::Expiration; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{ - next_id, parse_id, Ballot, Config, Proposal, BALLOTS, CONFIG, PROPOSALS, VOTERS, -}; +use crate::state::{next_id, Ballot, Config, Proposal, BALLOTS, CONFIG, PROPOSALS, VOTERS}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw3-fixed-multisig"; @@ -315,13 +313,13 @@ fn list_proposals( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive_int); - let props: StdResult> = PROPOSALS - .range_raw(deps.storage, start, None, Order::Ascending) + let proposals = PROPOSALS + .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|p| map_proposal(&env.block, &threshold, p)) - .collect(); + .collect::>()?; - Ok(ProposalListResponse { proposals: props? }) + Ok(ProposalListResponse { proposals }) } fn reverse_proposals( @@ -338,30 +336,31 @@ fn reverse_proposals( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let end = start_before.map(Bound::exclusive_int); - let props: StdResult> = PROPOSALS - .range_raw(deps.storage, None, end, Order::Descending) + let proposals = PROPOSALS + .range(deps.storage, None, end, Order::Descending) .take(limit) .map(|p| map_proposal(&env.block, &threshold, p)) - .collect(); + .collect::>()?; - Ok(ProposalListResponse { proposals: props? }) + Ok(ProposalListResponse { proposals }) } fn map_proposal( block: &BlockInfo, threshold: &ThresholdResponse, - item: StdResult<(Vec, Proposal)>, + item: StdResult<(u64, Proposal)>, ) -> StdResult { - let (key, prop) = item?; - let status = prop.current_status(block); - Ok(ProposalResponse { - id: parse_id(&key)?, - title: prop.title, - description: prop.description, - msgs: prop.msgs, - status, - expires: prop.expires, - threshold: threshold.clone(), + item.map(|(id, prop)| { + let status = prop.current_status(block); + ProposalResponse { + id, + title: prop.title, + description: prop.description, + msgs: prop.msgs, + status, + expires: prop.expires, + threshold: threshold.clone(), + } }) } @@ -385,21 +384,20 @@ fn list_votes( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive); - let votes: StdResult> = BALLOTS + let votes = BALLOTS .prefix(proposal_id) - .range_raw(deps.storage, start, None, Order::Ascending) + .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { - let (key, ballot) = item?; - Ok(VoteInfo { - voter: String::from_utf8(key)?, + item.map(|(addr, ballot)| VoteInfo { + voter: addr.into(), vote: ballot.vote, weight: ballot.weight, }) }) - .collect(); + .collect::>()?; - Ok(VoteListResponse { votes: votes? }) + Ok(VoteListResponse { votes }) } fn query_voter(deps: Deps, voter: String) -> StdResult { @@ -416,19 +414,18 @@ fn list_voters( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive); - let voters: StdResult> = VOTERS - .range_raw(deps.storage, start, None, Order::Ascending) + let voters = VOTERS + .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { - let (key, weight) = item?; - Ok(VoterDetail { - addr: String::from_utf8(key)?, + item.map(|(addr, weight)| VoterDetail { + addr: addr.into(), weight, }) }) - .collect(); + .collect::>()?; - Ok(VoterListResponse { voters: voters? }) + Ok(VoterListResponse { voters }) } #[cfg(test)] diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index c7293d99c..38169b6b5 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -18,9 +18,7 @@ use utils::{maybe_addr, Expiration}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{ - next_id, parse_id, Ballot, Config, Proposal, Votes, BALLOTS, CONFIG, PROPOSALS, -}; +use crate::state::{next_id, Ballot, Config, Proposal, Votes, BALLOTS, CONFIG, PROPOSALS}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw3-flex-multisig"; @@ -317,13 +315,13 @@ fn list_proposals( ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive_int); - let props: StdResult> = PROPOSALS - .range_raw(deps.storage, start, None, Order::Ascending) + let proposals = PROPOSALS + .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|p| map_proposal(&env.block, p)) - .collect(); + .collect::>()?; - Ok(ProposalListResponse { proposals: props? }) + Ok(ProposalListResponse { proposals }) } fn reverse_proposals( @@ -335,7 +333,7 @@ fn reverse_proposals( let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let end = start_before.map(Bound::exclusive_int); let props: StdResult> = PROPOSALS - .range_raw(deps.storage, None, end, Order::Descending) + .range(deps.storage, None, end, Order::Descending) .take(limit) .map(|p| map_proposal(&env.block, p)) .collect(); @@ -345,19 +343,20 @@ fn reverse_proposals( fn map_proposal( block: &BlockInfo, - item: StdResult<(Vec, Proposal)>, + item: StdResult<(u64, Proposal)>, ) -> StdResult { - let (key, prop) = item?; - let status = prop.current_status(block); - let threshold = prop.threshold.to_response(prop.total_weight); - Ok(ProposalResponse { - id: parse_id(&key)?, - title: prop.title, - description: prop.description, - msgs: prop.msgs, - status, - expires: prop.expires, - threshold, + item.map(|(id, prop)| { + let status = prop.current_status(block); + let threshold = prop.threshold.to_response(prop.total_weight); + ProposalResponse { + id, + title: prop.title, + description: prop.description, + msgs: prop.msgs, + status, + expires: prop.expires, + threshold, + } }) } @@ -382,21 +381,20 @@ fn list_votes( let addr = maybe_addr(deps.api, start_after)?; let start = addr.map(|addr| Bound::exclusive(addr.as_ref())); - let votes: StdResult> = BALLOTS + let votes = BALLOTS .prefix(proposal_id) - .range_raw(deps.storage, start, None, Order::Ascending) + .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { - let (voter, ballot) = item?; - Ok(VoteInfo { - voter: String::from_utf8(voter)?, + item.map(|(addr, ballot)| VoteInfo { + voter: addr.into(), vote: ballot.vote, weight: ballot.weight, }) }) - .collect(); + .collect::>()?; - Ok(VoteListResponse { votes: votes? }) + Ok(VoteListResponse { votes }) } fn query_voter(deps: Deps, voter: String) -> StdResult { diff --git a/contracts/cw4-group/src/contract.rs b/contracts/cw4-group/src/contract.rs index e0a34d3f1..e41e9d9f6 100644 --- a/contracts/cw4-group/src/contract.rs +++ b/contracts/cw4-group/src/contract.rs @@ -192,19 +192,18 @@ fn list_members( let addr = maybe_addr(deps.api, start_after)?; let start = addr.map(|addr| Bound::exclusive(addr.to_string())); - let members: StdResult> = MEMBERS - .range_raw(deps.storage, start, None, Order::Ascending) + let members = MEMBERS + .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { - let (key, weight) = item?; - Ok(Member { - addr: String::from_utf8(key)?, + item.map(|(addr, weight)| Member { + addr: addr.into(), weight, }) }) - .collect(); + .collect::>()?; - Ok(MemberListResponse { members: members? }) + Ok(MemberListResponse { members }) } #[cfg(test)] diff --git a/contracts/cw4-stake/src/contract.rs b/contracts/cw4-stake/src/contract.rs index 20aa3b6f2..635a20080 100644 --- a/contracts/cw4-stake/src/contract.rs +++ b/contracts/cw4-stake/src/contract.rs @@ -341,19 +341,18 @@ fn list_members( let addr = maybe_addr(deps.api, start_after)?; let start = addr.map(|addr| Bound::exclusive(addr.as_ref())); - let members: StdResult> = MEMBERS - .range_raw(deps.storage, start, None, Order::Ascending) + let members = MEMBERS + .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { - let (key, weight) = item?; - Ok(Member { - addr: String::from_utf8(key)?, + item.map(|(addr, weight)| Member { + addr: addr.into(), weight, }) }) - .collect(); + .collect::>()?; - Ok(MemberListResponse { members: members? }) + Ok(MemberListResponse { members }) } #[cfg(test)] From ae2537cf60e5b15321cdeeaaba08f5bbe3425365 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 13 Dec 2021 07:59:20 +0100 Subject: [PATCH 044/352] Update test cases/comments in Map for clarity --- packages/storage-plus/src/map.rs | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index c7f7fc02c..320c7a64c 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -124,7 +124,7 @@ where } } -// short-cut for simple keys, rather than .prefix(()).range(...) +// short-cut for simple keys, rather than .prefix(()).range_raw(...) #[cfg(feature = "iterator")] impl<'a, K, T> Map<'a, K, T> where @@ -133,8 +133,8 @@ where // Other cases need to call prefix() first K: PrimaryKey<'a>, { - /// While `range` over a `prefix` fixes the prefix to one element and iterates over the - /// remaining, `prefix_range` accepts bounds for the lowest and highest elements of the `Prefix` + /// While `range_raw` over a `prefix` fixes the prefix to one element and iterates over the + /// remaining, `prefix_range_raw` accepts bounds for the lowest and highest elements of the `Prefix` /// itself, and iterates over those (inclusively or exclusively, depending on `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. @@ -395,7 +395,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn range_simple_key() { + fn range_raw_simple_key() { let mut store = MockStorage::new(); // save and load on two keys @@ -457,7 +457,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn range_de_simple_string_key() { + fn range_simple_string_key() { let mut store = MockStorage::new(); // save and load on two keys @@ -517,7 +517,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn range_de_simple_integer_key() { + fn range_simple_integer_key() { let mut store = MockStorage::new(); // save and load on two keys @@ -570,7 +570,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn range_composite_key() { + fn range_raw_composite_key() { let mut store = MockStorage::new(); // save and load on three keys, one under different owner @@ -614,7 +614,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn range_de_composite_key() { + fn range_composite_key() { let mut store = MockStorage::new(); // save and load on three keys, one under different owner @@ -643,7 +643,7 @@ mod test { ] ); - // let's try to iterate over a prefix_de + // let's try to iterate over a prefix let all: StdResult> = ALLOWANCE .prefix(b"owner") .range(&store, None, None, Order::Ascending) @@ -658,7 +658,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn range_triple_key() { + fn range_raw_triple_key() { let mut store = MockStorage::new(); // save and load on three keys, one under different owner @@ -725,7 +725,7 @@ mod test { .collect(); let all = all.unwrap(); assert_eq!(3, all.len()); - // Use range_de() if you want key deserialization + // Use range() if you want key deserialization assert_eq!( all, vec![ @@ -738,7 +738,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn range_de_triple_key() { + fn range_triple_key() { let mut store = MockStorage::new(); // save and load on three keys, one under different owner @@ -769,7 +769,7 @@ mod test { ] ); - // let's iterate over a sub_prefix_de + // let's iterate over a sub_prefix let all: StdResult> = TRIPLE .sub_prefix(b"owner") .range(&store, None, None, Order::Ascending) @@ -785,7 +785,7 @@ mod test { ] ); - // let's iterate over a prefix_de + // let's iterate over a prefix let all: StdResult> = TRIPLE .prefix((b"owner", 9)) .range(&store, None, None, Order::Ascending) @@ -931,7 +931,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn readme_with_range() -> StdResult<()> { + fn readme_with_range_raw() -> StdResult<()> { let mut store = MockStorage::new(); // save and load on two keys @@ -998,7 +998,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn prefixed_range_works() { + fn prefixed_range_raw_works() { // this is designed to look as much like a secondary index as possible // we want to query over a range of u32 for the first key and all subkeys const AGES: Map<(u32, Vec), u64> = Map::new("ages"); @@ -1084,7 +1084,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn prefixed_range_de_works() { + fn prefixed_range_works() { // this is designed to look as much like a secondary index as possible // we want to query over a range of u32 for the first key and all subkeys const AGES: Map<(u32, &str), u64> = Map::new("ages"); From 8a0365f5f5a6b8c6eb7904e794910280dadade62 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 13 Dec 2021 08:09:52 +0100 Subject: [PATCH 045/352] Update test cases/comments in SnapshotMap --- packages/storage-plus/src/snapshot/map.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index 030e08937..ef1d572b4 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -156,7 +156,7 @@ where } } -// short-cut for simple keys, rather than .prefix(()).range(...) +// short-cut for simple keys, rather than .prefix(()).range_raw(...) impl<'a, K, T> SnapshotMap<'a, K, T> where T: Serialize + DeserializeOwned + Clone, @@ -333,7 +333,7 @@ mod tests { const VALUES_START_5: &[(&str, Option)] = &[("A", Some(8)), ("B", None), ("C", Some(13)), ("D", None)]; - // Same as `init_data`, but we have a composite key for testing range_de. + // Same as `init_data`, but we have a composite key for testing range. fn init_data_composite_key(map: &TestMapCompositeKey, storage: &mut dyn Storage) { map.save(storage, ("A", "B"), &5, 1).unwrap(); map.save(storage, ("B", "A"), &7, 2).unwrap(); @@ -460,7 +460,7 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn range_de_simple_string_key() { + fn range_simple_string_key() { use cosmwasm_std::Order; let mut store = MockStorage::new(); @@ -501,7 +501,7 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn range_de_composite_key() { + fn range_composite_key() { use cosmwasm_std::Order; let mut store = MockStorage::new(); @@ -524,7 +524,7 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn prefix_range_de_composite_key() { + fn prefix_range_composite_key() { use cosmwasm_std::Order; let mut store = MockStorage::new(); @@ -546,7 +546,7 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn prefix_de_composite_key() { + fn prefix_composite_key() { use cosmwasm_std::Order; let mut store = MockStorage::new(); @@ -564,7 +564,7 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn sub_prefix_de_composite_key() { + fn sub_prefix_composite_key() { use cosmwasm_std::Order; let mut store = MockStorage::new(); @@ -572,7 +572,7 @@ mod tests { // Let's sub-prefix and iterate. // This is similar to calling range() directly, but added here for completeness / - // sub_prefix_de type checks + // sub_prefix type checks let all: StdResult> = EVERY_COMPOSITE_KEY .sub_prefix(()) .range(&store, None, None, Order::Ascending) From 200948f89b29f93e7d935202704dc8e7fa53dd8d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 13 Dec 2021 08:11:02 +0100 Subject: [PATCH 046/352] Adjust indexes comments --- packages/storage-plus/src/indexes/multi.rs | 6 +++--- packages/storage-plus/src/indexes/unique.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 499e7bb44..91a4f29c7 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -187,7 +187,7 @@ where } } -// short-cut for simple keys, rather than .prefix(()).range(...) +// short-cut for simple keys, rather than .prefix(()).range_raw(...) impl<'a, IK, T, PK> MultiIndex<'a, IK, T, PK> where T: Serialize + DeserializeOwned + Clone, @@ -218,8 +218,8 @@ where self.no_prefix_raw().keys_raw(store, min, max, order) } - /// While `range` over a `prefix` fixes the prefix to one element and iterates over the - /// remaining, `prefix_range` accepts bounds for the lowest and highest elements of the + /// While `range_raw` over a `prefix` fixes the prefix to one element and iterates over the + /// remaining, `prefix_range_raw` accepts bounds for the lowest and highest elements of the /// `Prefix` itself, and iterates over those (inclusively or exclusively, depending on /// `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index 06c266fa1..6f729db10 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -132,7 +132,7 @@ where } } -// short-cut for simple keys, rather than .prefix(()).range(...) +// short-cut for simple keys, rather than .prefix(()).range_raw(...) impl<'a, IK, T, PK> UniqueIndex<'a, IK, T, PK> where T: Serialize + DeserializeOwned + Clone, From 4181f547282ed3b1cc51ad9b2b3d449b3e81426a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 13 Dec 2021 08:31:25 +0100 Subject: [PATCH 047/352] Update test cases/comments in indexed maps --- packages/storage-plus/src/indexed_map.rs | 42 +++++++++---------- packages/storage-plus/src/indexed_snapshot.rs | 36 ++++++++-------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index b67dadb9a..d9a7df53c 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -135,7 +135,7 @@ where } } -// short-cut for simple keys, rather than .prefix(()).range(...) +// short-cut for simple keys, rather than .prefix(()).range_raw(...) impl<'a, K, T, I> IndexedMap<'a, K, T, I> where K: PrimaryKey<'a>, @@ -175,8 +175,8 @@ where T: Serialize + DeserializeOwned + Clone, I: IndexList, { - /// While `range` over a `prefix` fixes the prefix to one element and iterates over the - /// remaining, `prefix_range` accepts bounds for the lowest and highest elements of the `Prefix` + /// While `range_raw` over a `prefix` fixes the prefix to one element and iterates over the + /// remaining, `prefix_range_raw` accepts bounds for the lowest and highest elements of the `Prefix` /// itself, and iterates over those (inclusively or exclusively, depending on `PrefixBound`). /// There are some issues that distinguish these two, and blindly casting to `Vec` doesn't /// solve them. @@ -520,7 +520,7 @@ mod test { } #[test] - fn range_simple_key_by_multi_index() { + fn range_raw_simple_key_by_multi_index() { let mut store = MockStorage::new(); let map = build_map(); @@ -576,7 +576,7 @@ mod test { } #[test] - fn range_de_simple_key_by_multi_index() { + fn range_simple_key_by_multi_index() { let mut store = MockStorage::new(); let map = build_map(); @@ -632,7 +632,7 @@ mod test { } #[test] - fn range_composite_key_by_multi_index() { + fn range_raw_composite_key_by_multi_index() { let mut store = MockStorage::new(); let indexes = DataCompositeMultiIndex { @@ -693,7 +693,7 @@ mod test { } #[test] - fn range_de_composite_key_by_multi_index() { + fn range_composite_key_by_multi_index() { let mut store = MockStorage::new(); let indexes = DataCompositeMultiIndex { @@ -861,7 +861,7 @@ mod test { } #[test] - fn range_simple_key_by_unique_index() { + fn range_raw_simple_key_by_unique_index() { let mut store = MockStorage::new(); let map = build_map(); @@ -894,7 +894,7 @@ mod test { } #[test] - fn range_de_simple_key_by_unique_index() { + fn range_simple_key_by_unique_index() { let mut store = MockStorage::new(); let map = build_map(); @@ -927,7 +927,7 @@ mod test { } #[test] - fn range_composite_key_by_unique_index() { + fn range_raw_composite_key_by_unique_index() { let mut store = MockStorage::new(); let map = build_map(); @@ -956,7 +956,7 @@ mod test { } #[test] - fn range_de_composite_key_by_unique_index() { + fn range_composite_key_by_unique_index() { let mut store = MockStorage::new(); let map = build_map(); @@ -986,7 +986,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn range_de_simple_string_key() { + fn range_simple_string_key() { let mut store = MockStorage::new(); let map = build_map(); @@ -1029,7 +1029,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn prefix_de_simple_string_key() { + fn prefix_simple_string_key() { let mut store = MockStorage::new(); let map = build_map(); @@ -1037,7 +1037,7 @@ mod test { let (pks, datas) = save_data(&mut store, &map); // Let's prefix and iterate. - // This is similar to calling range() directly, but added here for completeness / prefix_de + // This is similar to calling range() directly, but added here for completeness / prefix // type checks let all: StdResult> = map .prefix(()) @@ -1056,7 +1056,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn prefix_de_composite_key() { + fn prefix_composite_key() { let mut store = MockStorage::new(); let indexes = DataCompositeMultiIndex { @@ -1111,7 +1111,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn prefix_de_triple_key() { + fn prefix_triple_key() { let mut store = MockStorage::new(); let indexes = DataCompositeMultiIndex { @@ -1163,7 +1163,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn sub_prefix_de_triple_key() { + fn sub_prefix_triple_key() { let mut store = MockStorage::new(); let indexes = DataCompositeMultiIndex { @@ -1221,7 +1221,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn prefix_range_de_simple_key() { + fn prefix_range_simple_key() { let mut store = MockStorage::new(); let indexes = DataCompositeMultiIndex { @@ -1262,7 +1262,7 @@ mod test { let pk4 = ("3", "5630"); map.save(&mut store, pk4, &data4).unwrap(); - // let's try to iterate! + // let's prefix-range and iterate let result: StdResult> = map .prefix_range( &store, @@ -1281,7 +1281,7 @@ mod test { ] ); - // let's try to iterate over a range + // let's try to iterate over a more restrictive prefix-range! let result: StdResult> = map .prefix_range( &store, @@ -1302,7 +1302,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn prefix_range_de_triple_key() { + fn prefix_range_triple_key() { let mut store = MockStorage::new(); let indexes = DataCompositeMultiIndex { diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 2b7914186..7b2eb7b82 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -180,7 +180,7 @@ where } } -// short-cut for simple keys, rather than .prefix(()).range(...) +// short-cut for simple keys, rather than .prefix(()).range_raw(...) impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I> where K: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize, @@ -488,7 +488,7 @@ mod test { } #[test] - fn range_simple_key_by_multi_index() { + fn range_raw_simple_key_by_multi_index() { let mut store = MockStorage::new(); let map = build_snapshot_map(); let mut height = 1; @@ -548,7 +548,7 @@ mod test { } #[test] - fn range_de_simple_key_by_multi_index() { + fn range_simple_key_by_multi_index() { let mut store = MockStorage::new(); let map = build_snapshot_map(); let mut height = 1; @@ -608,7 +608,7 @@ mod test { } #[test] - fn range_composite_key_by_multi_index() { + fn range_raw_composite_key_by_multi_index() { let mut store = MockStorage::new(); let mut height = 2; @@ -674,7 +674,7 @@ mod test { } #[test] - fn range_de_composite_key_by_multi_index() { + fn range_composite_key_by_multi_index() { let mut store = MockStorage::new(); let mut height = 2; @@ -853,7 +853,7 @@ mod test { } #[test] - fn range_simple_key_by_unique_index() { + fn range_raw_simple_key_by_unique_index() { let mut store = MockStorage::new(); let map = build_snapshot_map(); @@ -884,7 +884,7 @@ mod test { } #[test] - fn range_de_simple_key_by_unique_index() { + fn range_simple_key_by_unique_index() { let mut store = MockStorage::new(); let map = build_snapshot_map(); @@ -915,7 +915,7 @@ mod test { } #[test] - fn range_composite_key_by_unique_index() { + fn range_raw_composite_key_by_unique_index() { let mut store = MockStorage::new(); let map = build_snapshot_map(); @@ -944,7 +944,7 @@ mod test { } #[test] - fn range_de_composite_key_by_unique_index() { + fn range_composite_key_by_unique_index() { let mut store = MockStorage::new(); let map = build_snapshot_map(); @@ -974,7 +974,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn range_de_simple_string_key() { + fn range_simple_string_key() { let mut store = MockStorage::new(); let map = build_snapshot_map(); @@ -1017,7 +1017,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn prefix_de_simple_string_key() { + fn prefix_simple_string_key() { let mut store = MockStorage::new(); let map = build_snapshot_map(); @@ -1025,7 +1025,7 @@ mod test { let (pks, datas) = save_data(&mut store, &map); // Let's prefix and iterate. - // This is similar to calling range() directly, but added here for completeness / prefix_de + // This is similar to calling range() directly, but added here for completeness / prefix // type checks let all: StdResult> = map .prefix(()) @@ -1044,15 +1044,15 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn sub_prefix_de_simple_string_key() { + fn sub_prefix_simple_string_key() { let mut store = MockStorage::new(); let map = build_snapshot_map(); // save data let (pks, datas) = save_data(&mut store, &map); - // Let's prefix and iterate. - // This is similar to calling range() directly, but added here for completeness / sub_prefix_de + // Let's sub-prefix and iterate. + // This is similar to calling range() directly, but added here for completeness / sub_prefix // type checks let all: StdResult> = map .sub_prefix(()) @@ -1071,7 +1071,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn prefix_range_de_simple_key() { + fn prefix_range_simple_key() { let mut store = MockStorage::new(); let indexes = DataCompositeMultiIndex { @@ -1113,7 +1113,7 @@ mod test { let pk4: (&str, &str) = ("3", "5630"); map.save(&mut store, pk4, &data4, 1).unwrap(); - // let's try to iterate! + // let's prefix-range and iterate let result: StdResult> = map .prefix_range( &store, @@ -1132,7 +1132,7 @@ mod test { ] ); - // let's try to iterate over a range + // let's try to iterate over a more restrictive prefix-range! let result: StdResult> = map .prefix_range( &store, From 97d6683c3549386805d4eecd2edddd8dd29d733b Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 14 Dec 2021 16:07:01 +0100 Subject: [PATCH 048/352] Add deprecation notices for `IntKey` type aliases --- packages/storage-plus/src/keys.rs | 10 ++++++++++ packages/storage-plus/src/lib.rs | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index 15b7a6c19..08cb4caf9 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -326,16 +326,26 @@ impl<'a, T: Endian> Prefixer<'a> for IntKey { } } +#[deprecated(note = "It is suggested to use `u8` as key type instead of the `U8Key` wrapper")] pub type U8Key = IntKey; +#[deprecated(note = "It is suggested to use `u16` as key type instead of the `U16Key` wrapper")] pub type U16Key = IntKey; +#[deprecated(note = "It is suggested to use `u32` as key type instead of the `U32Key` wrapper")] pub type U32Key = IntKey; +#[deprecated(note = "It is suggested to use `u64` as key type instead of the `U64Key` wrapper")] pub type U64Key = IntKey; +#[deprecated(note = "Consider using 64-bit keys instead of the `U128Key` wrapper")] pub type U128Key = IntKey; +#[deprecated(note = "It is suggested to use `i8` as key type instead of the `I8Key` wrapper")] pub type I8Key = IntKey; +#[deprecated(note = "It is suggested to use `i16` as key type instead of the `I16Key` wrapper")] pub type I16Key = IntKey; +#[deprecated(note = "It is suggested to use `i32` as key type instead of the `I32Key` wrapper")] pub type I32Key = IntKey; +#[deprecated(note = "It is suggested to use `i64` as key type instead of the `I64Key` wrapper")] pub type I64Key = IntKey; +#[deprecated(note = "Consider using 64-bit keys instead of the `I128Key` wrapper")] pub type I128Key = IntKey; /// It will cast one-particular int type into a Key via Vec, ensuring you don't mix up u32 and u64 diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 53bbba036..0ab72b3a5 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -24,7 +24,11 @@ pub use indexes::UniqueIndex; #[cfg(feature = "iterator")] pub use indexes::{index_string, index_string_tuple, index_triple, index_tuple, Index}; pub use item::Item; +// TODO: Remove along with `IntKey` +#[allow(deprecated)] pub use keys::{I128Key, I16Key, I32Key, I64Key, I8Key}; +// TODO: Remove along with `IntKey` +#[allow(deprecated)] pub use keys::{Prefixer, PrimaryKey, U128Key, U16Key, U32Key, U64Key, U8Key}; pub use map::Map; pub use path::Path; From 155909bbabd6700d003001eb2cdb3f108d8ee638 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 15 Dec 2021 14:13:14 +0100 Subject: [PATCH 049/352] Add integer key builder / helpers --- packages/storage-plus/src/int_key.rs | 51 ++++++++++++++++++++++++++++ packages/storage-plus/src/lib.rs | 1 + 2 files changed, 52 insertions(+) create mode 100644 packages/storage-plus/src/int_key.rs diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs new file mode 100644 index 000000000..8462f7d68 --- /dev/null +++ b/packages/storage-plus/src/int_key.rs @@ -0,0 +1,51 @@ +use std::mem; + +/// Our int keys are simply the Big-endian representation bytes for unsigned ints, +/// but "sign-flipped" (xored msb) Big-endian bytes for signed ints. +/// So that the representation of signed integers is correctly ordered lexicographically. +pub trait CwIntKey: Sized + Copy { + type Buf: AsRef<[u8]> + AsMut<[u8]> + Into> + Default; + + fn to_cw_bytes(&self) -> Self::Buf; + fn from_cw_bytes(bytes: Self::Buf) -> Self; +} + +macro_rules! cw_uint_keys { + (for $($t:ty),+) => { + $(impl CwIntKey for $t { + type Buf = [u8; mem::size_of::<$t>()]; + + fn to_cw_bytes(&self) -> Self::Buf { + self.to_be_bytes() + } + + fn from_cw_bytes(bytes: Self::Buf) -> Self { + Self::from_be_bytes(bytes) + } + })* + } +} + +cw_uint_keys!(for u8, u16, u32, u64, u128); + +macro_rules! cw_int_keys { + (for $($t:ty),+) => { + $(impl CwIntKey for $t { + type Buf = [u8; mem::size_of::<$t>()]; + + fn to_cw_bytes(&self) -> Self::Buf { + let mut bytes = self.to_be_bytes(); + bytes[0] ^= 0x80; + bytes + } + + fn from_cw_bytes(bytes: Self::Buf) -> Self { + let mut bytes = bytes; + bytes[0] ^= 0x80; + Self::from_be_bytes(bytes) + } + })* + } +} + +cw_int_keys!(for i8, i16, i32, i64, i128); diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 0ab72b3a5..0dd50417e 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -4,6 +4,7 @@ mod helpers; mod indexed_map; mod indexed_snapshot; mod indexes; +mod int_key; mod item; mod iter_helpers; mod keys; From bdba35cb68838eb66885a84b949e206fe5877082 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 15 Dec 2021 18:21:09 +0100 Subject: [PATCH 050/352] Use new integer key helpers --- packages/storage-plus/src/de.rs | 18 +++++++----- packages/storage-plus/src/keys.rs | 45 +++++++++++++++-------------- packages/storage-plus/src/prefix.rs | 9 +++--- 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/packages/storage-plus/src/de.rs b/packages/storage-plus/src/de.rs index 1d69df74e..75981956d 100644 --- a/packages/storage-plus/src/de.rs +++ b/packages/storage-plus/src/de.rs @@ -6,6 +6,7 @@ use std::convert::TryInto; use cosmwasm_std::{Addr, StdError, StdResult}; +use crate::int_key::CwIntKey; use crate::keys::{IntKey, TimestampKey}; pub trait KeyDeserialize { @@ -106,7 +107,7 @@ macro_rules! integer_de { #[inline(always)] fn from_vec(value: Vec) -> StdResult { - Ok(<$t>::from_be_bytes(value.as_slice().try_into() + Ok(<$t>::from_cw_bytes(value.as_slice().try_into() .map_err(|err: TryFromSliceError| StdError::generic_err(err.to_string()))?)) } })* @@ -122,7 +123,7 @@ macro_rules! intkey_de { #[inline(always)] fn from_vec(value: Vec) -> StdResult { - Ok(<$t>::from_be_bytes(value.as_slice().try_into() + Ok(<$t>::from_cw_bytes(value.as_slice().try_into() .map_err(|err: TryFromSliceError| StdError::generic_err(err.to_string()))?)) } })* @@ -232,11 +233,14 @@ mod test { #[test] fn deserialize_integer_works() { assert_eq!(>::from_slice(&[1]).unwrap(), 1u8); - assert_eq!(>::from_slice(&[128]).unwrap(), -1i8 << 7); + assert_eq!( + >::from_slice(&[128]).unwrap(), + ((-1i8 << 7) as u8 ^ 0x80) as i8 + ); assert_eq!(>::from_slice(&[1, 0]).unwrap(), 1u16 << 8); assert_eq!( >::from_slice(&[128, 0]).unwrap(), - -1i16 << (8 + 7) + ((-1i16 << (8 + 7)) as u16 ^ 0x8000) as i16 ); assert_eq!( >::from_slice(&[1, 0, 0, 0]).unwrap(), @@ -244,7 +248,7 @@ mod test { ); assert_eq!( >::from_slice(&[128, 0, 0, 0]).unwrap(), - -1i32 << (3 * 8 + 7) + ((-1i32 << (3 * 8 + 7)) as u32 ^ 0x80000000) as i32 ); assert_eq!( >::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0]).unwrap(), @@ -252,7 +256,7 @@ mod test { ); assert_eq!( >::from_slice(&[128, 0, 0, 0, 0, 0, 0, 0]).unwrap(), - -1i64 << (7 * 8 + 7) + ((-1i64 << (7 * 8 + 7)) as u64 ^ 0x8000000000000000) as i64 ); assert_eq!( >::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), @@ -263,7 +267,7 @@ mod test { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ]) .unwrap(), - -1i128 + (-1i128 as u128 ^ 0x80000000000000000000000000000000u128) as i128 ); } diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index 08cb4caf9..ff318cde0 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -6,6 +6,7 @@ use std::marker::PhantomData; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; +use crate::int_key::CwIntKey; use crate::Endian; #[derive(Debug)] @@ -284,7 +285,7 @@ macro_rules! integer_key { type SuperSuffix = Self; fn key(&self) -> Vec { - vec![Key::$v(self.to_be_bytes())] + vec![Key::$v(self.to_cw_bytes())] } })* } @@ -296,7 +297,7 @@ macro_rules! integer_prefix { (for $($t:ty, $v:tt),+) => { $(impl<'a> Prefixer<'a> for $t { fn prefix(&self) -> Vec { - vec![Key::$v(self.to_be_bytes())] + vec![Key::$v(self.to_cw_bytes())] } })* } @@ -361,16 +362,16 @@ pub struct IntKey { pub data: PhantomData, } -impl IntKey { +impl IntKey { pub fn new(val: T) -> Self { IntKey { - wrapped: val.to_be_bytes().into(), + wrapped: val.to_cw_bytes().into(), data: PhantomData, } } } -impl From for IntKey { +impl From for IntKey { fn from(val: T) -> Self { IntKey::new(val) } @@ -440,7 +441,7 @@ mod test { let k: U64Key = 134u64.into(); let path = k.key(); assert_eq!(1, path.len()); - assert_eq!(134u64.to_be_bytes(), path[0].as_ref()); + assert_eq!(134u64.to_cw_bytes(), path[0].as_ref()); } #[test] @@ -448,7 +449,7 @@ mod test { let k: U32Key = 4242u32.into(); let path = k.key(); assert_eq!(1, path.len()); - assert_eq!(4242u32.to_be_bytes(), path[0].as_ref()); + assert_eq!(4242u32.to_cw_bytes(), path[0].as_ref()); } #[test] @@ -456,12 +457,12 @@ mod test { let k: u8 = 42u8; let path = k.key(); assert_eq!(1, path.len()); - assert_eq!(42u8.to_be_bytes(), path[0].as_ref()); + assert_eq!(42u8.to_cw_bytes(), path[0].as_ref()); let k: i8 = 42i8; let path = k.key(); assert_eq!(1, path.len()); - assert_eq!(42i8.to_be_bytes(), path[0].as_ref()); + assert_eq!(42i8.to_cw_bytes(), path[0].as_ref()); } #[test] @@ -469,12 +470,12 @@ mod test { let k: u16 = 4242u16; let path = k.key(); assert_eq!(1, path.len()); - assert_eq!(4242u16.to_be_bytes(), path[0].as_ref()); + assert_eq!(4242u16.to_cw_bytes(), path[0].as_ref()); let k: i16 = 4242i16; let path = k.key(); assert_eq!(1, path.len()); - assert_eq!(4242i16.to_be_bytes(), path[0].as_ref()); + assert_eq!(4242i16.to_cw_bytes(), path[0].as_ref()); } #[test] @@ -482,12 +483,12 @@ mod test { let k: u32 = 4242u32; let path = k.key(); assert_eq!(1, path.len()); - assert_eq!(4242u32.to_be_bytes(), path[0].as_ref()); + assert_eq!(4242u32.to_cw_bytes(), path[0].as_ref()); let k: i32 = 4242i32; let path = k.key(); assert_eq!(1, path.len()); - assert_eq!(4242i32.to_be_bytes(), path[0].as_ref()); + assert_eq!(4242i32.to_cw_bytes(), path[0].as_ref()); } #[test] @@ -495,12 +496,12 @@ mod test { let k: u64 = 4242u64; let path = k.key(); assert_eq!(1, path.len()); - assert_eq!(4242u64.to_be_bytes(), path[0].as_ref()); + assert_eq!(4242u64.to_cw_bytes(), path[0].as_ref()); let k: i64 = 4242i64; let path = k.key(); assert_eq!(1, path.len()); - assert_eq!(4242i64.to_be_bytes(), path[0].as_ref()); + assert_eq!(4242i64.to_cw_bytes(), path[0].as_ref()); } #[test] @@ -557,8 +558,8 @@ mod test { assert_eq!(2, path.len()); assert_eq!(4, path[0].as_ref().len()); assert_eq!(8, path[1].as_ref().len()); - assert_eq!(path[0].as_ref(), 123u32.to_be_bytes()); - assert_eq!(path[1].as_ref(), 87654u64.to_be_bytes()); + assert_eq!(path[0].as_ref(), 123u32.to_cw_bytes()); + assert_eq!(path[1].as_ref(), 87654u64.to_cw_bytes()); } #[test] @@ -568,8 +569,8 @@ mod test { assert_eq!(2, path.len()); assert_eq!(4, path[0].as_ref().len()); assert_eq!(8, path[1].as_ref().len()); - assert_eq!(path[0].as_ref(), 123u32.to_be_bytes()); - assert_eq!(path[1].as_ref(), 87654u64.to_be_bytes()); + assert_eq!(path[0].as_ref(), 123u32.to_cw_bytes()); + assert_eq!(path[1].as_ref(), 87654u64.to_cw_bytes()); } #[test] @@ -625,7 +626,7 @@ mod test { assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); let pair: (i8, &[u8]) = (123, b"random"); - let one: Vec = vec![123]; + let one: Vec = vec![123 + 128]; let two: Vec = b"random".to_vec(); assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); } @@ -638,7 +639,7 @@ mod test { assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); let pair: (i16, &[u8]) = (12345, b"random"); - let one: Vec = vec![48, 57]; + let one: Vec = vec![48 + 128, 57]; let two: Vec = b"random".to_vec(); assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); } @@ -651,7 +652,7 @@ mod test { assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); let pair: (i64, &[u8]) = (12345, b"random"); - let one: Vec = vec![0, 0, 0, 0, 0, 0, 48, 57]; + let one: Vec = vec![128, 0, 0, 0, 0, 0, 48, 57]; let two: Vec = b"random".to_vec(); assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); } diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 5c210052a..38e4b7c78 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -8,6 +8,7 @@ use std::ops::Deref; use crate::de::KeyDeserialize; use crate::helpers::{namespaces_with_key, nested_namespaces_with_key}; +use crate::int_key::CwIntKey; use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim}; use crate::keys::Key; use crate::{Endian, Prefixer}; @@ -34,13 +35,13 @@ impl Bound { } /// Turns an int, like Option into an inclusive bound - pub fn inclusive_int(limit: T) -> Self { - Bound::Inclusive(limit.to_be_bytes().into()) + pub fn inclusive_int(limit: T) -> Self { + Bound::Inclusive(limit.to_cw_bytes().into()) } /// Turns an int, like Option into an exclusive bound - pub fn exclusive_int(limit: T) -> Self { - Bound::Exclusive(limit.to_be_bytes().into()) + pub fn exclusive_int(limit: T) -> Self { + Bound::Exclusive(limit.to_cw_bytes().into()) } } From 00f0af851ca07f0b95ba1137a3d935bd8f536557 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 15 Dec 2021 18:32:45 +0100 Subject: [PATCH 051/352] Add positive integer signed integer key tests --- packages/storage-plus/src/de.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/storage-plus/src/de.rs b/packages/storage-plus/src/de.rs index 75981956d..6106aa088 100644 --- a/packages/storage-plus/src/de.rs +++ b/packages/storage-plus/src/de.rs @@ -237,10 +237,18 @@ mod test { >::from_slice(&[128]).unwrap(), ((-1i8 << 7) as u8 ^ 0x80) as i8 ); + assert_eq!( + >::from_slice(&[127]).unwrap(), + (127 ^ 0x80) as i8 + ); assert_eq!(>::from_slice(&[1, 0]).unwrap(), 1u16 << 8); assert_eq!( >::from_slice(&[128, 0]).unwrap(), - ((-1i16 << (8 + 7)) as u16 ^ 0x8000) as i16 + ((-1i16 << 15) as u16 ^ 0x8000) as i16 + ); + assert_eq!( + >::from_slice(&[127, 255]).unwrap(), + (((1u16 << 15) - 1) ^ 0x8000) as i16 ); assert_eq!( >::from_slice(&[1, 0, 0, 0]).unwrap(), @@ -248,7 +256,11 @@ mod test { ); assert_eq!( >::from_slice(&[128, 0, 0, 0]).unwrap(), - ((-1i32 << (3 * 8 + 7)) as u32 ^ 0x80000000) as i32 + ((-1i32 << 31) as u32 ^ 0x80000000) as i32 + ); + assert_eq!( + >::from_slice(&[127, 255, 255, 255]).unwrap(), + (((1u32 << 31) - 1) ^ 0x80000000) as i32 ); assert_eq!( >::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0]).unwrap(), @@ -256,7 +268,11 @@ mod test { ); assert_eq!( >::from_slice(&[128, 0, 0, 0, 0, 0, 0, 0]).unwrap(), - ((-1i64 << (7 * 8 + 7)) as u64 ^ 0x8000000000000000) as i64 + ((-1i64 << 63) as u64 ^ 0x8000000000000000) as i64 + ); + assert_eq!( + >::from_slice(&[127, 255, 255, 255, 255, 255, 255, 255]).unwrap(), + (((1u64 << 63) - 1) ^ 0x8000000000000000) as i64 ); assert_eq!( >::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), @@ -267,7 +283,7 @@ mod test { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ]) .unwrap(), - (-1i128 as u128 ^ 0x80000000000000000000000000000000u128) as i128 + (-1i128 as u128 ^ 0x80000000000000000000000000000000) as i128 ); } From 495ae24f7992e03f7746ea7f2c5b83c67f2fa2d1 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 15 Dec 2021 20:55:14 +0100 Subject: [PATCH 052/352] Non-mutable, branchless signed int key conversions --- packages/storage-plus/src/int_key.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs index 8462f7d68..b2475938f 100644 --- a/packages/storage-plus/src/int_key.rs +++ b/packages/storage-plus/src/int_key.rs @@ -3,6 +3,7 @@ use std::mem; /// Our int keys are simply the Big-endian representation bytes for unsigned ints, /// but "sign-flipped" (xored msb) Big-endian bytes for signed ints. /// So that the representation of signed integers is correctly ordered lexicographically. +// TODO: Rename to `IntKey` when deprecating actual `IntKey` pub trait CwIntKey: Sized + Copy { type Buf: AsRef<[u8]> + AsMut<[u8]> + Into> + Default; @@ -34,15 +35,11 @@ macro_rules! cw_int_keys { type Buf = [u8; mem::size_of::<$t>()]; fn to_cw_bytes(&self) -> Self::Buf { - let mut bytes = self.to_be_bytes(); - bytes[0] ^= 0x80; - bytes + ((*self as u128 ^ <$t>::MIN as u128) as $t).to_be_bytes() } fn from_cw_bytes(bytes: Self::Buf) -> Self { - let mut bytes = bytes; - bytes[0] ^= 0x80; - Self::from_be_bytes(bytes) + (Self::from_be_bytes(bytes) as u128 ^ <$t>::MIN as u128) as _ } })* } From c211470ac3f51cd7fe6069c5d74afa729faa2f18 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 15 Dec 2021 20:56:05 +0100 Subject: [PATCH 053/352] Type-sized casts signed int key conversions --- packages/storage-plus/src/int_key.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs index b2475938f..da099b1d0 100644 --- a/packages/storage-plus/src/int_key.rs +++ b/packages/storage-plus/src/int_key.rs @@ -30,19 +30,19 @@ macro_rules! cw_uint_keys { cw_uint_keys!(for u8, u16, u32, u64, u128); macro_rules! cw_int_keys { - (for $($t:ty),+) => { + (for $($t:ty, $ut:ty),+) => { $(impl CwIntKey for $t { type Buf = [u8; mem::size_of::<$t>()]; fn to_cw_bytes(&self) -> Self::Buf { - ((*self as u128 ^ <$t>::MIN as u128) as $t).to_be_bytes() + (*self as $ut ^ <$t>::MIN as $ut).to_be_bytes() } fn from_cw_bytes(bytes: Self::Buf) -> Self { - (Self::from_be_bytes(bytes) as u128 ^ <$t>::MIN as u128) as _ + (Self::from_be_bytes(bytes) as $ut ^ <$t>::MIN as $ut) as _ } })* } } -cw_int_keys!(for i8, i16, i32, i64, i128); +cw_int_keys!(for i8, u8, i16, u16, i32, u32, i64, u64, i128, u128); From 525390d17b82e40be57755bcc726d4bfcac37221 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 15 Dec 2021 21:02:50 +0100 Subject: [PATCH 054/352] Adapt packages to cw int keys --- packages/storage-plus/src/map.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 320c7a64c..b85c69010 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -254,6 +254,8 @@ mod test { #[cfg(feature = "iterator")] use cosmwasm_std::{Order, StdResult}; + use crate::int_key::CwIntKey; + #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] struct Data { pub name: String, @@ -297,7 +299,7 @@ mod test { ); assert_eq!(b"triple".to_vec().as_slice(), &key[2..8]); assert_eq!(b"john".to_vec().as_slice(), &key[10..14]); - assert_eq!(8u8.to_be_bytes(), &key[16..17]); + assert_eq!(8u8.to_cw_bytes(), &key[16..17]); assert_eq!(b"pedro".to_vec().as_slice(), &key[17..]); } From c2c1a0c8464885034e3b17375e43cc417d62462c Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 15 Dec 2021 21:12:19 +0100 Subject: [PATCH 055/352] Publish cw int key trait --- packages/storage-plus/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 0dd50417e..77665e2f7 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -29,6 +29,7 @@ pub use item::Item; #[allow(deprecated)] pub use keys::{I128Key, I16Key, I32Key, I64Key, I8Key}; // TODO: Remove along with `IntKey` +pub use int_key::CwIntKey; #[allow(deprecated)] pub use keys::{Prefixer, PrimaryKey, U128Key, U16Key, U32Key, U64Key, U8Key}; pub use map::Map; From fc708d4babe8190936b877c55a574614e606f4d8 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 15 Dec 2021 21:17:09 +0100 Subject: [PATCH 056/352] Remove deprecated functions --- contracts/cw3-fixed-multisig/src/state.rs | 12 +----------- contracts/cw3-flex-multisig/src/state.rs | 14 +------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index e3b35c27b..b596ef605 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -1,8 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::convert::TryInto; -use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Empty, StdError, StdResult, Storage}; +use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Empty, StdResult, Storage}; use cw3::{Status, Vote}; use cw_storage_plus::{Item, Map}; @@ -66,12 +65,3 @@ pub fn next_id(store: &mut dyn Storage) -> StdResult { PROPOSAL_COUNT.save(store, &id)?; Ok(id) } - -pub fn parse_id(data: &[u8]) -> StdResult { - match data[0..8].try_into() { - Ok(bytes) => Ok(u64::from_be_bytes(bytes)), - Err(_) => Err(StdError::generic_err( - "Corrupted data found. 8 byte expected.", - )), - } -} diff --git a/contracts/cw3-flex-multisig/src/state.rs b/contracts/cw3-flex-multisig/src/state.rs index 844ec8408..013757beb 100644 --- a/contracts/cw3-flex-multisig/src/state.rs +++ b/contracts/cw3-flex-multisig/src/state.rs @@ -1,10 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::convert::TryInto; -use cosmwasm_std::{ - Addr, BlockInfo, CosmosMsg, Decimal, Empty, StdError, StdResult, Storage, Uint128, -}; +use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Decimal, Empty, StdResult, Storage, Uint128}; use cw3::{Status, Vote}; use cw4::Cw4Contract; @@ -162,15 +159,6 @@ pub fn next_id(store: &mut dyn Storage) -> StdResult { Ok(id) } -pub fn parse_id(data: &[u8]) -> StdResult { - match data[0..8].try_into() { - Ok(bytes) => Ok(u64::from_be_bytes(bytes)), - Err(_) => Err(StdError::generic_err( - "Corrupted data found. 8 byte expected.", - )), - } -} - #[cfg(test)] mod test { use super::*; From a69865660d706d624a3198a4b41ff6ee0d82dac6 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 15 Dec 2021 21:23:14 +0100 Subject: [PATCH 057/352] Improve docs / comments --- packages/storage-plus/src/int_key.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs index da099b1d0..918110345 100644 --- a/packages/storage-plus/src/int_key.rs +++ b/packages/storage-plus/src/int_key.rs @@ -1,9 +1,10 @@ use std::mem; -/// Our int keys are simply the Big-endian representation bytes for unsigned ints, -/// but "sign-flipped" (xored msb) Big-endian bytes for signed ints. -/// So that the representation of signed integers is correctly ordered lexicographically. -// TODO: Rename to `IntKey` when deprecating actual `IntKey` +/// Our int keys are simply the big-endian representation bytes for unsigned ints, +/// but "sign-flipped" (xored msb) big-endian bytes for signed ints. +/// +/// So that the representation of signed integers is in the right lexicographical order. +// TODO: Rename to `IntKey` when deprecating current `IntKey` pub trait CwIntKey: Sized + Copy { type Buf: AsRef<[u8]> + AsMut<[u8]> + Into> + Default; From 2d81dca15fa32b8fa2c7becd7ba63883524da3a6 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 15 Dec 2021 21:35:39 +0100 Subject: [PATCH 058/352] Add cw int key unit tests --- packages/storage-plus/src/int_key.rs | 77 ++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs index 918110345..9aa85e9f9 100644 --- a/packages/storage-plus/src/int_key.rs +++ b/packages/storage-plus/src/int_key.rs @@ -47,3 +47,80 @@ macro_rules! cw_int_keys { } cw_int_keys!(for i8, u8, i16, u16, i32, u32, i64, u64, i128, u128); + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn x8_int_key_works() { + let k: u8 = 42u8; + assert_eq!(k.to_cw_bytes(), k.to_be_bytes()); + + let k: i8 = 42i8; + assert_eq!(k.to_cw_bytes(), (k as u8 ^ 0x80).to_be_bytes()); + + let k: i8 = -42i8; + assert_eq!(k.to_cw_bytes(), (k as u8 ^ 0x80).to_be_bytes()); + } + + #[test] + fn x16_int_key_works() { + let k: u16 = 4243u16; + assert_eq!(k.to_cw_bytes(), k.to_be_bytes()); + + let k: i16 = 4445i16; + assert_eq!(k.to_cw_bytes(), (k as u16 ^ 0x8000).to_be_bytes()); + + let k: i16 = -4748i16; + assert_eq!(k.to_cw_bytes(), (k as u16 ^ 0x8000).to_be_bytes()); + } + + #[test] + fn x32_int_key_works() { + let k: u32 = 424344u32; + assert_eq!(k.to_cw_bytes(), k.to_be_bytes()); + + let k: i32 = 454647i32; + assert_eq!(k.to_cw_bytes(), (k as u32 ^ 0x80000000).to_be_bytes()); + + let k: i32 = -484950i32; + assert_eq!(k.to_cw_bytes(), (k as u32 ^ 0x80000000).to_be_bytes()); + } + + #[test] + fn x64_int_key_works() { + let k: u64 = 42434445u64; + assert_eq!(k.to_cw_bytes(), k.to_be_bytes()); + + let k: i64 = 46474849i64; + assert_eq!( + k.to_cw_bytes(), + (k as u64 ^ 0x8000000000000000).to_be_bytes() + ); + + let k: i64 = -50515253i64; + assert_eq!( + k.to_cw_bytes(), + (k as u64 ^ 0x8000000000000000).to_be_bytes() + ); + } + + #[test] + fn x128_int_key_works() { + let k: u128 = 4243444546u128; + assert_eq!(k.to_cw_bytes(), k.to_be_bytes()); + + let k: i128 = 4748495051i128; + assert_eq!( + k.to_cw_bytes(), + (k as u128 ^ 0x80000000000000000000000000000000).to_be_bytes() + ); + + let k: i128 = -5253545556i128; + assert_eq!( + k.to_cw_bytes(), + (k as u128 ^ 0x80000000000000000000000000000000).to_be_bytes() + ); + } +} From a3d5c4ce3cef5ea26da58b029e12c6d196d0515b Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 16 Dec 2021 06:48:44 +0100 Subject: [PATCH 059/352] Add inline attribute to int key helpers --- packages/storage-plus/src/int_key.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs index 9aa85e9f9..70c558c9d 100644 --- a/packages/storage-plus/src/int_key.rs +++ b/packages/storage-plus/src/int_key.rs @@ -17,10 +17,12 @@ macro_rules! cw_uint_keys { $(impl CwIntKey for $t { type Buf = [u8; mem::size_of::<$t>()]; + #[inline] fn to_cw_bytes(&self) -> Self::Buf { self.to_be_bytes() } + #[inline] fn from_cw_bytes(bytes: Self::Buf) -> Self { Self::from_be_bytes(bytes) } @@ -35,10 +37,12 @@ macro_rules! cw_int_keys { $(impl CwIntKey for $t { type Buf = [u8; mem::size_of::<$t>()]; + #[inline] fn to_cw_bytes(&self) -> Self::Buf { (*self as $ut ^ <$t>::MIN as $ut).to_be_bytes() } + #[inline] fn from_cw_bytes(bytes: Self::Buf) -> Self { (Self::from_be_bytes(bytes) as $ut ^ <$t>::MIN as $ut) as _ } From 1e1f8c441065b588dc5f6f306431ab928252175d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 16 Dec 2021 11:27:57 +0100 Subject: [PATCH 060/352] Update TODO --- packages/storage-plus/src/int_key.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs index 70c558c9d..35c3cb69b 100644 --- a/packages/storage-plus/src/int_key.rs +++ b/packages/storage-plus/src/int_key.rs @@ -4,7 +4,7 @@ use std::mem; /// but "sign-flipped" (xored msb) big-endian bytes for signed ints. /// /// So that the representation of signed integers is in the right lexicographical order. -// TODO: Rename to `IntKey` when deprecating current `IntKey` +// TODO: Rename to `IntKey` after deprecating current `IntKey` (https://github.com/CosmWasm/cw-plus/issues/570) pub trait CwIntKey: Sized + Copy { type Buf: AsRef<[u8]> + AsMut<[u8]> + Into> + Default; From a993938f49c8a4cdba8ad84befd559bab6d57a67 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 16 Dec 2021 11:31:49 +0100 Subject: [PATCH 061/352] Clarify signed int keys format in tests --- packages/storage-plus/src/keys.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index ff318cde0..63bedba2e 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -626,7 +626,8 @@ mod test { assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); let pair: (i8, &[u8]) = (123, b"random"); - let one: Vec = vec![123 + 128]; + // Signed int keys are "sign-flipped" + let one: Vec = vec![123 ^ 0x80]; let two: Vec = b"random".to_vec(); assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); } @@ -639,7 +640,8 @@ mod test { assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); let pair: (i16, &[u8]) = (12345, b"random"); - let one: Vec = vec![48 + 128, 57]; + // Signed int keys are "sign-flipped" + let one: Vec = vec![48 ^ 0x80, 57]; let two: Vec = b"random".to_vec(); assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); } @@ -652,7 +654,9 @@ mod test { assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); let pair: (i64, &[u8]) = (12345, b"random"); - let one: Vec = vec![128, 0, 0, 0, 0, 0, 48, 57]; + // Signed int keys are "sign-flipped" + #[allow(clippy::identity_op)] + let one: Vec = vec![0 ^ 0x80, 0, 0, 0, 0, 0, 48, 57]; let two: Vec = b"random".to_vec(); assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); } From 7208d847535a76d182d4520a8d3f44ae5402c3e7 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 16 Dec 2021 22:57:53 +0100 Subject: [PATCH 062/352] Add signed int key range tests --- packages/storage-plus/src/map.rs | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index b85c69010..5bb9e91e5 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -265,6 +265,8 @@ mod test { const PEOPLE: Map<&[u8], Data> = Map::new("people"); #[cfg(feature = "iterator")] const PEOPLE_ID: Map = Map::new("people_id"); + #[cfg(feature = "iterator")] + const SIGNED_ID: Map = Map::new("signed_id"); const ALLOWANCE: Map<(&[u8], &[u8]), u64> = Map::new("allow"); @@ -570,6 +572,69 @@ mod test { assert_eq!(all, vec![(1234, data)]); } + #[test] + #[cfg(feature = "iterator")] + fn range_simple_signed_integer_key() { + let mut store = MockStorage::new(); + + // save and load on three keys + let data = Data { + name: "John".to_string(), + age: 32, + }; + SIGNED_ID.save(&mut store, -1234, &data).unwrap(); + + let data2 = Data { + name: "Jim".to_string(), + age: 44, + }; + SIGNED_ID.save(&mut store, -56, &data2).unwrap(); + + let data3 = Data { + name: "Jules".to_string(), + age: 55, + }; + SIGNED_ID.save(&mut store, 50, &data3).unwrap(); + + // let's try to iterate! + let all: StdResult> = SIGNED_ID + .range(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(3, all.len()); + // order is correct + assert_eq!( + all, + vec![(-1234, data), (-56, data2.clone()), (50, data3.clone())] + ); + + // let's try to iterate over a range + let all: StdResult> = SIGNED_ID + .range( + &store, + Some(Bound::inclusive_int(-56i32)), + None, + Order::Ascending, + ) + .collect(); + let all = all.unwrap(); + assert_eq!(2, all.len()); + assert_eq!(all, vec![(-56, data2), (50, data3.clone())]); + + // let's try to iterate over a more restrictive range + let all: StdResult> = SIGNED_ID + .range( + &store, + Some(Bound::inclusive_int(-55i32)), + Some(Bound::inclusive_int(50i32)), + Order::Descending, + ) + .collect(); + let all = all.unwrap(); + assert_eq!(1, all.len()); + assert_eq!(all, vec![(50, data3)]); + } + #[test] #[cfg(feature = "iterator")] fn range_raw_composite_key() { From c19c45ec5729284d9320eac8c48e475e8cb3ba10 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 17 Dec 2021 11:30:56 +0100 Subject: [PATCH 063/352] Use explicit expected results in tests --- packages/storage-plus/src/de.rs | 59 +++++++++++++++++---------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/packages/storage-plus/src/de.rs b/packages/storage-plus/src/de.rs index 6106aa088..6990518ee 100644 --- a/packages/storage-plus/src/de.rs +++ b/packages/storage-plus/src/de.rs @@ -233,57 +233,58 @@ mod test { #[test] fn deserialize_integer_works() { assert_eq!(>::from_slice(&[1]).unwrap(), 1u8); - assert_eq!( - >::from_slice(&[128]).unwrap(), - ((-1i8 << 7) as u8 ^ 0x80) as i8 - ); - assert_eq!( - >::from_slice(&[127]).unwrap(), - (127 ^ 0x80) as i8 - ); - assert_eq!(>::from_slice(&[1, 0]).unwrap(), 1u16 << 8); - assert_eq!( - >::from_slice(&[128, 0]).unwrap(), - ((-1i16 << 15) as u16 ^ 0x8000) as i16 - ); - assert_eq!( - >::from_slice(&[127, 255]).unwrap(), - (((1u16 << 15) - 1) ^ 0x8000) as i16 - ); + assert_eq!(>::from_slice(&[127]).unwrap(), -1i8); + assert_eq!(>::from_slice(&[128]).unwrap(), 0i8); + + assert_eq!(>::from_slice(&[1, 0]).unwrap(), 256u16); + assert_eq!(>::from_slice(&[128, 0]).unwrap(), 0i16); + assert_eq!(>::from_slice(&[127, 255]).unwrap(), -1i16); + assert_eq!( >::from_slice(&[1, 0, 0, 0]).unwrap(), - 1u32 << (3 * 8) - ); - assert_eq!( - >::from_slice(&[128, 0, 0, 0]).unwrap(), - ((-1i32 << 31) as u32 ^ 0x80000000) as i32 + 16777216u32 ); + assert_eq!(>::from_slice(&[128, 0, 0, 0]).unwrap(), 0i32); assert_eq!( >::from_slice(&[127, 255, 255, 255]).unwrap(), - (((1u32 << 31) - 1) ^ 0x80000000) as i32 + -1i32 ); + assert_eq!( >::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0]).unwrap(), - 1u64 << (7 * 8) + 72057594037927936u64 ); assert_eq!( >::from_slice(&[128, 0, 0, 0, 0, 0, 0, 0]).unwrap(), - ((-1i64 << 63) as u64 ^ 0x8000000000000000) as i64 + 0i64 ); assert_eq!( >::from_slice(&[127, 255, 255, 255, 255, 255, 255, 255]).unwrap(), - (((1u64 << 63) - 1) ^ 0x8000000000000000) as i64 + -1i64 ); + assert_eq!( >::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), - 1u128 << (15 * 8) + 1329227995784915872903807060280344576u128 + ); + assert_eq!( + >::from_slice(&[128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + .unwrap(), + 0i128 + ); + assert_eq!( + >::from_slice(&[ + 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 + ]) + .unwrap(), + -1i128 ); assert_eq!( >::from_slice(&[ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ]) .unwrap(), - (-1i128 as u128 ^ 0x80000000000000000000000000000000) as i128 + 170141183460469231731687303715884105727i128, ); } @@ -306,7 +307,7 @@ mod test { fn deserialize_timestamp_works() { assert_eq!( ::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0]).unwrap(), - 1u64 << (7 * 8) + 72057594037927936 ); } From 1548f22eb690e4d837fd0d713d54c5cccc05acf1 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 17 Dec 2021 11:31:51 +0100 Subject: [PATCH 064/352] Add naked int deserialization tests --- packages/storage-plus/src/de.rs | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/packages/storage-plus/src/de.rs b/packages/storage-plus/src/de.rs index 6990518ee..60f6fcb57 100644 --- a/packages/storage-plus/src/de.rs +++ b/packages/storage-plus/src/de.rs @@ -230,6 +230,54 @@ mod test { )); } + #[test] + fn deserialize_naked_integer_works() { + assert_eq!(u8::from_slice(&[1]).unwrap(), 1u8); + assert_eq!(i8::from_slice(&[127]).unwrap(), -1i8); + assert_eq!(i8::from_slice(&[128]).unwrap(), 0i8); + + assert_eq!(u16::from_slice(&[1, 0]).unwrap(), 256u16); + assert_eq!(i16::from_slice(&[128, 0]).unwrap(), 0i16); + assert_eq!(i16::from_slice(&[127, 255]).unwrap(), -1i16); + + assert_eq!(u32::from_slice(&[1, 0, 0, 0]).unwrap(), 16777216u32); + assert_eq!(i32::from_slice(&[128, 0, 0, 0]).unwrap(), 0i32); + assert_eq!(i32::from_slice(&[127, 255, 255, 255]).unwrap(), -1i32); + + assert_eq!( + u64::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0]).unwrap(), + 72057594037927936u64 + ); + assert_eq!(i64::from_slice(&[128, 0, 0, 0, 0, 0, 0, 0]).unwrap(), 0i64); + assert_eq!( + i64::from_slice(&[127, 255, 255, 255, 255, 255, 255, 255]).unwrap(), + -1i64 + ); + + assert_eq!( + u128::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), + 1329227995784915872903807060280344576u128 + ); + assert_eq!( + i128::from_slice(&[128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), + 0i128 + ); + assert_eq!( + i128::from_slice(&[ + 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 + ]) + .unwrap(), + -1i128 + ); + assert_eq!( + i128::from_slice(&[ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 + ]) + .unwrap(), + 170141183460469231731687303715884105727i128, + ); + } + #[test] fn deserialize_integer_works() { assert_eq!(>::from_slice(&[1]).unwrap(), 1u8); From fd84dcd2a084de12b9809532d9c24d12ddaaede2 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 17 Dec 2021 12:34:03 +0100 Subject: [PATCH 065/352] Use explicit expected results in int key tests --- packages/storage-plus/src/int_key.rs | 78 ++++++++++++---------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs index 35c3cb69b..e2633bb83 100644 --- a/packages/storage-plus/src/int_key.rs +++ b/packages/storage-plus/src/int_key.rs @@ -58,73 +58,63 @@ mod test { #[test] fn x8_int_key_works() { - let k: u8 = 42u8; - assert_eq!(k.to_cw_bytes(), k.to_be_bytes()); - - let k: i8 = 42i8; - assert_eq!(k.to_cw_bytes(), (k as u8 ^ 0x80).to_be_bytes()); - - let k: i8 = -42i8; - assert_eq!(k.to_cw_bytes(), (k as u8 ^ 0x80).to_be_bytes()); + assert_eq!(0x42u8.to_cw_bytes(), [0x42]); + assert_eq!(0x42i8.to_cw_bytes(), [0xc2]); + assert_eq!((-0x3ei8).to_cw_bytes(), [0x42]); } #[test] fn x16_int_key_works() { - let k: u16 = 4243u16; - assert_eq!(k.to_cw_bytes(), k.to_be_bytes()); - - let k: i16 = 4445i16; - assert_eq!(k.to_cw_bytes(), (k as u16 ^ 0x8000).to_be_bytes()); - - let k: i16 = -4748i16; - assert_eq!(k.to_cw_bytes(), (k as u16 ^ 0x8000).to_be_bytes()); + assert_eq!(0x4243u16.to_cw_bytes(), [0x42, 0x43]); + assert_eq!(0x4243i16.to_cw_bytes(), [0xc2, 0x43]); + assert_eq!((-0x3dbdi16).to_cw_bytes(), [0x42, 0x43]); } #[test] fn x32_int_key_works() { - let k: u32 = 424344u32; - assert_eq!(k.to_cw_bytes(), k.to_be_bytes()); - - let k: i32 = 454647i32; - assert_eq!(k.to_cw_bytes(), (k as u32 ^ 0x80000000).to_be_bytes()); - - let k: i32 = -484950i32; - assert_eq!(k.to_cw_bytes(), (k as u32 ^ 0x80000000).to_be_bytes()); + assert_eq!(0x424344u32.to_cw_bytes(), [0x00, 0x42, 0x43, 0x44]); + assert_eq!(0x424344i32.to_cw_bytes(), [0x80, 0x42, 0x43, 0x44]); + assert_eq!((-0x7fbdbcbci32).to_cw_bytes(), [0x00, 0x42, 0x43, 0x44]); } #[test] fn x64_int_key_works() { - let k: u64 = 42434445u64; - assert_eq!(k.to_cw_bytes(), k.to_be_bytes()); - - let k: i64 = 46474849i64; assert_eq!( - k.to_cw_bytes(), - (k as u64 ^ 0x8000000000000000).to_be_bytes() + 0x42434445u64.to_cw_bytes(), + [0x00, 0x00, 0x00, 0x00, 0x42, 0x43, 0x44, 0x45] + ); + assert_eq!( + 0x42434445i64.to_cw_bytes(), + [0x80, 0x00, 0x00, 0x00, 0x42, 0x43, 0x44, 0x45] ); - - let k: i64 = -50515253i64; assert_eq!( - k.to_cw_bytes(), - (k as u64 ^ 0x8000000000000000).to_be_bytes() + (-0x7fffffffbdbcbbbbi64).to_cw_bytes(), + [0x00, 0x00, 0x00, 0x00, 0x42, 0x43, 0x44, 0x45] ); } #[test] fn x128_int_key_works() { - let k: u128 = 4243444546u128; - assert_eq!(k.to_cw_bytes(), k.to_be_bytes()); - - let k: i128 = 4748495051i128; assert_eq!( - k.to_cw_bytes(), - (k as u128 ^ 0x80000000000000000000000000000000).to_be_bytes() + 0x4243444546u128.to_cw_bytes(), + [ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x43, 0x44, + 0x45, 0x46 + ] + ); + assert_eq!( + 0x4243444546i128.to_cw_bytes(), + [ + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x43, 0x44, + 0x45, 0x46 + ] ); - - let k: i128 = -5253545556i128; assert_eq!( - k.to_cw_bytes(), - (k as u128 ^ 0x80000000000000000000000000000000).to_be_bytes() + (-0x7fffffffffffffffffffffbdbcbbbabai128).to_cw_bytes(), + [ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x43, 0x44, + 0x45, 0x46 + ] ); } } From dcf66208de20e7af51c12f6049aa07555324f882 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 17 Dec 2021 12:41:20 +0100 Subject: [PATCH 066/352] Add unsigned / signed int keys order tests --- packages/storage-plus/src/int_key.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs index e2633bb83..7f7713369 100644 --- a/packages/storage-plus/src/int_key.rs +++ b/packages/storage-plus/src/int_key.rs @@ -117,4 +117,15 @@ mod test { ] ); } + + #[test] + fn unsigned_int_key_order() { + assert!(0u32.to_cw_bytes() < 652u32.to_cw_bytes()); + } + + #[test] + fn signed_int_key_order() { + assert!((-321i32).to_cw_bytes() < 0i32.to_cw_bytes()); + assert!(0i32.to_cw_bytes() < 652i32.to_cw_bytes()); + } } From 0afdefc1ffb110fafdcb4858230486dcc05d6a5c Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 5 Nov 2021 11:26:38 +0100 Subject: [PATCH 067/352] Make update_changelog use the latest version tag by default --- scripts/update_changelog.sh | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/scripts/update_changelog.sh b/scripts/update_changelog.sh index 62a17f520..09331e61e 100755 --- a/scripts/update_changelog.sh +++ b/scripts/update_changelog.sh @@ -2,29 +2,29 @@ ORIGINAL_OPTS=$* -OPTS=$(getopt -l "help,since-tag:,latest-tag,token:" -o "hlt" -- "$@") || exit 1 +OPTS=$(getopt -l "help,since-tag:,full,token:" -o "hft" -- "$@") || exit 1 eval set -- "$OPTS" while true do case $1 in -h|--help) - echo -e "Usage: $0 [-h|--help] [--since-tag ] [-l|--latest-tag] [-t|--token ] + echo -e "Usage: $0 [-h|--help] [-f|--full] [--since-tag ] [-t|--token ] -h, --help Display help ---since-tag Process changes since tag --l, --latest-tag Process changes since latest tag +-f, --full Process changes since the beginning (by default: since latest git version tag) +--since-tag Process changes since git version tag (by default: since latest git version tag) --token Pass changelog github token " exit 0 ;; ---since-tag) + --since-tag) shift TAG="$1" ;; --l|--latest-tag) - TAG=$(git tag --sort=creatordate | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | tail -1) - ORIGINAL_OPTS=$(echo "$ORIGINAL_OPTS" | sed "s/\\B$1\\b/--since-tag $TAG/") + -f|--full) + TAG="" + ORIGINAL_OPTS=$(echo "$ORIGINAL_OPTS" | sed "s/\\B$1\\b//") ;; ---) + --) shift break ;; @@ -32,8 +32,21 @@ esac shift done + +if [ -z "$TAG" ] +then + # Use latest git version tag + TAG=$(git tag --sort=creatordate | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | tail -1) + ORIGINAL_OPTS="$ORIGINAL_OPTS --since-tag $TAG" +fi + +echo "Git version tag: $TAG" + cp CHANGELOG.md /tmp/CHANGELOG.md.$$ -sed -i -n "/^## \\[$TAG\\]/,\$p" CHANGELOG.md +# Consolidate tag for matching changelog entries +TAG=$(echo "$TAG" | sed 's/-\([A-Za-z]*\)[^A-Za-z]*/-\1/') +echo "Consolidated tag: $TAG" +sed -i -n "/^## \\[${TAG}[^]]*\\]/,\$p" CHANGELOG.md github_changelog_generator -u CosmWasm -p cw-plus --base CHANGELOG.md $ORIGINAL_OPTS || cp /tmp/CHANGELOG.md.$$ CHANGELOG.md From 8a430d3da9027ead0df514e807e9620eb3e6fe03 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Tue, 21 Dec 2021 13:15:16 +0100 Subject: [PATCH 068/352] Update to cosmwasm 1.0.0-beta3 --- Cargo.lock | 80 ++++++++++++------------ contracts/cw1-subkeys/Cargo.toml | 4 +- contracts/cw1-whitelist-ng/Cargo.toml | 4 +- contracts/cw1-whitelist/Cargo.toml | 4 +- contracts/cw1155-base/Cargo.toml | 4 +- contracts/cw20-atomic-swap/Cargo.toml | 4 +- contracts/cw20-base/Cargo.toml | 4 +- contracts/cw20-bonding/Cargo.toml | 4 +- contracts/cw20-escrow/Cargo.toml | 4 +- contracts/cw20-ics20/Cargo.toml | 4 +- contracts/cw20-merkle-airdrop/Cargo.toml | 4 +- contracts/cw20-staking/Cargo.toml | 4 +- contracts/cw3-fixed-multisig/Cargo.toml | 4 +- contracts/cw3-flex-multisig/Cargo.toml | 4 +- contracts/cw4-group/Cargo.toml | 4 +- contracts/cw4-stake/Cargo.toml | 4 +- packages/controllers/Cargo.toml | 2 +- packages/cw1/Cargo.toml | 4 +- packages/cw1155/Cargo.toml | 4 +- packages/cw2/Cargo.toml | 2 +- packages/cw20/Cargo.toml | 4 +- packages/cw3/Cargo.toml | 4 +- packages/cw4/Cargo.toml | 4 +- packages/multi-test/Cargo.toml | 4 +- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 2 +- 26 files changed, 86 insertions(+), 86 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 295f5ee19..43fed7b8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "anyhow" -version = "1.0.45" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee10e43ae4a853c0a3591d4e2ada1719e553be18199d9da9d4a83f5927c2f5c7" +checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" dependencies = [ "backtrace", ] @@ -133,9 +133,9 @@ checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" [[package]] name = "cosmwasm-crypto" -version = "1.0.0-beta2" +version = "1.0.0-beta3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c16b255449b3f5cd7fa4b79acd5225b5185655261087a3d8aaac44f88a0e23e9" +checksum = "a380b87642204557629c9b72988c47b55fbfe6d474960adba56b22331504956a" dependencies = [ "digest 0.9.0", "ed25519-zebra", @@ -146,18 +146,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.0.0-beta2" +version = "1.0.0-beta3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abad1a6ff427a2f66890a4dce6354b4563cd07cee91a942300e011c921c09ed2" +checksum = "866713b2fe13f23038c7d8824c3059d1f28dd94685fb406d1533c4eeeefeefae" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.0.0-beta2" +version = "1.0.0-beta3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe52b19d45fe3f8359db6cc24df44dbe05e5ae32539afc0f5b7f790a21aa6fd0" +checksum = "818b928263c09a3269c2bed22494a62107a43ef87900e273af8ad2cb9f7e4440" dependencies = [ "schemars", "serde_json", @@ -165,9 +165,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.0.0-beta2" +version = "1.0.0-beta3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1660ee3d5734672e1eb4f0ceda403e2d83345e15143a48845f340f3252ce99a6" +checksum = "8dbb9939b31441dfa9af3ec9740c8a24d585688401eff1b6b386abb7ad0d10a8" dependencies = [ "base64", "cosmwasm-crypto", @@ -181,9 +181,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.0.0-beta2" +version = "1.0.0-beta3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3b4efe3b4f86df668520a02e9a29c23eea99b64dfcacb0e59b98346418af7f" +checksum = "b4a4e55f0d64fed54cd2202301b8d466af8de044589247dabd77a4222f52f749" dependencies = [ "cosmwasm-std", "serde", @@ -600,9 +600,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28e98c534e9c8a0483aa01d6f6913bc063de254311bd267c9cf535e9b70e15b2" +checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" dependencies = [ "const-oid", ] @@ -806,18 +806,18 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" dependencies = [ "either", ] [[package]] name = "itoa" -version = "0.4.8" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "k256" @@ -833,9 +833,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.107" +version = "0.2.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" [[package]] name = "memchr" @@ -895,9 +895,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" dependencies = [ "unicode-xid", ] @@ -954,9 +954,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353775f96a1f400edcca737f843cb201af3645912e741e64456a257c770173e8" +checksum = "71b5a9625a7e6060b23db692facf49082cc78889a7e6ac94a735356ae49db4b0" dependencies = [ "arrayvec", "num-traits", @@ -971,15 +971,15 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "schemars" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271ac0c667b8229adf70f0f957697c96fafd7486ab7481e15dc5e45e3e6a4368" +checksum = "c6b5a3c80cea1ab61f4260238409510e814e38b4b563c06044edf91e7dc070e3" dependencies = [ "dyn-clone", "schemars_derive", @@ -989,9 +989,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ebda811090b257411540779860bc09bf321bc587f58d2c5864309d1566214e7" +checksum = "41ae4dce13e8614c46ac3c38ef1c0d668b101df6ac39817aebdaa26642ddae9b" dependencies = [ "proc-macro2", "quote", @@ -1007,27 +1007,27 @@ checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "serde" -version = "1.0.130" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008" dependencies = [ "serde_derive", ] [[package]] name = "serde-json-wasm" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50eef3672ec8fa45f3457fd423ba131117786784a895548021976117c1ded449" +checksum = "042ac496d97e5885149d34139bad1d617192770d7eb8f1866da2317ff4501853" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.130" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276" dependencies = [ "proc-macro2", "quote", @@ -1047,9 +1047,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.70" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e277c495ac6cd1a01a58d0a0c574568b4d1ddf14f59965c6a58b8d96400b54f3" +checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" dependencies = [ "itoa", "ryu", @@ -1114,9 +1114,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" +checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" dependencies = [ "proc-macro2", "quote", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 37af477d8..acdc2d8db 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -23,7 +23,7 @@ utils = { path = "../../packages/utils", version = "0.10.3" } cw1 = { path = "../../packages/cw1", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.10.3", features = ["library"] } -cosmwasm-std = { version = "1.0.0-beta", features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = "1.0.23" semver = "1" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.10.3", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index 820636d96..e439b6264 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -25,7 +25,7 @@ multitest = ["cw-multi-test", "anyhow"] utils = { path = "../../packages/utils", version = "0.10.3" } cw1 = { path = "../../packages/cw1", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta", features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -36,6 +36,6 @@ anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index 524e9e3fc..22d7a9218 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -22,7 +22,7 @@ test-utils = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw1 = { path = "../../packages/cw1", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta", features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,6 +31,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] anyhow = "1" assert_matches = "1" -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 3dd077bbd..0e9859c4d 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -22,10 +22,10 @@ utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw1155 = { path = "../../packages/cw1155", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-atomic-swap/Cargo.toml b/contracts/cw20-atomic-swap/Cargo.toml index 99f82105a..7da558616 100644 --- a/contracts/cw20-atomic-swap/Cargo.toml +++ b/contracts/cw20-atomic-swap/Cargo.toml @@ -18,7 +18,7 @@ library = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw20 = { path = "../../packages/cw20", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -27,4 +27,4 @@ hex = "0.3.1" sha2 = "0.8.0" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index b0c3a6785..dbd87339a 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -22,10 +22,10 @@ utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw20 = { path = "../../packages/cw20", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-bonding/Cargo.toml b/contracts/cw20-bonding/Cargo.toml index 257d64fe5..4479a7f67 100644 --- a/contracts/cw20-bonding/Cargo.toml +++ b/contracts/cw20-bonding/Cargo.toml @@ -25,7 +25,7 @@ cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw20 = { path = "../../packages/cw20", version = "0.10.3" } cw20-base = { path = "../../contracts/cw20-base", version = "0.10.3", features = ["library"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta", default-features = false, features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta3", default-features = false, features = ["staking"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -34,4 +34,4 @@ integer-sqrt = { version = "0.1.5" } integer-cbrt = { version = "0.1.2" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-escrow/Cargo.toml b/contracts/cw20-escrow/Cargo.toml index 73ad16006..9727002a8 100644 --- a/contracts/cw20-escrow/Cargo.toml +++ b/contracts/cw20-escrow/Cargo.toml @@ -21,13 +21,13 @@ library = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw20 = { path = "../../packages/cw20", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3" } cw20-base = { path = "../cw20-base", version = "0.10.3", features = ["library"] } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 91b6f38f0..53443d2a7 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -21,11 +21,11 @@ library = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw20 = { path = "../../packages/cw20", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta", features = ["stargate"] } +cosmwasm-std = { version = "1.0.0-beta3", features = ["stargate"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-merkle-airdrop/Cargo.toml b/contracts/cw20-merkle-airdrop/Cargo.toml index 3fd176381..f9ef8cc9c 100644 --- a/contracts/cw20-merkle-airdrop/Cargo.toml +++ b/contracts/cw20-merkle-airdrop/Cargo.toml @@ -22,7 +22,7 @@ library = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw20 = { path = "../../packages/cw20", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ hex = "0.4" sha2 = { version = "0.9.5", default-features = false } [dev-dependencies] -cosmwasm-schema = "1.0.0-beta" +cosmwasm-schema = "1.0.0-beta3" serde_json = "1.0" diff --git a/contracts/cw20-staking/Cargo.toml b/contracts/cw20-staking/Cargo.toml index 75ba91acc..e3effd870 100644 --- a/contracts/cw20-staking/Cargo.toml +++ b/contracts/cw20-staking/Cargo.toml @@ -25,11 +25,11 @@ cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw20 = { path = "../../packages/cw20", version = "0.10.3" } cw-controllers = { path = "../../packages/controllers", version = "0.10.3" } cw20-base = { path = "../../contracts/cw20-base", version = "0.10.3", features = ["library"] } -cosmwasm-std = { version = "1.0.0-beta", features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index 2c5a917da..edab67af4 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -22,13 +22,13 @@ utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw3 = { path = "../../packages/cw3", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } cw20 = { path = "../../packages/cw20", version = "0.10.3" } cw20-base = { path = "../cw20-base", version = "0.10.3", features = ["library"] } cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 0d23ed746..d4d8e8608 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -23,12 +23,12 @@ cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw3 = { path = "../../packages/cw3", version = "0.10.3" } cw4 = { path = "../../packages/cw4", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } cw4-group = { path = "../cw4-group", version = "0.10.3" } cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index 76c9ef038..a4dc89f4b 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -31,10 +31,10 @@ cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw4 = { path = "../../packages/cw4", version = "0.10.3" } cw-controllers = { path = "../../packages/controllers", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index 1c07977e3..c07504e07 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -32,10 +32,10 @@ cw4 = { path = "../../packages/cw4", version = "0.10.3" } cw20 = { path = "../../packages/cw20", version = "0.10.3" } cw-controllers = { path = "../../packages/controllers", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index f41a29f16..5d99266c3 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -12,7 +12,7 @@ documentation = "https://docs.cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } utils = { path = "../utils", version = "0.10.3" } cw-storage-plus = { path = "../storage-plus", version = "0.10.3" } schemars = "0.8.1" diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index 8fdefaf8f..75b2bcdbf 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -10,9 +10,9 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 65a1ffc85..808ab5625 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] utils = { path = "../../packages/utils", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index d2e13ee6c..fc492461b 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0-beta", default-features = false } +cosmwasm-std = { version = "1.0.0-beta3", default-features = false } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index eb618d550..fd47608e4 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] utils = { path = "../../packages/utils", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index dc07798b6..1e483eac8 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] utils = { path = "../../packages/utils", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index 6c4329756..cd531b9da 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-storage-plus = { path = "../storage-plus", version = "0.10.3" } -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta" } +cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index 4199b1390..e2f7c0dfe 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -20,8 +20,8 @@ backtrace = ["anyhow/backtrace"] [dependencies] utils = { path = "../../packages/utils", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3"} -cosmwasm-std = { version = "1.0.0-beta", features = ["staking"] } -cosmwasm-storage = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } +cosmwasm-storage = { version = "1.0.0-beta3" } itertools = "0.10.1" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 2a6033b66..9635d6a49 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -14,6 +14,6 @@ default = ["iterator"] iterator = ["cosmwasm-std/iterator"] [dependencies] -cosmwasm-std = { version = "1.0.0-beta", default-features = false } +cosmwasm-std = { version = "1.0.0-beta3", default-features = false } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index 1254a7f2b..f0a2ecd3d 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -12,7 +12,7 @@ documentation = "https://docs.cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0-beta" } +cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } From 0783a93fe82167c8a2274644961758caab2cc63f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 21 Dec 2021 16:02:54 +0100 Subject: [PATCH 069/352] Remove schema outdated checks from CI --- .circleci/config.yml | 180 ------------------------------------------- 1 file changed, 180 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index de0e79fea..1965017e3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,15 +61,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -97,15 +88,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -133,15 +115,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -172,15 +145,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -208,15 +172,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -244,15 +199,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -280,15 +226,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -316,15 +253,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -352,15 +280,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -388,15 +307,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -424,15 +334,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -460,15 +361,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -496,15 +388,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -532,15 +415,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -568,15 +442,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure checked-in schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -655,15 +520,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -718,15 +574,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -755,15 +602,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -792,15 +630,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry @@ -829,15 +658,6 @@ jobs: - run: name: Build and run schema generator command: cargo schema --locked - - run: - name: Ensure schemas are up-to-date - command: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - save_cache: paths: - /usr/local/cargo/registry From f4282d8e5035275ffd69dc875da2a8ec97611522 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 21 Dec 2021 16:07:06 +0100 Subject: [PATCH 070/352] Add CI job to build and publish schemas on release tags --- .circleci/config.yml | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1965017e3..126a9c128 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,6 +38,12 @@ workflows: only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/ branches: ignore: /.*/ + - build_and_upload_schemas: + filters: + tags: + only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/ + branches: + ignore: /.*/ jobs: contract_cw1_subkeys: @@ -844,3 +850,49 @@ jobs: -n "$TITLE" -b "$BODY" \ -delete \ "$TAG" ./artifacts/ + + build_and_upload_schemas: + docker: + - image: rust:1.53.0 + working_directory: ~/project + steps: + - checkout: + path: ~/project + - run: + name: Create schemas directory + command: mkdir -p schemas + - run: + name: Install ghr + command: wget https://github.com/tcnksm/ghr/releases/download/v0.14.0/ghr_v0.14.0_linux_amd64.tar.gz -O - | tar -zxvf - -C /usr/local/bin --wildcards --strip-components 1 */ghr + - run: + name: Build and run schema generator for packages + command: | + for S in ./packages/*/examples/schema.rs + do + P=$(dirname $S)/.. + echo "Generating schema for $P ..." + (cd $P && cargo schema --locked && tar -zcf ~/project/schemas/$(basename $(pwd))_schema.tar.gz ./schema) + done + - run: + name: Build and run schema generator for contracts + command: | + for C in ./contracts/*/ + do + echo "Generating schema for $C ..." + (cd $C && cargo schema --locked && tar -zcf ~/project/schemas/$(basename $(pwd))_schema.tar.gz ./schema) + done + - run: + name: Show data + command: ls -l ./schemas + - run: + name: Publish schemas on GitHub + command: | + TAG="$CIRCLE_TAG" + TITLE="$TAG" + BODY="Attached there are some schemas and build artifacts generated at this tag. Those are for development purposes only! Please use crates.io to find the packages of this release." + ghr -t "$GITHUB_TOKEN" \ + -u "$CIRCLE_PROJECT_USERNAME" -r "$CIRCLE_PROJECT_REPONAME" \ + -c "$CIRCLE_SHA1" \ + -n "$TITLE" -b "$BODY" \ + -replace \ + "$TAG" ./schemas/ From 7ef7abcf35cec61ec4f9103b95b1cad81e4b91a2 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 21 Dec 2021 16:08:11 +0100 Subject: [PATCH 071/352] Remove package schemas from repo --- packages/cw1/schema/can_execute_response.json | 13 - packages/cw1/schema/execute_msg.json | 331 ----------- packages/cw1/schema/query_msg.json | 332 ----------- .../schema/approved_for_all_response.json | 97 ---- packages/cw1155/schema/balance_response.json | 19 - .../cw1155/schema/batch_balance_response.json | 22 - .../schema/cw1155_batch_receive_msg.json | 51 -- .../cw1155/schema/cw1155_execute_msg.json | 383 ------------- packages/cw1155/schema/cw1155_query_msg.json | 211 ------- .../cw1155/schema/cw1155_receive_msg.json | 44 -- .../schema/is_approved_for_all_response.json | 13 - .../cw1155/schema/token_info_response.json | 14 - packages/cw1155/schema/tokens_response.json | 17 - .../cw20/schema/all_accounts_response.json | 16 - .../cw20/schema/all_allowances_response.json | 99 ---- packages/cw20/schema/allowance_response.json | 81 --- packages/cw20/schema/balance_response.json | 19 - packages/cw20/schema/cw20_execute_msg.json | 442 --------------- packages/cw20/schema/cw20_query_msg.json | 168 ------ packages/cw20/schema/cw20_receive_msg.json | 32 -- .../cw20/schema/download_logo_response.json | 24 - .../cw20/schema/marketing_info_response.json | 73 --- packages/cw20/schema/minter_response.json | 30 - packages/cw20/schema/token_info_response.json | 33 -- packages/cw3/schema/execute_msg.json | 495 ---------------- .../cw3/schema/proposal_list_response.json | 527 ------------------ packages/cw3/schema/proposal_response.json | 513 ----------------- packages/cw3/schema/query_msg.json | 218 -------- packages/cw3/schema/threshold_response.json | 100 ---- packages/cw3/schema/vote_list_response.json | 49 -- packages/cw3/schema/vote_response.json | 50 -- packages/cw3/schema/voter_detail.json | 19 - packages/cw3/schema/voter_list_response.json | 35 -- packages/cw3/schema/voter_response.json | 15 - packages/cw4/schema/admin_response.json | 13 - packages/cw4/schema/cw4_execute_msg.json | 69 --- packages/cw4/schema/cw4_query_msg.json | 103 ---- .../cw4/schema/member_changed_hook_msg.json | 47 -- packages/cw4/schema/member_list_response.json | 36 -- packages/cw4/schema/member_response.json | 15 - .../cw4/schema/total_weight_response.json | 15 - 41 files changed, 4883 deletions(-) delete mode 100644 packages/cw1/schema/can_execute_response.json delete mode 100644 packages/cw1/schema/execute_msg.json delete mode 100644 packages/cw1/schema/query_msg.json delete mode 100644 packages/cw1155/schema/approved_for_all_response.json delete mode 100644 packages/cw1155/schema/balance_response.json delete mode 100644 packages/cw1155/schema/batch_balance_response.json delete mode 100644 packages/cw1155/schema/cw1155_batch_receive_msg.json delete mode 100644 packages/cw1155/schema/cw1155_execute_msg.json delete mode 100644 packages/cw1155/schema/cw1155_query_msg.json delete mode 100644 packages/cw1155/schema/cw1155_receive_msg.json delete mode 100644 packages/cw1155/schema/is_approved_for_all_response.json delete mode 100644 packages/cw1155/schema/token_info_response.json delete mode 100644 packages/cw1155/schema/tokens_response.json delete mode 100644 packages/cw20/schema/all_accounts_response.json delete mode 100644 packages/cw20/schema/all_allowances_response.json delete mode 100644 packages/cw20/schema/allowance_response.json delete mode 100644 packages/cw20/schema/balance_response.json delete mode 100644 packages/cw20/schema/cw20_execute_msg.json delete mode 100644 packages/cw20/schema/cw20_query_msg.json delete mode 100644 packages/cw20/schema/cw20_receive_msg.json delete mode 100644 packages/cw20/schema/download_logo_response.json delete mode 100644 packages/cw20/schema/marketing_info_response.json delete mode 100644 packages/cw20/schema/minter_response.json delete mode 100644 packages/cw20/schema/token_info_response.json delete mode 100644 packages/cw3/schema/execute_msg.json delete mode 100644 packages/cw3/schema/proposal_list_response.json delete mode 100644 packages/cw3/schema/proposal_response.json delete mode 100644 packages/cw3/schema/query_msg.json delete mode 100644 packages/cw3/schema/threshold_response.json delete mode 100644 packages/cw3/schema/vote_list_response.json delete mode 100644 packages/cw3/schema/vote_response.json delete mode 100644 packages/cw3/schema/voter_detail.json delete mode 100644 packages/cw3/schema/voter_list_response.json delete mode 100644 packages/cw3/schema/voter_response.json delete mode 100644 packages/cw4/schema/admin_response.json delete mode 100644 packages/cw4/schema/cw4_execute_msg.json delete mode 100644 packages/cw4/schema/cw4_query_msg.json delete mode 100644 packages/cw4/schema/member_changed_hook_msg.json delete mode 100644 packages/cw4/schema/member_list_response.json delete mode 100644 packages/cw4/schema/member_response.json delete mode 100644 packages/cw4/schema/total_weight_response.json diff --git a/packages/cw1/schema/can_execute_response.json b/packages/cw1/schema/can_execute_response.json deleted file mode 100644 index a11bb1c17..000000000 --- a/packages/cw1/schema/can_execute_response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "CanExecuteResponse", - "type": "object", - "required": [ - "can_execute" - ], - "properties": { - "can_execute": { - "type": "boolean" - } - } -} diff --git a/packages/cw1/schema/execute_msg.json b/packages/cw1/schema/execute_msg.json deleted file mode 100644 index f5d5419e2..000000000 --- a/packages/cw1/schema/execute_msg.json +++ /dev/null @@ -1,331 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "description": "Execute requests the contract to re-dispatch all these messages with the contract's address as sender. Every implementation has it's own logic to determine in", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "msgs" - ], - "properties": { - "msgs": { - "type": "array", - "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - } - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/packages/cw1/schema/query_msg.json b/packages/cw1/schema/query_msg.json deleted file mode 100644 index dd699df25..000000000 --- a/packages/cw1/schema/query_msg.json +++ /dev/null @@ -1,332 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Checks permissions of the caller on this proxy. If CanExecute returns true then a call to `Execute` with the same message, from the given sender, before any further state changes, should also succeed.", - "type": "object", - "required": [ - "can_execute" - ], - "properties": { - "can_execute": { - "type": "object", - "required": [ - "msg", - "sender" - ], - "properties": { - "msg": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - }, - "sender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/packages/cw1155/schema/approved_for_all_response.json b/packages/cw1155/schema/approved_for_all_response.json deleted file mode 100644 index 453f17b7c..000000000 --- a/packages/cw1155/schema/approved_for_all_response.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ApprovedForAllResponse", - "type": "object", - "required": [ - "operators" - ], - "properties": { - "operators": { - "type": "array", - "items": { - "$ref": "#/definitions/Approval" - } - } - }, - "definitions": { - "Approval": { - "type": "object", - "required": [ - "expires", - "spender" - ], - "properties": { - "expires": { - "description": "When the Approval expires (maybe Expiration::never)", - "allOf": [ - { - "$ref": "#/definitions/Expiration" - } - ] - }, - "spender": { - "description": "Account that can transfer/send the token", - "type": "string" - } - } - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw1155/schema/balance_response.json b/packages/cw1155/schema/balance_response.json deleted file mode 100644 index 4e1a0be2b..000000000 --- a/packages/cw1155/schema/balance_response.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BalanceResponse", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw1155/schema/batch_balance_response.json b/packages/cw1155/schema/batch_balance_response.json deleted file mode 100644 index 39c8bd040..000000000 --- a/packages/cw1155/schema/batch_balance_response.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BatchBalanceResponse", - "type": "object", - "required": [ - "balances" - ], - "properties": { - "balances": { - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw1155/schema/cw1155_batch_receive_msg.json b/packages/cw1155/schema/cw1155_batch_receive_msg.json deleted file mode 100644 index 39820287c..000000000 --- a/packages/cw1155/schema/cw1155_batch_receive_msg.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw1155BatchReceiveMsg", - "description": "Cw1155BatchReceiveMsg should be de/serialized under `BatchReceive()` variant in a ExecuteMsg", - "type": "object", - "required": [ - "batch", - "msg", - "operator" - ], - "properties": { - "batch": { - "type": "array", - "items": { - "type": "array", - "items": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/Uint128" - } - ], - "maxItems": 2, - "minItems": 2 - } - }, - "from": { - "type": [ - "string", - "null" - ] - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "operator": { - "type": "string" - } - }, - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw1155/schema/cw1155_execute_msg.json b/packages/cw1155/schema/cw1155_execute_msg.json deleted file mode 100644 index 41ebe3020..000000000 --- a/packages/cw1155/schema/cw1155_execute_msg.json +++ /dev/null @@ -1,383 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw1155ExecuteMsg", - "oneOf": [ - { - "description": "SendFrom is a base message to move tokens, if `env.sender` is the owner or has sufficient pre-approval.", - "type": "object", - "required": [ - "send_from" - ], - "properties": { - "send_from": { - "type": "object", - "required": [ - "from", - "to", - "token_id", - "value" - ], - "properties": { - "from": { - "type": "string" - }, - "msg": { - "description": "`None` means don't call the receiver interface", - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - }, - "to": { - "description": "If `to` is not contract, `msg` should be `None`", - "type": "string" - }, - "token_id": { - "type": "string" - }, - "value": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "BatchSendFrom is a base message to move multiple types of tokens in batch, if `env.sender` is the owner or has sufficient pre-approval.", - "type": "object", - "required": [ - "batch_send_from" - ], - "properties": { - "batch_send_from": { - "type": "object", - "required": [ - "batch", - "from", - "to" - ], - "properties": { - "batch": { - "type": "array", - "items": { - "type": "array", - "items": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/Uint128" - } - ], - "maxItems": 2, - "minItems": 2 - } - }, - "from": { - "type": "string" - }, - "msg": { - "description": "`None` means don't call the receiver interface", - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - }, - "to": { - "description": "if `to` is not contract, `msg` should be `None`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Mint is a base message to mint tokens.", - "type": "object", - "required": [ - "mint" - ], - "properties": { - "mint": { - "type": "object", - "required": [ - "to", - "token_id", - "value" - ], - "properties": { - "msg": { - "description": "`None` means don't call the receiver interface", - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - }, - "to": { - "description": "If `to` is not contract, `msg` should be `None`", - "type": "string" - }, - "token_id": { - "type": "string" - }, - "value": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "BatchMint is a base message to mint multiple types of tokens in batch.", - "type": "object", - "required": [ - "batch_mint" - ], - "properties": { - "batch_mint": { - "type": "object", - "required": [ - "batch", - "to" - ], - "properties": { - "batch": { - "type": "array", - "items": { - "type": "array", - "items": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/Uint128" - } - ], - "maxItems": 2, - "minItems": 2 - } - }, - "msg": { - "description": "`None` means don't call the receiver interface", - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - }, - "to": { - "description": "If `to` is not contract, `msg` should be `None`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Burn is a base message to burn tokens.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "from", - "token_id", - "value" - ], - "properties": { - "from": { - "type": "string" - }, - "token_id": { - "type": "string" - }, - "value": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "BatchBurn is a base message to burn multiple types of tokens in batch.", - "type": "object", - "required": [ - "batch_burn" - ], - "properties": { - "batch_burn": { - "type": "object", - "required": [ - "batch", - "from" - ], - "properties": { - "batch": { - "type": "array", - "items": { - "type": "array", - "items": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/Uint128" - } - ], - "maxItems": 2, - "minItems": 2 - } - }, - "from": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Allows operator to transfer / send any token from the owner's account. If expiration is set, then this allowance has a time/height limit", - "type": "object", - "required": [ - "approve_all" - ], - "properties": { - "approve_all": { - "type": "object", - "required": [ - "operator" - ], - "properties": { - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "operator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Remove previously granted ApproveAll permission", - "type": "object", - "required": [ - "revoke_all" - ], - "properties": { - "revoke_all": { - "type": "object", - "required": [ - "operator" - ], - "properties": { - "operator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw1155/schema/cw1155_query_msg.json b/packages/cw1155/schema/cw1155_query_msg.json deleted file mode 100644 index fa4282450..000000000 --- a/packages/cw1155/schema/cw1155_query_msg.json +++ /dev/null @@ -1,211 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw1155QueryMsg", - "oneOf": [ - { - "description": "Returns the current balance of the given address, 0 if unset. Return type: BalanceResponse.", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "type": "object", - "required": [ - "owner", - "token_id" - ], - "properties": { - "owner": { - "type": "string" - }, - "token_id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns the current balance of the given address for a batch of tokens, 0 if unset. Return type: BatchBalanceResponse.", - "type": "object", - "required": [ - "batch_balance" - ], - "properties": { - "batch_balance": { - "type": "object", - "required": [ - "owner", - "token_ids" - ], - "properties": { - "owner": { - "type": "string" - }, - "token_ids": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - }, - "additionalProperties": false - }, - { - "description": "List all operators that can access all of the owner's tokens. Return type: ApprovedForAllResponse.", - "type": "object", - "required": [ - "approved_for_all" - ], - "properties": { - "approved_for_all": { - "type": "object", - "required": [ - "owner" - ], - "properties": { - "include_expired": { - "description": "unset or false will filter out expired approvals, you must set to true to see them", - "type": [ - "boolean", - "null" - ] - }, - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "owner": { - "type": "string" - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Query approved status `owner` granted to `operator`. Return type: IsApprovedForAllResponse", - "type": "object", - "required": [ - "is_approved_for_all" - ], - "properties": { - "is_approved_for_all": { - "type": "object", - "required": [ - "operator", - "owner" - ], - "properties": { - "operator": { - "type": "string" - }, - "owner": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "With MetaData Extension. Query metadata of token Return type: TokenInfoResponse.", - "type": "object", - "required": [ - "token_info" - ], - "properties": { - "token_info": { - "type": "object", - "required": [ - "token_id" - ], - "properties": { - "token_id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "With Enumerable extension. Returns all tokens owned by the given address, [] if unset. Return type: TokensResponse.", - "type": "object", - "required": [ - "tokens" - ], - "properties": { - "tokens": { - "type": "object", - "required": [ - "owner" - ], - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "owner": { - "type": "string" - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "With Enumerable extension. Requires pagination. Lists all token_ids controlled by the contract. Return type: TokensResponse.", - "type": "object", - "required": [ - "all_tokens" - ], - "properties": { - "all_tokens": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/packages/cw1155/schema/cw1155_receive_msg.json b/packages/cw1155/schema/cw1155_receive_msg.json deleted file mode 100644 index 1bf693cec..000000000 --- a/packages/cw1155/schema/cw1155_receive_msg.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw1155ReceiveMsg", - "description": "Cw1155ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg", - "type": "object", - "required": [ - "amount", - "msg", - "operator", - "token_id" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "from": { - "description": "The account that the token transfered from", - "type": [ - "string", - "null" - ] - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "operator": { - "description": "The account that executed the send message", - "type": "string" - }, - "token_id": { - "type": "string" - } - }, - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw1155/schema/is_approved_for_all_response.json b/packages/cw1155/schema/is_approved_for_all_response.json deleted file mode 100644 index e3af7a983..000000000 --- a/packages/cw1155/schema/is_approved_for_all_response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "IsApprovedForAllResponse", - "type": "object", - "required": [ - "approved" - ], - "properties": { - "approved": { - "type": "boolean" - } - } -} diff --git a/packages/cw1155/schema/token_info_response.json b/packages/cw1155/schema/token_info_response.json deleted file mode 100644 index a94af98e3..000000000 --- a/packages/cw1155/schema/token_info_response.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TokenInfoResponse", - "type": "object", - "required": [ - "url" - ], - "properties": { - "url": { - "description": "Should be a url point to a json file", - "type": "string" - } - } -} diff --git a/packages/cw1155/schema/tokens_response.json b/packages/cw1155/schema/tokens_response.json deleted file mode 100644 index b8e3d75b5..000000000 --- a/packages/cw1155/schema/tokens_response.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TokensResponse", - "type": "object", - "required": [ - "tokens" - ], - "properties": { - "tokens": { - "description": "Contains all token_ids in lexicographical ordering If there are more than `limit`, use `start_from` in future queries to achieve pagination.", - "type": "array", - "items": { - "type": "string" - } - } - } -} diff --git a/packages/cw20/schema/all_accounts_response.json b/packages/cw20/schema/all_accounts_response.json deleted file mode 100644 index cea50fba4..000000000 --- a/packages/cw20/schema/all_accounts_response.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AllAccountsResponse", - "type": "object", - "required": [ - "accounts" - ], - "properties": { - "accounts": { - "type": "array", - "items": { - "type": "string" - } - } - } -} diff --git a/packages/cw20/schema/all_allowances_response.json b/packages/cw20/schema/all_allowances_response.json deleted file mode 100644 index 6bb2291ce..000000000 --- a/packages/cw20/schema/all_allowances_response.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AllAllowancesResponse", - "type": "object", - "required": [ - "allowances" - ], - "properties": { - "allowances": { - "type": "array", - "items": { - "$ref": "#/definitions/AllowanceInfo" - } - } - }, - "definitions": { - "AllowanceInfo": { - "type": "object", - "required": [ - "allowance", - "expires", - "spender" - ], - "properties": { - "allowance": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "$ref": "#/definitions/Expiration" - }, - "spender": { - "type": "string" - } - } - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw20/schema/allowance_response.json b/packages/cw20/schema/allowance_response.json deleted file mode 100644 index c4f98d6fc..000000000 --- a/packages/cw20/schema/allowance_response.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AllowanceResponse", - "type": "object", - "required": [ - "allowance", - "expires" - ], - "properties": { - "allowance": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "$ref": "#/definitions/Expiration" - } - }, - "definitions": { - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw20/schema/balance_response.json b/packages/cw20/schema/balance_response.json deleted file mode 100644 index 4e1a0be2b..000000000 --- a/packages/cw20/schema/balance_response.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BalanceResponse", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw20/schema/cw20_execute_msg.json b/packages/cw20/schema/cw20_execute_msg.json deleted file mode 100644 index e4bc559cd..000000000 --- a/packages/cw20/schema/cw20_execute_msg.json +++ /dev/null @@ -1,442 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw20ExecuteMsg", - "oneOf": [ - { - "description": "Transfer is a base message to move tokens to another account without triggering actions", - "type": "object", - "required": [ - "transfer" - ], - "properties": { - "transfer": { - "type": "object", - "required": [ - "amount", - "recipient" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "recipient": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Burn is a base message to destroy tokens forever", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Send is a base message to transfer tokens to a contract and trigger an action on the receiving contract.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "contract", - "msg" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "contract": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"approval\" extension. Allows spender to access an additional amount tokens from the owner's (env.sender) account. If expires is Some(), overwrites current allowance expiration with this one.", - "type": "object", - "required": [ - "increase_allowance" - ], - "properties": { - "increase_allowance": { - "type": "object", - "required": [ - "amount", - "spender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"approval\" extension. Lowers the spender's access of tokens from the owner's (env.sender) account by amount. If expires is Some(), overwrites current allowance expiration with this one.", - "type": "object", - "required": [ - "decrease_allowance" - ], - "properties": { - "decrease_allowance": { - "type": "object", - "required": [ - "amount", - "spender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"approval\" extension. Transfers amount tokens from owner -> recipient if `env.sender` has sufficient pre-approval.", - "type": "object", - "required": [ - "transfer_from" - ], - "properties": { - "transfer_from": { - "type": "object", - "required": [ - "amount", - "owner", - "recipient" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "owner": { - "type": "string" - }, - "recipient": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"approval\" extension. Sends amount tokens from owner -> contract if `env.sender` has sufficient pre-approval.", - "type": "object", - "required": [ - "send_from" - ], - "properties": { - "send_from": { - "type": "object", - "required": [ - "amount", - "contract", - "msg", - "owner" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "contract": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "owner": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"approval\" extension. Destroys tokens forever", - "type": "object", - "required": [ - "burn_from" - ], - "properties": { - "burn_from": { - "type": "object", - "required": [ - "amount", - "owner" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "owner": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with the \"mintable\" extension. If authorized, creates amount new tokens and adds to the recipient balance.", - "type": "object", - "required": [ - "mint" - ], - "properties": { - "mint": { - "type": "object", - "required": [ - "amount", - "recipient" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "recipient": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with the \"marketing\" extension. If authorized, updates marketing metadata. Setting None/null for any of these will leave it unchanged. Setting Some(\"\") will clear this field on the contract storage", - "type": "object", - "required": [ - "update_marketing" - ], - "properties": { - "update_marketing": { - "type": "object", - "properties": { - "description": { - "description": "A longer description of the token and it's utility. Designed for tooltips or such", - "type": [ - "string", - "null" - ] - }, - "marketing": { - "description": "The address (if any) who can update this data structure", - "type": [ - "string", - "null" - ] - }, - "project": { - "description": "A URL pointing to the project behind this token.", - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "If set as the \"marketing\" role on the contract, upload a new URL, SVG, or PNG for the token", - "type": "object", - "required": [ - "upload_logo" - ], - "properties": { - "upload_logo": { - "$ref": "#/definitions/Logo" - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "EmbeddedLogo": { - "description": "This is used to store the logo on the blockchain in an accepted format. Enforce maximum size of 5KB on all variants.", - "oneOf": [ - { - "description": "Store the Logo as an SVG file. The content must conform to the spec at https://en.wikipedia.org/wiki/Scalable_Vector_Graphics (The contract should do some light-weight sanity-check validation)", - "type": "object", - "required": [ - "svg" - ], - "properties": { - "svg": { - "$ref": "#/definitions/Binary" - } - }, - "additionalProperties": false - }, - { - "description": "Store the Logo as a PNG file. This will likely only support up to 64x64 or so within the 5KB limit.", - "type": "object", - "required": [ - "png" - ], - "properties": { - "png": { - "$ref": "#/definitions/Binary" - } - }, - "additionalProperties": false - } - ] - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Logo": { - "description": "This is used for uploading logo data, or setting it in InstantiateData", - "oneOf": [ - { - "description": "A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL.", - "type": "object", - "required": [ - "url" - ], - "properties": { - "url": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "description": "Logo content stored on the blockchain. Enforce maximum size of 5KB on all variants", - "type": "object", - "required": [ - "embedded" - ], - "properties": { - "embedded": { - "$ref": "#/definitions/EmbeddedLogo" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw20/schema/cw20_query_msg.json b/packages/cw20/schema/cw20_query_msg.json deleted file mode 100644 index 2dbeb2914..000000000 --- a/packages/cw20/schema/cw20_query_msg.json +++ /dev/null @@ -1,168 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw20QueryMsg", - "oneOf": [ - { - "description": "Returns the current balance of the given address, 0 if unset. Return type: BalanceResponse.", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns metadata on the contract - name, decimals, supply, etc. Return type: TokenInfoResponse.", - "type": "object", - "required": [ - "token_info" - ], - "properties": { - "token_info": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"allowance\" extension. Returns how much spender can use from owner account, 0 if unset. Return type: AllowanceResponse.", - "type": "object", - "required": [ - "allowance" - ], - "properties": { - "allowance": { - "type": "object", - "required": [ - "owner", - "spender" - ], - "properties": { - "owner": { - "type": "string" - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"mintable\" extension. Returns who can mint and the hard cap on maximum tokens after minting. Return type: MinterResponse.", - "type": "object", - "required": [ - "minter" - ], - "properties": { - "minter": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"marketing\" extension Returns more metadata on the contract to display in the client: - description, logo, project url, etc. Return type: MarketingInfoResponse.", - "type": "object", - "required": [ - "marketing_info" - ], - "properties": { - "marketing_info": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"marketing\" extension Downloads the embedded logo data (if stored on chain). Errors if no logo data stored for this contract. Return type: DownloadLogoResponse.", - "type": "object", - "required": [ - "download_logo" - ], - "properties": { - "download_logo": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"enumerable\" extension (and \"allowances\") Returns all allowances this owner has approved. Supports pagination. Return type: AllAllowancesResponse.", - "type": "object", - "required": [ - "all_allowances" - ], - "properties": { - "all_allowances": { - "type": "object", - "required": [ - "owner" - ], - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "owner": { - "type": "string" - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"enumerable\" extension Returns all accounts that have balances. Supports pagination. Return type: AllAccountsResponse.", - "type": "object", - "required": [ - "all_accounts" - ], - "properties": { - "all_accounts": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/packages/cw20/schema/cw20_receive_msg.json b/packages/cw20/schema/cw20_receive_msg.json deleted file mode 100644 index e06a24584..000000000 --- a/packages/cw20/schema/cw20_receive_msg.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw20ReceiveMsg", - "description": "Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg", - "type": "object", - "required": [ - "amount", - "msg", - "sender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "sender": { - "type": "string" - } - }, - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw20/schema/download_logo_response.json b/packages/cw20/schema/download_logo_response.json deleted file mode 100644 index a4bac1f5c..000000000 --- a/packages/cw20/schema/download_logo_response.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "DownloadLogoResponse", - "description": "When we download an embedded logo, we get this response type. We expect a SPA to be able to accept this info and display it.", - "type": "object", - "required": [ - "data", - "mime_type" - ], - "properties": { - "data": { - "$ref": "#/definitions/Binary" - }, - "mime_type": { - "type": "string" - } - }, - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - } - } -} diff --git a/packages/cw20/schema/marketing_info_response.json b/packages/cw20/schema/marketing_info_response.json deleted file mode 100644 index 616d00de8..000000000 --- a/packages/cw20/schema/marketing_info_response.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MarketingInfoResponse", - "type": "object", - "properties": { - "description": { - "description": "A longer description of the token and it's utility. Designed for tooltips or such", - "type": [ - "string", - "null" - ] - }, - "logo": { - "description": "A link to the logo, or a comment there is an on-chain logo stored", - "anyOf": [ - { - "$ref": "#/definitions/LogoInfo" - }, - { - "type": "null" - } - ] - }, - "marketing": { - "description": "The address (if any) who can update this data structure", - "anyOf": [ - { - "$ref": "#/definitions/Addr" - }, - { - "type": "null" - } - ] - }, - "project": { - "description": "A URL pointing to the project behind this token.", - "type": [ - "string", - "null" - ] - } - }, - "definitions": { - "Addr": { - "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", - "type": "string" - }, - "LogoInfo": { - "description": "This is used to display logo info, provide a link or inform there is one that can be downloaded from the blockchain itself", - "oneOf": [ - { - "type": "string", - "enum": [ - "embedded" - ] - }, - { - "description": "A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL.", - "type": "object", - "required": [ - "url" - ], - "properties": { - "url": { - "type": "string" - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/packages/cw20/schema/minter_response.json b/packages/cw20/schema/minter_response.json deleted file mode 100644 index a05f8fd58..000000000 --- a/packages/cw20/schema/minter_response.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MinterResponse", - "type": "object", - "required": [ - "minter" - ], - "properties": { - "cap": { - "description": "cap is a hard cap on total supply that can be achieved by minting. Note that this refers to total_supply. If None, there is unlimited cap.", - "anyOf": [ - { - "$ref": "#/definitions/Uint128" - }, - { - "type": "null" - } - ] - }, - "minter": { - "type": "string" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw20/schema/token_info_response.json b/packages/cw20/schema/token_info_response.json deleted file mode 100644 index 9920c841f..000000000 --- a/packages/cw20/schema/token_info_response.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TokenInfoResponse", - "type": "object", - "required": [ - "decimals", - "name", - "symbol", - "total_supply" - ], - "properties": { - "decimals": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "name": { - "type": "string" - }, - "symbol": { - "type": "string" - }, - "total_supply": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/packages/cw3/schema/execute_msg.json b/packages/cw3/schema/execute_msg.json deleted file mode 100644 index 896d2c86f..000000000 --- a/packages/cw3/schema/execute_msg.json +++ /dev/null @@ -1,495 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "propose" - ], - "properties": { - "propose": { - "type": "object", - "required": [ - "description", - "msgs", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "earliest": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "latest": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "msgs": { - "type": "array", - "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - } - }, - "title": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "vote" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "vote": { - "$ref": "#/definitions/Vote" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "close" - ], - "properties": { - "close": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - }, - "Vote": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "veto" - ] - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/packages/cw3/schema/proposal_list_response.json b/packages/cw3/schema/proposal_list_response.json deleted file mode 100644 index c14db0eb4..000000000 --- a/packages/cw3/schema/proposal_list_response.json +++ /dev/null @@ -1,527 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ProposalListResponse", - "type": "object", - "required": [ - "proposals" - ], - "properties": { - "proposals": { - "type": "array", - "items": { - "$ref": "#/definitions/ProposalResponse_for_Empty" - } - } - }, - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "ProposalResponse_for_Empty": { - "description": "Note, if you are storing custom messages in the proposal, the querier needs to know what possible custom message types those are in order to parse the response", - "type": "object", - "required": [ - "description", - "expires", - "id", - "msgs", - "status", - "threshold", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "expires": { - "$ref": "#/definitions/Expiration" - }, - "id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "msgs": { - "type": "array", - "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - } - }, - "status": { - "$ref": "#/definitions/Status" - }, - "threshold": { - "description": "This is the threshold that is applied to this proposal. Both the rules of the voting contract, as well as the total_weight of the voting group may have changed since this time. That means that the generic `Threshold{}` query does not provide valid information for existing proposals.", - "allOf": [ - { - "$ref": "#/definitions/ThresholdResponse" - } - ] - }, - "title": { - "type": "string" - } - } - }, - "Status": { - "type": "string", - "enum": [ - "pending", - "open", - "rejected", - "passed", - "executed" - ] - }, - "ThresholdResponse": { - "description": "This defines the different ways tallies can happen. Every contract should support a subset of these, ideally all.\n\nThe total_weight used for calculating success as well as the weights of each individual voter used in tallying should be snapshotted at the beginning of the block at which the proposal starts (this is likely the responsibility of a correct cw4 implementation).", - "oneOf": [ - { - "description": "Declares that a fixed weight of yes votes is needed to pass. It does not matter how many no votes are cast, or how many do not vote, as long as `weight` yes votes are cast.\n\nThis is the simplest format and usually suitable for small multisigs of trusted parties, like 3 of 5. (weight: 3, total_weight: 5)\n\nA proposal of this type can pass early as soon as the needed weight of yes votes has been cast.", - "type": "object", - "required": [ - "absolute_count" - ], - "properties": { - "absolute_count": { - "type": "object", - "required": [ - "total_weight", - "weight" - ], - "properties": { - "total_weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Declares a percentage of the total weight that must cast Yes votes, in order for a proposal to pass. The passing weight is computed over the total weight minus the weight of the abstained votes.\n\nThis is useful for similar circumstances as `AbsoluteCount`, where we have a relatively small set of voters, and participation is required. It is understood that if the voting set (group) changes between different proposals that refer to the same group, each proposal will work with a different set of voter weights (the ones snapshotted at proposal creation), and the passing weight for each proposal will be computed based on the absolute percentage, times the total weights of the members at the time of each proposal creation.\n\nExample: we set `percentage` to 51%. Proposal 1 starts when there is a `total_weight` of 5. This will require 3 weight of Yes votes in order to pass. Later, the Proposal 2 starts but the `total_weight` of the group has increased to 9. That proposal will then automatically require 5 Yes of 9 to pass, rather than 3 yes of 9 as would be the case with `AbsoluteCount`.", - "type": "object", - "required": [ - "absolute_percentage" - ], - "properties": { - "absolute_percentage": { - "type": "object", - "required": [ - "percentage", - "total_weight" - ], - "properties": { - "percentage": { - "$ref": "#/definitions/Decimal" - }, - "total_weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "In addition to a `threshold`, declares a `quorum` of the total votes that must participate in the election in order for the vote to be considered at all. Within the votes that were cast, it requires `threshold` votes in favor. That is calculated by ignoring the Abstain votes (they count towards `quorum`, but do not influence `threshold`). That is, we calculate `Yes / (Yes + No + Veto)` and compare it with `threshold` to consider if the proposal was passed.\n\nIt is rather difficult for a proposal of this type to pass early. That can only happen if the required quorum has been already met, and there are already enough Yes votes for the proposal to pass.\n\n30% Yes votes, 10% No votes, and 20% Abstain would pass early if quorum <= 60% (who has cast votes) and if the threshold is <= 37.5% (the remaining 40% voting no => 30% yes + 50% no). Once the voting period has passed with no additional votes, that same proposal would be considered successful if quorum <= 60% and threshold <= 75% (percent in favor if we ignore abstain votes).\n\nThis type is more common in general elections, where participation is often expected to be low, and `AbsolutePercentage` would either be too high to pass anything, or allow low percentages to pass, independently of if there was high participation in the election or not.", - "type": "object", - "required": [ - "threshold_quorum" - ], - "properties": { - "threshold_quorum": { - "type": "object", - "required": [ - "quorum", - "threshold", - "total_weight" - ], - "properties": { - "quorum": { - "$ref": "#/definitions/Decimal" - }, - "threshold": { - "$ref": "#/definitions/Decimal" - }, - "total_weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/packages/cw3/schema/proposal_response.json b/packages/cw3/schema/proposal_response.json deleted file mode 100644 index 42acdea03..000000000 --- a/packages/cw3/schema/proposal_response.json +++ /dev/null @@ -1,513 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ProposalResponse", - "description": "Note, if you are storing custom messages in the proposal, the querier needs to know what possible custom message types those are in order to parse the response", - "type": "object", - "required": [ - "description", - "expires", - "id", - "msgs", - "status", - "threshold", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "expires": { - "$ref": "#/definitions/Expiration" - }, - "id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "msgs": { - "type": "array", - "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - } - }, - "status": { - "$ref": "#/definitions/Status" - }, - "threshold": { - "description": "This is the threshold that is applied to this proposal. Both the rules of the voting contract, as well as the total_weight of the voting group may have changed since this time. That means that the generic `Threshold{}` query does not provide valid information for existing proposals.", - "allOf": [ - { - "$ref": "#/definitions/ThresholdResponse" - } - ] - }, - "title": { - "type": "string" - } - }, - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Status": { - "type": "string", - "enum": [ - "pending", - "open", - "rejected", - "passed", - "executed" - ] - }, - "ThresholdResponse": { - "description": "This defines the different ways tallies can happen. Every contract should support a subset of these, ideally all.\n\nThe total_weight used for calculating success as well as the weights of each individual voter used in tallying should be snapshotted at the beginning of the block at which the proposal starts (this is likely the responsibility of a correct cw4 implementation).", - "oneOf": [ - { - "description": "Declares that a fixed weight of yes votes is needed to pass. It does not matter how many no votes are cast, or how many do not vote, as long as `weight` yes votes are cast.\n\nThis is the simplest format and usually suitable for small multisigs of trusted parties, like 3 of 5. (weight: 3, total_weight: 5)\n\nA proposal of this type can pass early as soon as the needed weight of yes votes has been cast.", - "type": "object", - "required": [ - "absolute_count" - ], - "properties": { - "absolute_count": { - "type": "object", - "required": [ - "total_weight", - "weight" - ], - "properties": { - "total_weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Declares a percentage of the total weight that must cast Yes votes, in order for a proposal to pass. The passing weight is computed over the total weight minus the weight of the abstained votes.\n\nThis is useful for similar circumstances as `AbsoluteCount`, where we have a relatively small set of voters, and participation is required. It is understood that if the voting set (group) changes between different proposals that refer to the same group, each proposal will work with a different set of voter weights (the ones snapshotted at proposal creation), and the passing weight for each proposal will be computed based on the absolute percentage, times the total weights of the members at the time of each proposal creation.\n\nExample: we set `percentage` to 51%. Proposal 1 starts when there is a `total_weight` of 5. This will require 3 weight of Yes votes in order to pass. Later, the Proposal 2 starts but the `total_weight` of the group has increased to 9. That proposal will then automatically require 5 Yes of 9 to pass, rather than 3 yes of 9 as would be the case with `AbsoluteCount`.", - "type": "object", - "required": [ - "absolute_percentage" - ], - "properties": { - "absolute_percentage": { - "type": "object", - "required": [ - "percentage", - "total_weight" - ], - "properties": { - "percentage": { - "$ref": "#/definitions/Decimal" - }, - "total_weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "In addition to a `threshold`, declares a `quorum` of the total votes that must participate in the election in order for the vote to be considered at all. Within the votes that were cast, it requires `threshold` votes in favor. That is calculated by ignoring the Abstain votes (they count towards `quorum`, but do not influence `threshold`). That is, we calculate `Yes / (Yes + No + Veto)` and compare it with `threshold` to consider if the proposal was passed.\n\nIt is rather difficult for a proposal of this type to pass early. That can only happen if the required quorum has been already met, and there are already enough Yes votes for the proposal to pass.\n\n30% Yes votes, 10% No votes, and 20% Abstain would pass early if quorum <= 60% (who has cast votes) and if the threshold is <= 37.5% (the remaining 40% voting no => 30% yes + 50% no). Once the voting period has passed with no additional votes, that same proposal would be considered successful if quorum <= 60% and threshold <= 75% (percent in favor if we ignore abstain votes).\n\nThis type is more common in general elections, where participation is often expected to be low, and `AbsolutePercentage` would either be too high to pass anything, or allow low percentages to pass, independently of if there was high participation in the election or not.", - "type": "object", - "required": [ - "threshold_quorum" - ], - "properties": { - "threshold_quorum": { - "type": "object", - "required": [ - "quorum", - "threshold", - "total_weight" - ], - "properties": { - "quorum": { - "$ref": "#/definitions/Decimal" - }, - "threshold": { - "$ref": "#/definitions/Decimal" - }, - "total_weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/packages/cw3/schema/query_msg.json b/packages/cw3/schema/query_msg.json deleted file mode 100644 index 7e1dcaa65..000000000 --- a/packages/cw3/schema/query_msg.json +++ /dev/null @@ -1,218 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Returns the threshold rules that would be used for a new proposal that was opened right now. The threshold rules do not change often, but the `total_weight` in the response may easily differ from that used in previously opened proposals. Returns ThresholdResponse.", - "type": "object", - "required": [ - "threshold" - ], - "properties": { - "threshold": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Returns details of the proposal state. Returns ProposalResponse.", - "type": "object", - "required": [ - "proposal" - ], - "properties": { - "proposal": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Iterate over details of all proposals from oldest to newest. Returns ProposalListResponse", - "type": "object", - "required": [ - "list_proposals" - ], - "properties": { - "list_proposals": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Iterate reverse over details of all proposals, this is useful to easily query only the most recent proposals (to get updates). Returns ProposalListResponse", - "type": "object", - "required": [ - "reverse_proposals" - ], - "properties": { - "reverse_proposals": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_before": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Query the vote made by the given voter on `proposal_id`. This should return an error if there is no such proposal. It will return a None value if the proposal exists but the voter did not vote. Returns VoteResponse", - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "voter" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "voter": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Iterate (with pagination) over all votes for this proposal. The ordering is arbitrary, unlikely to be sorted by address. But ordering is consistent and pagination from the end of each page will cover all votes for the proposal. Returns VoteListResponse", - "type": "object", - "required": [ - "list_votes" - ], - "properties": { - "list_votes": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Voter extension: Returns VoterResponse", - "type": "object", - "required": [ - "voter" - ], - "properties": { - "voter": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "ListVoters extension: Returns VoterListResponse", - "type": "object", - "required": [ - "list_voters" - ], - "properties": { - "list_voters": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/packages/cw3/schema/threshold_response.json b/packages/cw3/schema/threshold_response.json deleted file mode 100644 index c36b4a566..000000000 --- a/packages/cw3/schema/threshold_response.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ThresholdResponse", - "description": "This defines the different ways tallies can happen. Every contract should support a subset of these, ideally all.\n\nThe total_weight used for calculating success as well as the weights of each individual voter used in tallying should be snapshotted at the beginning of the block at which the proposal starts (this is likely the responsibility of a correct cw4 implementation).", - "oneOf": [ - { - "description": "Declares that a fixed weight of yes votes is needed to pass. It does not matter how many no votes are cast, or how many do not vote, as long as `weight` yes votes are cast.\n\nThis is the simplest format and usually suitable for small multisigs of trusted parties, like 3 of 5. (weight: 3, total_weight: 5)\n\nA proposal of this type can pass early as soon as the needed weight of yes votes has been cast.", - "type": "object", - "required": [ - "absolute_count" - ], - "properties": { - "absolute_count": { - "type": "object", - "required": [ - "total_weight", - "weight" - ], - "properties": { - "total_weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Declares a percentage of the total weight that must cast Yes votes, in order for a proposal to pass. The passing weight is computed over the total weight minus the weight of the abstained votes.\n\nThis is useful for similar circumstances as `AbsoluteCount`, where we have a relatively small set of voters, and participation is required. It is understood that if the voting set (group) changes between different proposals that refer to the same group, each proposal will work with a different set of voter weights (the ones snapshotted at proposal creation), and the passing weight for each proposal will be computed based on the absolute percentage, times the total weights of the members at the time of each proposal creation.\n\nExample: we set `percentage` to 51%. Proposal 1 starts when there is a `total_weight` of 5. This will require 3 weight of Yes votes in order to pass. Later, the Proposal 2 starts but the `total_weight` of the group has increased to 9. That proposal will then automatically require 5 Yes of 9 to pass, rather than 3 yes of 9 as would be the case with `AbsoluteCount`.", - "type": "object", - "required": [ - "absolute_percentage" - ], - "properties": { - "absolute_percentage": { - "type": "object", - "required": [ - "percentage", - "total_weight" - ], - "properties": { - "percentage": { - "$ref": "#/definitions/Decimal" - }, - "total_weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "In addition to a `threshold`, declares a `quorum` of the total votes that must participate in the election in order for the vote to be considered at all. Within the votes that were cast, it requires `threshold` votes in favor. That is calculated by ignoring the Abstain votes (they count towards `quorum`, but do not influence `threshold`). That is, we calculate `Yes / (Yes + No + Veto)` and compare it with `threshold` to consider if the proposal was passed.\n\nIt is rather difficult for a proposal of this type to pass early. That can only happen if the required quorum has been already met, and there are already enough Yes votes for the proposal to pass.\n\n30% Yes votes, 10% No votes, and 20% Abstain would pass early if quorum <= 60% (who has cast votes) and if the threshold is <= 37.5% (the remaining 40% voting no => 30% yes + 50% no). Once the voting period has passed with no additional votes, that same proposal would be considered successful if quorum <= 60% and threshold <= 75% (percent in favor if we ignore abstain votes).\n\nThis type is more common in general elections, where participation is often expected to be low, and `AbsolutePercentage` would either be too high to pass anything, or allow low percentages to pass, independently of if there was high participation in the election or not.", - "type": "object", - "required": [ - "threshold_quorum" - ], - "properties": { - "threshold_quorum": { - "type": "object", - "required": [ - "quorum", - "threshold", - "total_weight" - ], - "properties": { - "quorum": { - "$ref": "#/definitions/Decimal" - }, - "threshold": { - "$ref": "#/definitions/Decimal" - }, - "total_weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - } - } -} diff --git a/packages/cw3/schema/vote_list_response.json b/packages/cw3/schema/vote_list_response.json deleted file mode 100644 index d0c22b6ba..000000000 --- a/packages/cw3/schema/vote_list_response.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "VoteListResponse", - "type": "object", - "required": [ - "votes" - ], - "properties": { - "votes": { - "type": "array", - "items": { - "$ref": "#/definitions/VoteInfo" - } - } - }, - "definitions": { - "Vote": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "veto" - ] - }, - "VoteInfo": { - "description": "Returns the vote (opinion as well as weight counted) as well as the address of the voter who submitted it", - "type": "object", - "required": [ - "vote", - "voter", - "weight" - ], - "properties": { - "vote": { - "$ref": "#/definitions/Vote" - }, - "voter": { - "type": "string" - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - } -} diff --git a/packages/cw3/schema/vote_response.json b/packages/cw3/schema/vote_response.json deleted file mode 100644 index eaf97cfee..000000000 --- a/packages/cw3/schema/vote_response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "VoteResponse", - "type": "object", - "properties": { - "vote": { - "anyOf": [ - { - "$ref": "#/definitions/VoteInfo" - }, - { - "type": "null" - } - ] - } - }, - "definitions": { - "Vote": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "veto" - ] - }, - "VoteInfo": { - "description": "Returns the vote (opinion as well as weight counted) as well as the address of the voter who submitted it", - "type": "object", - "required": [ - "vote", - "voter", - "weight" - ], - "properties": { - "vote": { - "$ref": "#/definitions/Vote" - }, - "voter": { - "type": "string" - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - } -} diff --git a/packages/cw3/schema/voter_detail.json b/packages/cw3/schema/voter_detail.json deleted file mode 100644 index b9543b60a..000000000 --- a/packages/cw3/schema/voter_detail.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "VoterDetail", - "type": "object", - "required": [ - "addr", - "weight" - ], - "properties": { - "addr": { - "type": "string" - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } -} diff --git a/packages/cw3/schema/voter_list_response.json b/packages/cw3/schema/voter_list_response.json deleted file mode 100644 index 17535bdc9..000000000 --- a/packages/cw3/schema/voter_list_response.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "VoterListResponse", - "type": "object", - "required": [ - "voters" - ], - "properties": { - "voters": { - "type": "array", - "items": { - "$ref": "#/definitions/VoterDetail" - } - } - }, - "definitions": { - "VoterDetail": { - "type": "object", - "required": [ - "addr", - "weight" - ], - "properties": { - "addr": { - "type": "string" - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - } -} diff --git a/packages/cw3/schema/voter_response.json b/packages/cw3/schema/voter_response.json deleted file mode 100644 index 6fefcfb6b..000000000 --- a/packages/cw3/schema/voter_response.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "VoterResponse", - "type": "object", - "properties": { - "weight": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } -} diff --git a/packages/cw4/schema/admin_response.json b/packages/cw4/schema/admin_response.json deleted file mode 100644 index 82bf62a3a..000000000 --- a/packages/cw4/schema/admin_response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AdminResponse", - "type": "object", - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - } - } -} diff --git a/packages/cw4/schema/cw4_execute_msg.json b/packages/cw4/schema/cw4_execute_msg.json deleted file mode 100644 index 9a3b3bb63..000000000 --- a/packages/cw4/schema/cw4_execute_msg.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw4ExecuteMsg", - "oneOf": [ - { - "description": "Change the admin", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Add a new hook to be informed of all membership changes. Must be called by Admin", - "type": "object", - "required": [ - "add_hook" - ], - "properties": { - "add_hook": { - "type": "object", - "required": [ - "addr" - ], - "properties": { - "addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Remove a hook. Must be called by Admin", - "type": "object", - "required": [ - "remove_hook" - ], - "properties": { - "remove_hook": { - "type": "object", - "required": [ - "addr" - ], - "properties": { - "addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/packages/cw4/schema/cw4_query_msg.json b/packages/cw4/schema/cw4_query_msg.json deleted file mode 100644 index f31ac791a..000000000 --- a/packages/cw4/schema/cw4_query_msg.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw4QueryMsg", - "oneOf": [ - { - "description": "Return AdminResponse", - "type": "object", - "required": [ - "admin" - ], - "properties": { - "admin": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Return TotalWeightResponse", - "type": "object", - "required": [ - "total_weight" - ], - "properties": { - "total_weight": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Returns MembersListResponse", - "type": "object", - "required": [ - "list_members" - ], - "properties": { - "list_members": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns MemberResponse", - "type": "object", - "required": [ - "member" - ], - "properties": { - "member": { - "type": "object", - "required": [ - "addr" - ], - "properties": { - "addr": { - "type": "string" - }, - "at_height": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Shows all registered hooks. Returns HooksResponse.", - "type": "object", - "required": [ - "hooks" - ], - "properties": { - "hooks": { - "type": "object" - } - }, - "additionalProperties": false - } - ] -} diff --git a/packages/cw4/schema/member_changed_hook_msg.json b/packages/cw4/schema/member_changed_hook_msg.json deleted file mode 100644 index 983f51d12..000000000 --- a/packages/cw4/schema/member_changed_hook_msg.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MemberChangedHookMsg", - "description": "MemberChangedHookMsg should be de/serialized under `MemberChangedHook()` variant in a ExecuteMsg. This contains a list of all diffs on the given transaction.", - "type": "object", - "required": [ - "diffs" - ], - "properties": { - "diffs": { - "type": "array", - "items": { - "$ref": "#/definitions/MemberDiff" - } - } - }, - "definitions": { - "MemberDiff": { - "description": "MemberDiff shows the old and new states for a given cw4 member They cannot both be None. old = None, new = Some -> Insert old = Some, new = Some -> Update old = Some, new = None -> Delete", - "type": "object", - "required": [ - "key" - ], - "properties": { - "key": { - "type": "string" - }, - "new": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "old": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - } -} diff --git a/packages/cw4/schema/member_list_response.json b/packages/cw4/schema/member_list_response.json deleted file mode 100644 index ae09f9bba..000000000 --- a/packages/cw4/schema/member_list_response.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MemberListResponse", - "type": "object", - "required": [ - "members" - ], - "properties": { - "members": { - "type": "array", - "items": { - "$ref": "#/definitions/Member" - } - } - }, - "definitions": { - "Member": { - "description": "A group member has a weight associated with them. This may all be equal, or may have meaning in the app that makes use of the group (eg. voting power)", - "type": "object", - "required": [ - "addr", - "weight" - ], - "properties": { - "addr": { - "type": "string" - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - } -} diff --git a/packages/cw4/schema/member_response.json b/packages/cw4/schema/member_response.json deleted file mode 100644 index c78ed8623..000000000 --- a/packages/cw4/schema/member_response.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MemberResponse", - "type": "object", - "properties": { - "weight": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } -} diff --git a/packages/cw4/schema/total_weight_response.json b/packages/cw4/schema/total_weight_response.json deleted file mode 100644 index 61db7a998..000000000 --- a/packages/cw4/schema/total_weight_response.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TotalWeightResponse", - "type": "object", - "required": [ - "weight" - ], - "properties": { - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } -} From 2f08eb738e65306aefc275653e1367a435177a0d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 21 Dec 2021 16:08:43 +0100 Subject: [PATCH 072/352] Remove contracts schemas from repo --- .../schema/admin_list_response.json | 20 - .../schema/all_allowances_response.json | 120 --- contracts/cw1-subkeys/schema/allowance.json | 102 --- contracts/cw1-subkeys/schema/execute_msg.json | 700 ------------------ .../cw1-subkeys/schema/instantiate_msg.json | 20 - contracts/cw1-subkeys/schema/query_msg.json | 602 --------------- .../schema/admin_list_response.json | 20 - .../cw1-whitelist-ng/schema/cw1_exec_msg.json | 488 ------------ .../schema/cw1_query_msg.json | 489 ------------ .../schema/instantiate_msg.json | 20 - .../schema/whitelist_exec_msg.json | 43 -- .../schema/whitelist_query_msg.json | 19 - .../schema/admin_list_response.json | 20 - .../cw1-whitelist/schema/execute_msg.json | 525 ------------- .../cw1-whitelist/schema/instantiate_msg.json | 20 - contracts/cw1-whitelist/schema/query_msg.json | 502 ------------- .../schema/approved_for_all_response.json | 97 --- .../cw1155-base/schema/balance_response.json | 19 - .../schema/batch_balance_response.json | 22 - .../schema/cw1155_batch_receive_msg.json | 51 -- .../schema/cw1155_execute_msg.json | 383 ---------- .../cw1155-base/schema/cw1155_query_msg.json | 211 ------ .../schema/cw1155_receive_msg.json | 44 -- .../cw1155-base/schema/instantiate_msg.json | 14 - .../schema/is_approved_for_all_response.json | 13 - .../schema/token_info_response.json | 14 - .../cw1155-base/schema/tokens_response.json | 17 - .../schema/details_response.json | 172 ----- .../cw20-atomic-swap/schema/execute_msg.json | 197 ----- .../schema/instantiate_msg.json | 5 - .../schema/list_response.json | 17 - .../cw20-atomic-swap/schema/query_msg.json | 56 -- .../schema/all_accounts_response.json | 16 - .../schema/all_allowances_response.json | 99 --- .../cw20-base/schema/allowance_response.json | 81 -- .../cw20-base/schema/balance_response.json | 19 - .../cw20-base/schema/cw20_execute_msg.json | 442 ----------- .../cw20-base/schema/instantiate_msg.json | 192 ----- contracts/cw20-base/schema/query_msg.json | 168 ----- .../cw20-base/schema/token_info_response.json | 33 - .../schema/allowance_response.json | 81 -- .../cw20-bonding/schema/balance_response.json | 19 - .../schema/curve_info_response.json | 35 - .../cw20-bonding/schema/execute_msg.json | 319 -------- .../cw20-bonding/schema/instantiate_msg.json | 138 ---- contracts/cw20-bonding/schema/query_msg.json | 78 -- .../schema/token_info_response.json | 33 - .../cw20-escrow/schema/details_response.json | 107 --- contracts/cw20-escrow/schema/execute_msg.json | 176 ----- .../cw20-escrow/schema/instantiate_msg.json | 5 - .../cw20-escrow/schema/list_response.json | 17 - contracts/cw20-escrow/schema/query_msg.json | 40 - contracts/cw20-escrow/schema/receive_msg.json | 91 --- .../cw20-ics20/schema/channel_response.json | 139 ---- contracts/cw20-ics20/schema/execute_msg.json | 89 --- contracts/cw20-ics20/schema/init_msg.json | 16 - .../schema/list_channels_response.json | 59 -- .../cw20-ics20/schema/port_response.json | 13 - contracts/cw20-ics20/schema/query_msg.json | 53 -- contracts/cw20-ics20/schema/transfer_msg.json | 29 - .../schema/config_response.json | 19 - .../schema/execute_msg.json | 89 --- .../schema/instantiate_msg.json | 20 - .../schema/is_claimed_response.json | 13 - .../schema/latest_stage_response.json | 15 - .../schema/merkle_root_response.json | 20 - .../cw20-merkle-airdrop/schema/query_msg.json | 78 -- .../schema/allowance_response.json | 81 -- .../cw20-staking/schema/balance_response.json | 19 - .../cw20-staking/schema/claims_response.json | 95 --- .../cw20-staking/schema/execute_msg.json | 379 ---------- .../cw20-staking/schema/instantiate_msg.json | 102 --- .../schema/investment_response.json | 74 -- contracts/cw20-staking/schema/query_msg.json | 99 --- .../schema/token_info_response.json | 33 - .../schema/execute_msg.json | 642 ---------------- .../schema/instantiate_msg.json | 79 -- .../cw3-fixed-multisig/schema/query_msg.json | 218 ------ .../cw3-flex-multisig/schema/execute_msg.json | 698 ----------------- .../schema/instantiate_msg.json | 135 ---- .../cw3-flex-multisig/schema/query_msg.json | 218 ------ .../cw4-group/schema/admin_response.json | 13 - contracts/cw4-group/schema/execute_msg.json | 120 --- .../cw4-group/schema/instantiate_msg.json | 43 -- .../schema/member_list_response.json | 36 - .../cw4-group/schema/member_response.json | 15 - contracts/cw4-group/schema/query_msg.json | 103 --- .../schema/total_weight_response.json | 15 - .../cw4-stake/schema/admin_response.json | 13 - .../cw4-stake/schema/claims_response.json | 95 --- contracts/cw4-stake/schema/execute_msg.json | 159 ---- .../cw4-stake/schema/instantiate_msg.json | 108 --- .../schema/member_list_response.json | 36 - .../cw4-stake/schema/member_response.json | 15 - contracts/cw4-stake/schema/query_msg.json | 144 ---- contracts/cw4-stake/schema/receive_msg.json | 19 - .../cw4-stake/schema/staked_response.json | 55 -- .../schema/total_weight_response.json | 15 - 98 files changed, 11759 deletions(-) delete mode 100644 contracts/cw1-subkeys/schema/admin_list_response.json delete mode 100644 contracts/cw1-subkeys/schema/all_allowances_response.json delete mode 100644 contracts/cw1-subkeys/schema/allowance.json delete mode 100644 contracts/cw1-subkeys/schema/execute_msg.json delete mode 100644 contracts/cw1-subkeys/schema/instantiate_msg.json delete mode 100644 contracts/cw1-subkeys/schema/query_msg.json delete mode 100644 contracts/cw1-whitelist-ng/schema/admin_list_response.json delete mode 100644 contracts/cw1-whitelist-ng/schema/cw1_exec_msg.json delete mode 100644 contracts/cw1-whitelist-ng/schema/cw1_query_msg.json delete mode 100644 contracts/cw1-whitelist-ng/schema/instantiate_msg.json delete mode 100644 contracts/cw1-whitelist-ng/schema/whitelist_exec_msg.json delete mode 100644 contracts/cw1-whitelist-ng/schema/whitelist_query_msg.json delete mode 100644 contracts/cw1-whitelist/schema/admin_list_response.json delete mode 100644 contracts/cw1-whitelist/schema/execute_msg.json delete mode 100644 contracts/cw1-whitelist/schema/instantiate_msg.json delete mode 100644 contracts/cw1-whitelist/schema/query_msg.json delete mode 100644 contracts/cw1155-base/schema/approved_for_all_response.json delete mode 100644 contracts/cw1155-base/schema/balance_response.json delete mode 100644 contracts/cw1155-base/schema/batch_balance_response.json delete mode 100644 contracts/cw1155-base/schema/cw1155_batch_receive_msg.json delete mode 100644 contracts/cw1155-base/schema/cw1155_execute_msg.json delete mode 100644 contracts/cw1155-base/schema/cw1155_query_msg.json delete mode 100644 contracts/cw1155-base/schema/cw1155_receive_msg.json delete mode 100644 contracts/cw1155-base/schema/instantiate_msg.json delete mode 100644 contracts/cw1155-base/schema/is_approved_for_all_response.json delete mode 100644 contracts/cw1155-base/schema/token_info_response.json delete mode 100644 contracts/cw1155-base/schema/tokens_response.json delete mode 100644 contracts/cw20-atomic-swap/schema/details_response.json delete mode 100644 contracts/cw20-atomic-swap/schema/execute_msg.json delete mode 100644 contracts/cw20-atomic-swap/schema/instantiate_msg.json delete mode 100644 contracts/cw20-atomic-swap/schema/list_response.json delete mode 100644 contracts/cw20-atomic-swap/schema/query_msg.json delete mode 100644 contracts/cw20-base/schema/all_accounts_response.json delete mode 100644 contracts/cw20-base/schema/all_allowances_response.json delete mode 100644 contracts/cw20-base/schema/allowance_response.json delete mode 100644 contracts/cw20-base/schema/balance_response.json delete mode 100644 contracts/cw20-base/schema/cw20_execute_msg.json delete mode 100644 contracts/cw20-base/schema/instantiate_msg.json delete mode 100644 contracts/cw20-base/schema/query_msg.json delete mode 100644 contracts/cw20-base/schema/token_info_response.json delete mode 100644 contracts/cw20-bonding/schema/allowance_response.json delete mode 100644 contracts/cw20-bonding/schema/balance_response.json delete mode 100644 contracts/cw20-bonding/schema/curve_info_response.json delete mode 100644 contracts/cw20-bonding/schema/execute_msg.json delete mode 100644 contracts/cw20-bonding/schema/instantiate_msg.json delete mode 100644 contracts/cw20-bonding/schema/query_msg.json delete mode 100644 contracts/cw20-bonding/schema/token_info_response.json delete mode 100644 contracts/cw20-escrow/schema/details_response.json delete mode 100644 contracts/cw20-escrow/schema/execute_msg.json delete mode 100644 contracts/cw20-escrow/schema/instantiate_msg.json delete mode 100644 contracts/cw20-escrow/schema/list_response.json delete mode 100644 contracts/cw20-escrow/schema/query_msg.json delete mode 100644 contracts/cw20-escrow/schema/receive_msg.json delete mode 100644 contracts/cw20-ics20/schema/channel_response.json delete mode 100644 contracts/cw20-ics20/schema/execute_msg.json delete mode 100644 contracts/cw20-ics20/schema/init_msg.json delete mode 100644 contracts/cw20-ics20/schema/list_channels_response.json delete mode 100644 contracts/cw20-ics20/schema/port_response.json delete mode 100644 contracts/cw20-ics20/schema/query_msg.json delete mode 100644 contracts/cw20-ics20/schema/transfer_msg.json delete mode 100644 contracts/cw20-merkle-airdrop/schema/config_response.json delete mode 100644 contracts/cw20-merkle-airdrop/schema/execute_msg.json delete mode 100644 contracts/cw20-merkle-airdrop/schema/instantiate_msg.json delete mode 100644 contracts/cw20-merkle-airdrop/schema/is_claimed_response.json delete mode 100644 contracts/cw20-merkle-airdrop/schema/latest_stage_response.json delete mode 100644 contracts/cw20-merkle-airdrop/schema/merkle_root_response.json delete mode 100644 contracts/cw20-merkle-airdrop/schema/query_msg.json delete mode 100644 contracts/cw20-staking/schema/allowance_response.json delete mode 100644 contracts/cw20-staking/schema/balance_response.json delete mode 100644 contracts/cw20-staking/schema/claims_response.json delete mode 100644 contracts/cw20-staking/schema/execute_msg.json delete mode 100644 contracts/cw20-staking/schema/instantiate_msg.json delete mode 100644 contracts/cw20-staking/schema/investment_response.json delete mode 100644 contracts/cw20-staking/schema/query_msg.json delete mode 100644 contracts/cw20-staking/schema/token_info_response.json delete mode 100644 contracts/cw3-fixed-multisig/schema/execute_msg.json delete mode 100644 contracts/cw3-fixed-multisig/schema/instantiate_msg.json delete mode 100644 contracts/cw3-fixed-multisig/schema/query_msg.json delete mode 100644 contracts/cw3-flex-multisig/schema/execute_msg.json delete mode 100644 contracts/cw3-flex-multisig/schema/instantiate_msg.json delete mode 100644 contracts/cw3-flex-multisig/schema/query_msg.json delete mode 100644 contracts/cw4-group/schema/admin_response.json delete mode 100644 contracts/cw4-group/schema/execute_msg.json delete mode 100644 contracts/cw4-group/schema/instantiate_msg.json delete mode 100644 contracts/cw4-group/schema/member_list_response.json delete mode 100644 contracts/cw4-group/schema/member_response.json delete mode 100644 contracts/cw4-group/schema/query_msg.json delete mode 100644 contracts/cw4-group/schema/total_weight_response.json delete mode 100644 contracts/cw4-stake/schema/admin_response.json delete mode 100644 contracts/cw4-stake/schema/claims_response.json delete mode 100644 contracts/cw4-stake/schema/execute_msg.json delete mode 100644 contracts/cw4-stake/schema/instantiate_msg.json delete mode 100644 contracts/cw4-stake/schema/member_list_response.json delete mode 100644 contracts/cw4-stake/schema/member_response.json delete mode 100644 contracts/cw4-stake/schema/query_msg.json delete mode 100644 contracts/cw4-stake/schema/receive_msg.json delete mode 100644 contracts/cw4-stake/schema/staked_response.json delete mode 100644 contracts/cw4-stake/schema/total_weight_response.json diff --git a/contracts/cw1-subkeys/schema/admin_list_response.json b/contracts/cw1-subkeys/schema/admin_list_response.json deleted file mode 100644 index bc20467c3..000000000 --- a/contracts/cw1-subkeys/schema/admin_list_response.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AdminListResponse", - "type": "object", - "required": [ - "admins", - "mutable" - ], - "properties": { - "admins": { - "type": "array", - "items": { - "type": "string" - } - }, - "mutable": { - "type": "boolean" - } - } -} diff --git a/contracts/cw1-subkeys/schema/all_allowances_response.json b/contracts/cw1-subkeys/schema/all_allowances_response.json deleted file mode 100644 index 287b75024..000000000 --- a/contracts/cw1-subkeys/schema/all_allowances_response.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AllAllowancesResponse", - "type": "object", - "required": [ - "allowances" - ], - "properties": { - "allowances": { - "type": "array", - "items": { - "$ref": "#/definitions/AllowanceInfo" - } - } - }, - "definitions": { - "AllowanceInfo": { - "type": "object", - "required": [ - "balance", - "expires", - "spender" - ], - "properties": { - "balance": { - "$ref": "#/definitions/NativeBalance" - }, - "expires": { - "$ref": "#/definitions/Expiration" - }, - "spender": { - "type": "string" - } - } - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "NativeBalance": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw1-subkeys/schema/allowance.json b/contracts/cw1-subkeys/schema/allowance.json deleted file mode 100644 index 2a8fb26b8..000000000 --- a/contracts/cw1-subkeys/schema/allowance.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Allowance", - "type": "object", - "required": [ - "balance", - "expires" - ], - "properties": { - "balance": { - "$ref": "#/definitions/NativeBalance" - }, - "expires": { - "$ref": "#/definitions/Expiration" - } - }, - "definitions": { - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "NativeBalance": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw1-subkeys/schema/execute_msg.json b/contracts/cw1-subkeys/schema/execute_msg.json deleted file mode 100644 index d1f887237..000000000 --- a/contracts/cw1-subkeys/schema/execute_msg.json +++ /dev/null @@ -1,700 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "description": "Execute requests the contract to re-dispatch all these messages with the contract's address as sender. Every implementation has it's own logic to determine in", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "msgs" - ], - "properties": { - "msgs": { - "type": "array", - "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - } - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Freeze will make a mutable contract immutable, must be called by an admin", - "type": "object", - "required": [ - "freeze" - ], - "properties": { - "freeze": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "UpdateAdmins will change the admin set of the contract, must be called by an existing admin, and only works if the contract is mutable", - "type": "object", - "required": [ - "update_admins" - ], - "properties": { - "update_admins": { - "type": "object", - "required": [ - "admins" - ], - "properties": { - "admins": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Add an allowance to a given subkey (subkey must not be admin)", - "type": "object", - "required": [ - "increase_allowance" - ], - "properties": { - "increase_allowance": { - "type": "object", - "required": [ - "amount", - "spender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Decreases an allowance for a given subkey (subkey must not be admin)", - "type": "object", - "required": [ - "decrease_allowance" - ], - "properties": { - "decrease_allowance": { - "type": "object", - "required": [ - "amount", - "spender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "set_permissions" - ], - "properties": { - "set_permissions": { - "type": "object", - "required": [ - "permissions", - "spender" - ], - "properties": { - "permissions": { - "$ref": "#/definitions/Permissions" - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "staking" - ], - "properties": { - "staking": { - "$ref": "#/definitions/StakingMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "distribution" - ], - "properties": { - "distribution": { - "$ref": "#/definitions/DistributionMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Permissions": { - "type": "object", - "required": [ - "delegate", - "redelegate", - "undelegate", - "withdraw" - ], - "properties": { - "delegate": { - "type": "boolean" - }, - "redelegate": { - "type": "boolean" - }, - "undelegate": { - "type": "boolean" - }, - "withdraw": { - "type": "boolean" - } - } - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "redelegate" - ], - "properties": { - "redelegate": { - "type": "object", - "required": [ - "amount", - "dst_validator", - "src_validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "dst_validator": { - "type": "string" - }, - "src_validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/contracts/cw1-subkeys/schema/instantiate_msg.json b/contracts/cw1-subkeys/schema/instantiate_msg.json deleted file mode 100644 index fdcd684aa..000000000 --- a/contracts/cw1-subkeys/schema/instantiate_msg.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "admins", - "mutable" - ], - "properties": { - "admins": { - "type": "array", - "items": { - "type": "string" - } - }, - "mutable": { - "type": "boolean" - } - } -} diff --git a/contracts/cw1-subkeys/schema/query_msg.json b/contracts/cw1-subkeys/schema/query_msg.json deleted file mode 100644 index 1fc41ead7..000000000 --- a/contracts/cw1-subkeys/schema/query_msg.json +++ /dev/null @@ -1,602 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Shows all admins and whether or not it is mutable Returns cw1-whitelist::AdminListResponse", - "type": "object", - "required": [ - "admin_list" - ], - "properties": { - "admin_list": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Get the current allowance for the given subkey (how much it can spend) Returns crate::state::Allowance", - "type": "object", - "required": [ - "allowance" - ], - "properties": { - "allowance": { - "type": "object", - "required": [ - "spender" - ], - "properties": { - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Get the current permissions for the given subkey (how much it can spend) Returns PermissionsInfo", - "type": "object", - "required": [ - "permissions" - ], - "properties": { - "permissions": { - "type": "object", - "required": [ - "spender" - ], - "properties": { - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Checks permissions of the caller on this proxy. If CanExecute returns true then a call to `Execute` with the same message, before any further state changes, should also succeed.", - "type": "object", - "required": [ - "can_execute" - ], - "properties": { - "can_execute": { - "type": "object", - "required": [ - "msg", - "sender" - ], - "properties": { - "msg": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - }, - "sender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Gets all Allowances for this contract Returns AllAllowancesResponse", - "type": "object", - "required": [ - "all_allowances" - ], - "properties": { - "all_allowances": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Gets all Permissions for this contract Returns AllPermissionsResponse", - "type": "object", - "required": [ - "all_permissions" - ], - "properties": { - "all_permissions": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "staking" - ], - "properties": { - "staking": { - "$ref": "#/definitions/StakingMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "distribution" - ], - "properties": { - "distribution": { - "$ref": "#/definitions/DistributionMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "redelegate" - ], - "properties": { - "redelegate": { - "type": "object", - "required": [ - "amount", - "dst_validator", - "src_validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "dst_validator": { - "type": "string" - }, - "src_validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/contracts/cw1-whitelist-ng/schema/admin_list_response.json b/contracts/cw1-whitelist-ng/schema/admin_list_response.json deleted file mode 100644 index bc20467c3..000000000 --- a/contracts/cw1-whitelist-ng/schema/admin_list_response.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AdminListResponse", - "type": "object", - "required": [ - "admins", - "mutable" - ], - "properties": { - "admins": { - "type": "array", - "items": { - "type": "string" - } - }, - "mutable": { - "type": "boolean" - } - } -} diff --git a/contracts/cw1-whitelist-ng/schema/cw1_exec_msg.json b/contracts/cw1-whitelist-ng/schema/cw1_exec_msg.json deleted file mode 100644 index 0eed149ec..000000000 --- a/contracts/cw1-whitelist-ng/schema/cw1_exec_msg.json +++ /dev/null @@ -1,488 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw1ExecMsg", - "oneOf": [ - { - "description": "Execute requests the contract to re-dispatch all these messages with the contract's address as sender. Every implementation has it's own logic to determine in", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "msgs" - ], - "properties": { - "msgs": { - "type": "array", - "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - } - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "staking" - ], - "properties": { - "staking": { - "$ref": "#/definitions/StakingMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "distribution" - ], - "properties": { - "distribution": { - "$ref": "#/definitions/DistributionMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "redelegate" - ], - "properties": { - "redelegate": { - "type": "object", - "required": [ - "amount", - "dst_validator", - "src_validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "dst_validator": { - "type": "string" - }, - "src_validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/contracts/cw1-whitelist-ng/schema/cw1_query_msg.json b/contracts/cw1-whitelist-ng/schema/cw1_query_msg.json deleted file mode 100644 index 7783a494a..000000000 --- a/contracts/cw1-whitelist-ng/schema/cw1_query_msg.json +++ /dev/null @@ -1,489 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw1QueryMsg", - "oneOf": [ - { - "description": "Checks permissions of the caller on this proxy. If CanExecute returns true then a call to `Execute` with the same message, before any further state changes, should also succeed.", - "type": "object", - "required": [ - "can_execute" - ], - "properties": { - "can_execute": { - "type": "object", - "required": [ - "msg", - "sender" - ], - "properties": { - "msg": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - }, - "sender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "staking" - ], - "properties": { - "staking": { - "$ref": "#/definitions/StakingMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "distribution" - ], - "properties": { - "distribution": { - "$ref": "#/definitions/DistributionMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "redelegate" - ], - "properties": { - "redelegate": { - "type": "object", - "required": [ - "amount", - "dst_validator", - "src_validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "dst_validator": { - "type": "string" - }, - "src_validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/contracts/cw1-whitelist-ng/schema/instantiate_msg.json b/contracts/cw1-whitelist-ng/schema/instantiate_msg.json deleted file mode 100644 index fdcd684aa..000000000 --- a/contracts/cw1-whitelist-ng/schema/instantiate_msg.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "admins", - "mutable" - ], - "properties": { - "admins": { - "type": "array", - "items": { - "type": "string" - } - }, - "mutable": { - "type": "boolean" - } - } -} diff --git a/contracts/cw1-whitelist-ng/schema/whitelist_exec_msg.json b/contracts/cw1-whitelist-ng/schema/whitelist_exec_msg.json deleted file mode 100644 index 0ac87ee51..000000000 --- a/contracts/cw1-whitelist-ng/schema/whitelist_exec_msg.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "WhitelistExecMsg", - "oneOf": [ - { - "description": "Freeze will make a mutable contract immutable, must be called by an admin", - "type": "object", - "required": [ - "freeze" - ], - "properties": { - "freeze": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "UpdateAdmins will change the admin set of the contract, must be called by an existing admin, and only works if the contract is mutable", - "type": "object", - "required": [ - "update_admins" - ], - "properties": { - "update_admins": { - "type": "object", - "required": [ - "admins" - ], - "properties": { - "admins": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw1-whitelist-ng/schema/whitelist_query_msg.json b/contracts/cw1-whitelist-ng/schema/whitelist_query_msg.json deleted file mode 100644 index b5d8ed25f..000000000 --- a/contracts/cw1-whitelist-ng/schema/whitelist_query_msg.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "WhitelistQueryMsg", - "oneOf": [ - { - "description": "Shows all admins and whether or not it is mutable", - "type": "object", - "required": [ - "admin_list" - ], - "properties": { - "admin_list": { - "type": "object" - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw1-whitelist/schema/admin_list_response.json b/contracts/cw1-whitelist/schema/admin_list_response.json deleted file mode 100644 index bc20467c3..000000000 --- a/contracts/cw1-whitelist/schema/admin_list_response.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AdminListResponse", - "type": "object", - "required": [ - "admins", - "mutable" - ], - "properties": { - "admins": { - "type": "array", - "items": { - "type": "string" - } - }, - "mutable": { - "type": "boolean" - } - } -} diff --git a/contracts/cw1-whitelist/schema/execute_msg.json b/contracts/cw1-whitelist/schema/execute_msg.json deleted file mode 100644 index 50ca31e12..000000000 --- a/contracts/cw1-whitelist/schema/execute_msg.json +++ /dev/null @@ -1,525 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "description": "Execute requests the contract to re-dispatch all these messages with the contract's address as sender. Every implementation has it's own logic to determine in", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "msgs" - ], - "properties": { - "msgs": { - "type": "array", - "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - } - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Freeze will make a mutable contract immutable, must be called by an admin", - "type": "object", - "required": [ - "freeze" - ], - "properties": { - "freeze": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "UpdateAdmins will change the admin set of the contract, must be called by an existing admin, and only works if the contract is mutable", - "type": "object", - "required": [ - "update_admins" - ], - "properties": { - "update_admins": { - "type": "object", - "required": [ - "admins" - ], - "properties": { - "admins": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "staking" - ], - "properties": { - "staking": { - "$ref": "#/definitions/StakingMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "distribution" - ], - "properties": { - "distribution": { - "$ref": "#/definitions/DistributionMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "redelegate" - ], - "properties": { - "redelegate": { - "type": "object", - "required": [ - "amount", - "dst_validator", - "src_validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "dst_validator": { - "type": "string" - }, - "src_validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/contracts/cw1-whitelist/schema/instantiate_msg.json b/contracts/cw1-whitelist/schema/instantiate_msg.json deleted file mode 100644 index fdcd684aa..000000000 --- a/contracts/cw1-whitelist/schema/instantiate_msg.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "admins", - "mutable" - ], - "properties": { - "admins": { - "type": "array", - "items": { - "type": "string" - } - }, - "mutable": { - "type": "boolean" - } - } -} diff --git a/contracts/cw1-whitelist/schema/query_msg.json b/contracts/cw1-whitelist/schema/query_msg.json deleted file mode 100644 index 7ce7782ec..000000000 --- a/contracts/cw1-whitelist/schema/query_msg.json +++ /dev/null @@ -1,502 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Shows all admins and whether or not it is mutable", - "type": "object", - "required": [ - "admin_list" - ], - "properties": { - "admin_list": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Checks permissions of the caller on this proxy. If CanExecute returns true then a call to `Execute` with the same message, before any further state changes, should also succeed.", - "type": "object", - "required": [ - "can_execute" - ], - "properties": { - "can_execute": { - "type": "object", - "required": [ - "msg", - "sender" - ], - "properties": { - "msg": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - }, - "sender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "staking" - ], - "properties": { - "staking": { - "$ref": "#/definitions/StakingMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "distribution" - ], - "properties": { - "distribution": { - "$ref": "#/definitions/DistributionMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "redelegate" - ], - "properties": { - "redelegate": { - "type": "object", - "required": [ - "amount", - "dst_validator", - "src_validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "dst_validator": { - "type": "string" - }, - "src_validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/contracts/cw1155-base/schema/approved_for_all_response.json b/contracts/cw1155-base/schema/approved_for_all_response.json deleted file mode 100644 index 453f17b7c..000000000 --- a/contracts/cw1155-base/schema/approved_for_all_response.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ApprovedForAllResponse", - "type": "object", - "required": [ - "operators" - ], - "properties": { - "operators": { - "type": "array", - "items": { - "$ref": "#/definitions/Approval" - } - } - }, - "definitions": { - "Approval": { - "type": "object", - "required": [ - "expires", - "spender" - ], - "properties": { - "expires": { - "description": "When the Approval expires (maybe Expiration::never)", - "allOf": [ - { - "$ref": "#/definitions/Expiration" - } - ] - }, - "spender": { - "description": "Account that can transfer/send the token", - "type": "string" - } - } - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw1155-base/schema/balance_response.json b/contracts/cw1155-base/schema/balance_response.json deleted file mode 100644 index 4e1a0be2b..000000000 --- a/contracts/cw1155-base/schema/balance_response.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BalanceResponse", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw1155-base/schema/batch_balance_response.json b/contracts/cw1155-base/schema/batch_balance_response.json deleted file mode 100644 index 39c8bd040..000000000 --- a/contracts/cw1155-base/schema/batch_balance_response.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BatchBalanceResponse", - "type": "object", - "required": [ - "balances" - ], - "properties": { - "balances": { - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw1155-base/schema/cw1155_batch_receive_msg.json b/contracts/cw1155-base/schema/cw1155_batch_receive_msg.json deleted file mode 100644 index 39820287c..000000000 --- a/contracts/cw1155-base/schema/cw1155_batch_receive_msg.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw1155BatchReceiveMsg", - "description": "Cw1155BatchReceiveMsg should be de/serialized under `BatchReceive()` variant in a ExecuteMsg", - "type": "object", - "required": [ - "batch", - "msg", - "operator" - ], - "properties": { - "batch": { - "type": "array", - "items": { - "type": "array", - "items": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/Uint128" - } - ], - "maxItems": 2, - "minItems": 2 - } - }, - "from": { - "type": [ - "string", - "null" - ] - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "operator": { - "type": "string" - } - }, - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw1155-base/schema/cw1155_execute_msg.json b/contracts/cw1155-base/schema/cw1155_execute_msg.json deleted file mode 100644 index 41ebe3020..000000000 --- a/contracts/cw1155-base/schema/cw1155_execute_msg.json +++ /dev/null @@ -1,383 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw1155ExecuteMsg", - "oneOf": [ - { - "description": "SendFrom is a base message to move tokens, if `env.sender` is the owner or has sufficient pre-approval.", - "type": "object", - "required": [ - "send_from" - ], - "properties": { - "send_from": { - "type": "object", - "required": [ - "from", - "to", - "token_id", - "value" - ], - "properties": { - "from": { - "type": "string" - }, - "msg": { - "description": "`None` means don't call the receiver interface", - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - }, - "to": { - "description": "If `to` is not contract, `msg` should be `None`", - "type": "string" - }, - "token_id": { - "type": "string" - }, - "value": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "BatchSendFrom is a base message to move multiple types of tokens in batch, if `env.sender` is the owner or has sufficient pre-approval.", - "type": "object", - "required": [ - "batch_send_from" - ], - "properties": { - "batch_send_from": { - "type": "object", - "required": [ - "batch", - "from", - "to" - ], - "properties": { - "batch": { - "type": "array", - "items": { - "type": "array", - "items": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/Uint128" - } - ], - "maxItems": 2, - "minItems": 2 - } - }, - "from": { - "type": "string" - }, - "msg": { - "description": "`None` means don't call the receiver interface", - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - }, - "to": { - "description": "if `to` is not contract, `msg` should be `None`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Mint is a base message to mint tokens.", - "type": "object", - "required": [ - "mint" - ], - "properties": { - "mint": { - "type": "object", - "required": [ - "to", - "token_id", - "value" - ], - "properties": { - "msg": { - "description": "`None` means don't call the receiver interface", - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - }, - "to": { - "description": "If `to` is not contract, `msg` should be `None`", - "type": "string" - }, - "token_id": { - "type": "string" - }, - "value": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "BatchMint is a base message to mint multiple types of tokens in batch.", - "type": "object", - "required": [ - "batch_mint" - ], - "properties": { - "batch_mint": { - "type": "object", - "required": [ - "batch", - "to" - ], - "properties": { - "batch": { - "type": "array", - "items": { - "type": "array", - "items": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/Uint128" - } - ], - "maxItems": 2, - "minItems": 2 - } - }, - "msg": { - "description": "`None` means don't call the receiver interface", - "anyOf": [ - { - "$ref": "#/definitions/Binary" - }, - { - "type": "null" - } - ] - }, - "to": { - "description": "If `to` is not contract, `msg` should be `None`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Burn is a base message to burn tokens.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "from", - "token_id", - "value" - ], - "properties": { - "from": { - "type": "string" - }, - "token_id": { - "type": "string" - }, - "value": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "BatchBurn is a base message to burn multiple types of tokens in batch.", - "type": "object", - "required": [ - "batch_burn" - ], - "properties": { - "batch_burn": { - "type": "object", - "required": [ - "batch", - "from" - ], - "properties": { - "batch": { - "type": "array", - "items": { - "type": "array", - "items": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/Uint128" - } - ], - "maxItems": 2, - "minItems": 2 - } - }, - "from": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Allows operator to transfer / send any token from the owner's account. If expiration is set, then this allowance has a time/height limit", - "type": "object", - "required": [ - "approve_all" - ], - "properties": { - "approve_all": { - "type": "object", - "required": [ - "operator" - ], - "properties": { - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "operator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Remove previously granted ApproveAll permission", - "type": "object", - "required": [ - "revoke_all" - ], - "properties": { - "revoke_all": { - "type": "object", - "required": [ - "operator" - ], - "properties": { - "operator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw1155-base/schema/cw1155_query_msg.json b/contracts/cw1155-base/schema/cw1155_query_msg.json deleted file mode 100644 index fa4282450..000000000 --- a/contracts/cw1155-base/schema/cw1155_query_msg.json +++ /dev/null @@ -1,211 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw1155QueryMsg", - "oneOf": [ - { - "description": "Returns the current balance of the given address, 0 if unset. Return type: BalanceResponse.", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "type": "object", - "required": [ - "owner", - "token_id" - ], - "properties": { - "owner": { - "type": "string" - }, - "token_id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns the current balance of the given address for a batch of tokens, 0 if unset. Return type: BatchBalanceResponse.", - "type": "object", - "required": [ - "batch_balance" - ], - "properties": { - "batch_balance": { - "type": "object", - "required": [ - "owner", - "token_ids" - ], - "properties": { - "owner": { - "type": "string" - }, - "token_ids": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - }, - "additionalProperties": false - }, - { - "description": "List all operators that can access all of the owner's tokens. Return type: ApprovedForAllResponse.", - "type": "object", - "required": [ - "approved_for_all" - ], - "properties": { - "approved_for_all": { - "type": "object", - "required": [ - "owner" - ], - "properties": { - "include_expired": { - "description": "unset or false will filter out expired approvals, you must set to true to see them", - "type": [ - "boolean", - "null" - ] - }, - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "owner": { - "type": "string" - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Query approved status `owner` granted to `operator`. Return type: IsApprovedForAllResponse", - "type": "object", - "required": [ - "is_approved_for_all" - ], - "properties": { - "is_approved_for_all": { - "type": "object", - "required": [ - "operator", - "owner" - ], - "properties": { - "operator": { - "type": "string" - }, - "owner": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "With MetaData Extension. Query metadata of token Return type: TokenInfoResponse.", - "type": "object", - "required": [ - "token_info" - ], - "properties": { - "token_info": { - "type": "object", - "required": [ - "token_id" - ], - "properties": { - "token_id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "With Enumerable extension. Returns all tokens owned by the given address, [] if unset. Return type: TokensResponse.", - "type": "object", - "required": [ - "tokens" - ], - "properties": { - "tokens": { - "type": "object", - "required": [ - "owner" - ], - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "owner": { - "type": "string" - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "With Enumerable extension. Requires pagination. Lists all token_ids controlled by the contract. Return type: TokensResponse.", - "type": "object", - "required": [ - "all_tokens" - ], - "properties": { - "all_tokens": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw1155-base/schema/cw1155_receive_msg.json b/contracts/cw1155-base/schema/cw1155_receive_msg.json deleted file mode 100644 index 1bf693cec..000000000 --- a/contracts/cw1155-base/schema/cw1155_receive_msg.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw1155ReceiveMsg", - "description": "Cw1155ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg", - "type": "object", - "required": [ - "amount", - "msg", - "operator", - "token_id" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "from": { - "description": "The account that the token transfered from", - "type": [ - "string", - "null" - ] - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "operator": { - "description": "The account that executed the send message", - "type": "string" - }, - "token_id": { - "type": "string" - } - }, - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw1155-base/schema/instantiate_msg.json b/contracts/cw1155-base/schema/instantiate_msg.json deleted file mode 100644 index 3f5eaf0ce..000000000 --- a/contracts/cw1155-base/schema/instantiate_msg.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "minter" - ], - "properties": { - "minter": { - "description": "The minter is the only one who can create new tokens. This is designed for a base token platform that is controlled by an external program or contract.", - "type": "string" - } - } -} diff --git a/contracts/cw1155-base/schema/is_approved_for_all_response.json b/contracts/cw1155-base/schema/is_approved_for_all_response.json deleted file mode 100644 index e3af7a983..000000000 --- a/contracts/cw1155-base/schema/is_approved_for_all_response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "IsApprovedForAllResponse", - "type": "object", - "required": [ - "approved" - ], - "properties": { - "approved": { - "type": "boolean" - } - } -} diff --git a/contracts/cw1155-base/schema/token_info_response.json b/contracts/cw1155-base/schema/token_info_response.json deleted file mode 100644 index a94af98e3..000000000 --- a/contracts/cw1155-base/schema/token_info_response.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TokenInfoResponse", - "type": "object", - "required": [ - "url" - ], - "properties": { - "url": { - "description": "Should be a url point to a json file", - "type": "string" - } - } -} diff --git a/contracts/cw1155-base/schema/tokens_response.json b/contracts/cw1155-base/schema/tokens_response.json deleted file mode 100644 index b8e3d75b5..000000000 --- a/contracts/cw1155-base/schema/tokens_response.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TokensResponse", - "type": "object", - "required": [ - "tokens" - ], - "properties": { - "tokens": { - "description": "Contains all token_ids in lexicographical ordering If there are more than `limit`, use `start_from` in future queries to achieve pagination.", - "type": "array", - "items": { - "type": "string" - } - } - } -} diff --git a/contracts/cw20-atomic-swap/schema/details_response.json b/contracts/cw20-atomic-swap/schema/details_response.json deleted file mode 100644 index efead08b7..000000000 --- a/contracts/cw20-atomic-swap/schema/details_response.json +++ /dev/null @@ -1,172 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "DetailsResponse", - "type": "object", - "required": [ - "balance", - "expires", - "hash", - "id", - "recipient", - "source" - ], - "properties": { - "balance": { - "description": "Balance in native tokens or cw20 token, with human-readable address", - "allOf": [ - { - "$ref": "#/definitions/BalanceHuman" - } - ] - }, - "expires": { - "description": "Once a swap is expired, it can be returned to the original source (via \"refund\").", - "allOf": [ - { - "$ref": "#/definitions/Expiration" - } - ] - }, - "hash": { - "description": "This is hex-encoded sha-256 hash of the preimage (must be 32*2 = 64 chars)", - "type": "string" - }, - "id": { - "description": "Id of this swap", - "type": "string" - }, - "recipient": { - "description": "If released, funds go to the recipient", - "type": "string" - }, - "source": { - "description": "If refunded, funds go to the source", - "type": "string" - } - }, - "definitions": { - "BalanceHuman": { - "oneOf": [ - { - "type": "object", - "required": [ - "Native" - ], - "properties": { - "Native": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "Cw20" - ], - "properties": { - "Cw20": { - "$ref": "#/definitions/Cw20Coin" - } - }, - "additionalProperties": false - } - ] - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "Cw20Coin": { - "type": "object", - "required": [ - "address", - "amount" - ], - "properties": { - "address": { - "type": "string" - }, - "amount": { - "$ref": "#/definitions/Uint128" - } - } - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-atomic-swap/schema/execute_msg.json b/contracts/cw20-atomic-swap/schema/execute_msg.json deleted file mode 100644 index 87d528567..000000000 --- a/contracts/cw20-atomic-swap/schema/execute_msg.json +++ /dev/null @@ -1,197 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "create" - ], - "properties": { - "create": { - "$ref": "#/definitions/CreateMsg" - } - }, - "additionalProperties": false - }, - { - "description": "Release sends all tokens to the recipient.", - "type": "object", - "required": [ - "release" - ], - "properties": { - "release": { - "type": "object", - "required": [ - "id", - "preimage" - ], - "properties": { - "id": { - "type": "string" - }, - "preimage": { - "description": "This is the preimage, must be exactly 32 bytes in hex (64 chars) to release: sha256(from_hex(preimage)) == from_hex(hash)", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Refund returns all remaining tokens to the original sender,", - "type": "object", - "required": [ - "refund" - ], - "properties": { - "refund": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This accepts a properly-encoded ReceiveMsg from a cw20 contract", - "type": "object", - "required": [ - "receive" - ], - "properties": { - "receive": { - "$ref": "#/definitions/Cw20ReceiveMsg" - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "CreateMsg": { - "type": "object", - "required": [ - "expires", - "hash", - "id", - "recipient" - ], - "properties": { - "expires": { - "description": "You can set expiration at time or at block height the contract is valid at. After the contract is expired, it can be returned to the original funder.", - "allOf": [ - { - "$ref": "#/definitions/Expiration" - } - ] - }, - "hash": { - "description": "This is hex-encoded sha-256 hash of the preimage (must be 32*2 = 64 chars)", - "type": "string" - }, - "id": { - "description": "id is a human-readable name for the swap to use later. 3-20 bytes of utf-8 text", - "type": "string" - }, - "recipient": { - "description": "If approved, funds go to the recipient", - "type": "string" - } - } - }, - "Cw20ReceiveMsg": { - "description": "Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg", - "type": "object", - "required": [ - "amount", - "msg", - "sender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "sender": { - "type": "string" - } - } - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-atomic-swap/schema/instantiate_msg.json b/contracts/cw20-atomic-swap/schema/instantiate_msg.json deleted file mode 100644 index 44588cf22..000000000 --- a/contracts/cw20-atomic-swap/schema/instantiate_msg.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object" -} diff --git a/contracts/cw20-atomic-swap/schema/list_response.json b/contracts/cw20-atomic-swap/schema/list_response.json deleted file mode 100644 index 47fba1bf8..000000000 --- a/contracts/cw20-atomic-swap/schema/list_response.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ListResponse", - "type": "object", - "required": [ - "swaps" - ], - "properties": { - "swaps": { - "description": "List all open swap ids", - "type": "array", - "items": { - "type": "string" - } - } - } -} diff --git a/contracts/cw20-atomic-swap/schema/query_msg.json b/contracts/cw20-atomic-swap/schema/query_msg.json deleted file mode 100644 index 5d9108d31..000000000 --- a/contracts/cw20-atomic-swap/schema/query_msg.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Show all open swaps. Return type is ListResponse.", - "type": "object", - "required": [ - "list" - ], - "properties": { - "list": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns the details of the named swap, error if not created. Return type: DetailsResponse.", - "type": "object", - "required": [ - "details" - ], - "properties": { - "details": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw20-base/schema/all_accounts_response.json b/contracts/cw20-base/schema/all_accounts_response.json deleted file mode 100644 index cea50fba4..000000000 --- a/contracts/cw20-base/schema/all_accounts_response.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AllAccountsResponse", - "type": "object", - "required": [ - "accounts" - ], - "properties": { - "accounts": { - "type": "array", - "items": { - "type": "string" - } - } - } -} diff --git a/contracts/cw20-base/schema/all_allowances_response.json b/contracts/cw20-base/schema/all_allowances_response.json deleted file mode 100644 index 6bb2291ce..000000000 --- a/contracts/cw20-base/schema/all_allowances_response.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AllAllowancesResponse", - "type": "object", - "required": [ - "allowances" - ], - "properties": { - "allowances": { - "type": "array", - "items": { - "$ref": "#/definitions/AllowanceInfo" - } - } - }, - "definitions": { - "AllowanceInfo": { - "type": "object", - "required": [ - "allowance", - "expires", - "spender" - ], - "properties": { - "allowance": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "$ref": "#/definitions/Expiration" - }, - "spender": { - "type": "string" - } - } - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-base/schema/allowance_response.json b/contracts/cw20-base/schema/allowance_response.json deleted file mode 100644 index c4f98d6fc..000000000 --- a/contracts/cw20-base/schema/allowance_response.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AllowanceResponse", - "type": "object", - "required": [ - "allowance", - "expires" - ], - "properties": { - "allowance": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "$ref": "#/definitions/Expiration" - } - }, - "definitions": { - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-base/schema/balance_response.json b/contracts/cw20-base/schema/balance_response.json deleted file mode 100644 index 4e1a0be2b..000000000 --- a/contracts/cw20-base/schema/balance_response.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BalanceResponse", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-base/schema/cw20_execute_msg.json b/contracts/cw20-base/schema/cw20_execute_msg.json deleted file mode 100644 index e4bc559cd..000000000 --- a/contracts/cw20-base/schema/cw20_execute_msg.json +++ /dev/null @@ -1,442 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Cw20ExecuteMsg", - "oneOf": [ - { - "description": "Transfer is a base message to move tokens to another account without triggering actions", - "type": "object", - "required": [ - "transfer" - ], - "properties": { - "transfer": { - "type": "object", - "required": [ - "amount", - "recipient" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "recipient": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Burn is a base message to destroy tokens forever", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Send is a base message to transfer tokens to a contract and trigger an action on the receiving contract.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "contract", - "msg" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "contract": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"approval\" extension. Allows spender to access an additional amount tokens from the owner's (env.sender) account. If expires is Some(), overwrites current allowance expiration with this one.", - "type": "object", - "required": [ - "increase_allowance" - ], - "properties": { - "increase_allowance": { - "type": "object", - "required": [ - "amount", - "spender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"approval\" extension. Lowers the spender's access of tokens from the owner's (env.sender) account by amount. If expires is Some(), overwrites current allowance expiration with this one.", - "type": "object", - "required": [ - "decrease_allowance" - ], - "properties": { - "decrease_allowance": { - "type": "object", - "required": [ - "amount", - "spender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"approval\" extension. Transfers amount tokens from owner -> recipient if `env.sender` has sufficient pre-approval.", - "type": "object", - "required": [ - "transfer_from" - ], - "properties": { - "transfer_from": { - "type": "object", - "required": [ - "amount", - "owner", - "recipient" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "owner": { - "type": "string" - }, - "recipient": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"approval\" extension. Sends amount tokens from owner -> contract if `env.sender` has sufficient pre-approval.", - "type": "object", - "required": [ - "send_from" - ], - "properties": { - "send_from": { - "type": "object", - "required": [ - "amount", - "contract", - "msg", - "owner" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "contract": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "owner": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"approval\" extension. Destroys tokens forever", - "type": "object", - "required": [ - "burn_from" - ], - "properties": { - "burn_from": { - "type": "object", - "required": [ - "amount", - "owner" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "owner": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with the \"mintable\" extension. If authorized, creates amount new tokens and adds to the recipient balance.", - "type": "object", - "required": [ - "mint" - ], - "properties": { - "mint": { - "type": "object", - "required": [ - "amount", - "recipient" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "recipient": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with the \"marketing\" extension. If authorized, updates marketing metadata. Setting None/null for any of these will leave it unchanged. Setting Some(\"\") will clear this field on the contract storage", - "type": "object", - "required": [ - "update_marketing" - ], - "properties": { - "update_marketing": { - "type": "object", - "properties": { - "description": { - "description": "A longer description of the token and it's utility. Designed for tooltips or such", - "type": [ - "string", - "null" - ] - }, - "marketing": { - "description": "The address (if any) who can update this data structure", - "type": [ - "string", - "null" - ] - }, - "project": { - "description": "A URL pointing to the project behind this token.", - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "If set as the \"marketing\" role on the contract, upload a new URL, SVG, or PNG for the token", - "type": "object", - "required": [ - "upload_logo" - ], - "properties": { - "upload_logo": { - "$ref": "#/definitions/Logo" - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "EmbeddedLogo": { - "description": "This is used to store the logo on the blockchain in an accepted format. Enforce maximum size of 5KB on all variants.", - "oneOf": [ - { - "description": "Store the Logo as an SVG file. The content must conform to the spec at https://en.wikipedia.org/wiki/Scalable_Vector_Graphics (The contract should do some light-weight sanity-check validation)", - "type": "object", - "required": [ - "svg" - ], - "properties": { - "svg": { - "$ref": "#/definitions/Binary" - } - }, - "additionalProperties": false - }, - { - "description": "Store the Logo as a PNG file. This will likely only support up to 64x64 or so within the 5KB limit.", - "type": "object", - "required": [ - "png" - ], - "properties": { - "png": { - "$ref": "#/definitions/Binary" - } - }, - "additionalProperties": false - } - ] - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Logo": { - "description": "This is used for uploading logo data, or setting it in InstantiateData", - "oneOf": [ - { - "description": "A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL.", - "type": "object", - "required": [ - "url" - ], - "properties": { - "url": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "description": "Logo content stored on the blockchain. Enforce maximum size of 5KB on all variants", - "type": "object", - "required": [ - "embedded" - ], - "properties": { - "embedded": { - "$ref": "#/definitions/EmbeddedLogo" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-base/schema/instantiate_msg.json b/contracts/cw20-base/schema/instantiate_msg.json deleted file mode 100644 index 7b9aa1eeb..000000000 --- a/contracts/cw20-base/schema/instantiate_msg.json +++ /dev/null @@ -1,192 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "decimals", - "initial_balances", - "name", - "symbol" - ], - "properties": { - "decimals": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "initial_balances": { - "type": "array", - "items": { - "$ref": "#/definitions/Cw20Coin" - } - }, - "marketing": { - "anyOf": [ - { - "$ref": "#/definitions/InstantiateMarketingInfo" - }, - { - "type": "null" - } - ] - }, - "mint": { - "anyOf": [ - { - "$ref": "#/definitions/MinterResponse" - }, - { - "type": "null" - } - ] - }, - "name": { - "type": "string" - }, - "symbol": { - "type": "string" - } - }, - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Cw20Coin": { - "type": "object", - "required": [ - "address", - "amount" - ], - "properties": { - "address": { - "type": "string" - }, - "amount": { - "$ref": "#/definitions/Uint128" - } - } - }, - "EmbeddedLogo": { - "description": "This is used to store the logo on the blockchain in an accepted format. Enforce maximum size of 5KB on all variants.", - "oneOf": [ - { - "description": "Store the Logo as an SVG file. The content must conform to the spec at https://en.wikipedia.org/wiki/Scalable_Vector_Graphics (The contract should do some light-weight sanity-check validation)", - "type": "object", - "required": [ - "svg" - ], - "properties": { - "svg": { - "$ref": "#/definitions/Binary" - } - }, - "additionalProperties": false - }, - { - "description": "Store the Logo as a PNG file. This will likely only support up to 64x64 or so within the 5KB limit.", - "type": "object", - "required": [ - "png" - ], - "properties": { - "png": { - "$ref": "#/definitions/Binary" - } - }, - "additionalProperties": false - } - ] - }, - "InstantiateMarketingInfo": { - "type": "object", - "properties": { - "description": { - "type": [ - "string", - "null" - ] - }, - "logo": { - "anyOf": [ - { - "$ref": "#/definitions/Logo" - }, - { - "type": "null" - } - ] - }, - "marketing": { - "type": [ - "string", - "null" - ] - }, - "project": { - "type": [ - "string", - "null" - ] - } - } - }, - "Logo": { - "description": "This is used for uploading logo data, or setting it in InstantiateData", - "oneOf": [ - { - "description": "A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL.", - "type": "object", - "required": [ - "url" - ], - "properties": { - "url": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "description": "Logo content stored on the blockchain. Enforce maximum size of 5KB on all variants", - "type": "object", - "required": [ - "embedded" - ], - "properties": { - "embedded": { - "$ref": "#/definitions/EmbeddedLogo" - } - }, - "additionalProperties": false - } - ] - }, - "MinterResponse": { - "type": "object", - "required": [ - "minter" - ], - "properties": { - "cap": { - "description": "cap is a hard cap on total supply that can be achieved by minting. Note that this refers to total_supply. If None, there is unlimited cap.", - "anyOf": [ - { - "$ref": "#/definitions/Uint128" - }, - { - "type": "null" - } - ] - }, - "minter": { - "type": "string" - } - } - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-base/schema/query_msg.json b/contracts/cw20-base/schema/query_msg.json deleted file mode 100644 index 369e21f07..000000000 --- a/contracts/cw20-base/schema/query_msg.json +++ /dev/null @@ -1,168 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Returns the current balance of the given address, 0 if unset. Return type: BalanceResponse.", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns metadata on the contract - name, decimals, supply, etc. Return type: TokenInfoResponse.", - "type": "object", - "required": [ - "token_info" - ], - "properties": { - "token_info": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"mintable\" extension. Returns who can mint and the hard cap on maximum tokens after minting. Return type: MinterResponse.", - "type": "object", - "required": [ - "minter" - ], - "properties": { - "minter": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"allowance\" extension. Returns how much spender can use from owner account, 0 if unset. Return type: AllowanceResponse.", - "type": "object", - "required": [ - "allowance" - ], - "properties": { - "allowance": { - "type": "object", - "required": [ - "owner", - "spender" - ], - "properties": { - "owner": { - "type": "string" - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"enumerable\" extension (and \"allowances\") Returns all allowances this owner has approved. Supports pagination. Return type: AllAllowancesResponse.", - "type": "object", - "required": [ - "all_allowances" - ], - "properties": { - "all_allowances": { - "type": "object", - "required": [ - "owner" - ], - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "owner": { - "type": "string" - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"enumerable\" extension Returns all accounts that have balances. Supports pagination. Return type: AllAccountsResponse.", - "type": "object", - "required": [ - "all_accounts" - ], - "properties": { - "all_accounts": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"marketing\" extension Returns more metadata on the contract to display in the client: - description, logo, project url, etc. Return type: MarketingInfoResponse", - "type": "object", - "required": [ - "marketing_info" - ], - "properties": { - "marketing_info": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Only with \"marketing\" extension Downloads the mbeded logo data (if stored on chain). Errors if no logo data ftored for this contract. Return type: DownloadLogoResponse.", - "type": "object", - "required": [ - "download_logo" - ], - "properties": { - "download_logo": { - "type": "object" - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw20-base/schema/token_info_response.json b/contracts/cw20-base/schema/token_info_response.json deleted file mode 100644 index 9920c841f..000000000 --- a/contracts/cw20-base/schema/token_info_response.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TokenInfoResponse", - "type": "object", - "required": [ - "decimals", - "name", - "symbol", - "total_supply" - ], - "properties": { - "decimals": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "name": { - "type": "string" - }, - "symbol": { - "type": "string" - }, - "total_supply": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-bonding/schema/allowance_response.json b/contracts/cw20-bonding/schema/allowance_response.json deleted file mode 100644 index c4f98d6fc..000000000 --- a/contracts/cw20-bonding/schema/allowance_response.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AllowanceResponse", - "type": "object", - "required": [ - "allowance", - "expires" - ], - "properties": { - "allowance": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "$ref": "#/definitions/Expiration" - } - }, - "definitions": { - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-bonding/schema/balance_response.json b/contracts/cw20-bonding/schema/balance_response.json deleted file mode 100644 index 4e1a0be2b..000000000 --- a/contracts/cw20-bonding/schema/balance_response.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BalanceResponse", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-bonding/schema/curve_info_response.json b/contracts/cw20-bonding/schema/curve_info_response.json deleted file mode 100644 index 85c4112b6..000000000 --- a/contracts/cw20-bonding/schema/curve_info_response.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "CurveInfoResponse", - "type": "object", - "required": [ - "reserve", - "reserve_denom", - "spot_price", - "supply" - ], - "properties": { - "reserve": { - "$ref": "#/definitions/Uint128" - }, - "reserve_denom": { - "type": "string" - }, - "spot_price": { - "$ref": "#/definitions/Decimal" - }, - "supply": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-bonding/schema/execute_msg.json b/contracts/cw20-bonding/schema/execute_msg.json deleted file mode 100644 index 647bcf381..000000000 --- a/contracts/cw20-bonding/schema/execute_msg.json +++ /dev/null @@ -1,319 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "description": "Buy will attempt to purchase as many supply tokens as possible. You must send only reserve tokens in that message", - "type": "object", - "required": [ - "buy" - ], - "properties": { - "buy": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20. Transfer is a base message to move tokens to another account without triggering actions", - "type": "object", - "required": [ - "transfer" - ], - "properties": { - "transfer": { - "type": "object", - "required": [ - "amount", - "recipient" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "recipient": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20. Burn is a base message to destroy tokens forever", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20. Send is a base message to transfer tokens to a contract and trigger an action on the receiving contract.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "contract", - "msg" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "contract": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"approval\" extension. Allows spender to access an additional amount tokens from the owner's (env.sender) account. If expires is Some(), overwrites current allowance expiration with this one.", - "type": "object", - "required": [ - "increase_allowance" - ], - "properties": { - "increase_allowance": { - "type": "object", - "required": [ - "amount", - "spender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"approval\" extension. Lowers the spender's access of tokens from the owner's (env.sender) account by amount. If expires is Some(), overwrites current allowance expiration with this one.", - "type": "object", - "required": [ - "decrease_allowance" - ], - "properties": { - "decrease_allowance": { - "type": "object", - "required": [ - "amount", - "spender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"approval\" extension. Transfers amount tokens from owner -> recipient if `env.sender` has sufficient pre-approval.", - "type": "object", - "required": [ - "transfer_from" - ], - "properties": { - "transfer_from": { - "type": "object", - "required": [ - "amount", - "owner", - "recipient" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "owner": { - "type": "string" - }, - "recipient": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"approval\" extension. Sends amount tokens from owner -> contract if `env.sender` has sufficient pre-approval.", - "type": "object", - "required": [ - "send_from" - ], - "properties": { - "send_from": { - "type": "object", - "required": [ - "amount", - "contract", - "msg", - "owner" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "contract": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "owner": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"approval\" extension. Destroys tokens forever", - "type": "object", - "required": [ - "burn_from" - ], - "properties": { - "burn_from": { - "type": "object", - "required": [ - "amount", - "owner" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "owner": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-bonding/schema/instantiate_msg.json b/contracts/cw20-bonding/schema/instantiate_msg.json deleted file mode 100644 index 3e968e673..000000000 --- a/contracts/cw20-bonding/schema/instantiate_msg.json +++ /dev/null @@ -1,138 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "curve_type", - "decimals", - "name", - "reserve_decimals", - "reserve_denom", - "symbol" - ], - "properties": { - "curve_type": { - "description": "enum to store the curve parameters used for this contract if you want to add a custom Curve, you should make a new contract that imports this one. write a custom `instantiate`, and then dispatch `your::execute` -> `cw20_bonding::do_execute` with your custom curve as a parameter (and same with `query` -> `do_query`)", - "allOf": [ - { - "$ref": "#/definitions/CurveType" - } - ] - }, - "decimals": { - "description": "number of decimal places of the supply token, needed for proper curve math. If it is eg. BTC, where a balance of 10^8 means 1 BTC, then use 8 here.", - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "name": { - "description": "name of the supply token", - "type": "string" - }, - "reserve_decimals": { - "description": "number of decimal places for the reserve token, needed for proper curve math. Same format as decimals above, eg. if it is uatom, where 1 unit is 10^-6 ATOM, use 6 here", - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "reserve_denom": { - "description": "this is the reserve token denom (only support native for now)", - "type": "string" - }, - "symbol": { - "description": "symbol / ticker of the supply token", - "type": "string" - } - }, - "definitions": { - "CurveType": { - "oneOf": [ - { - "description": "Constant always returns `value * 10^-scale` as spot price", - "type": "object", - "required": [ - "constant" - ], - "properties": { - "constant": { - "type": "object", - "required": [ - "scale", - "value" - ], - "properties": { - "scale": { - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "value": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Linear returns `slope * 10^-scale * supply` as spot price", - "type": "object", - "required": [ - "linear" - ], - "properties": { - "linear": { - "type": "object", - "required": [ - "scale", - "slope" - ], - "properties": { - "scale": { - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "slope": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "SquareRoot returns `slope * 10^-scale * supply^0.5` as spot price", - "type": "object", - "required": [ - "square_root" - ], - "properties": { - "square_root": { - "type": "object", - "required": [ - "scale", - "slope" - ], - "properties": { - "scale": { - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "slope": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-bonding/schema/query_msg.json b/contracts/cw20-bonding/schema/query_msg.json deleted file mode 100644 index e28d26b41..000000000 --- a/contracts/cw20-bonding/schema/query_msg.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Returns the reserve and supply quantities, as well as the spot price to buy 1 token", - "type": "object", - "required": [ - "curve_info" - ], - "properties": { - "curve_info": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20. Returns the current balance of the given address, 0 if unset.", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20. Returns metadata on the contract - name, decimals, supply, etc.", - "type": "object", - "required": [ - "token_info" - ], - "properties": { - "token_info": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"allowance\" extension. Returns how much spender can use from owner account, 0 if unset.", - "type": "object", - "required": [ - "allowance" - ], - "properties": { - "allowance": { - "type": "object", - "required": [ - "owner", - "spender" - ], - "properties": { - "owner": { - "type": "string" - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw20-bonding/schema/token_info_response.json b/contracts/cw20-bonding/schema/token_info_response.json deleted file mode 100644 index 9920c841f..000000000 --- a/contracts/cw20-bonding/schema/token_info_response.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TokenInfoResponse", - "type": "object", - "required": [ - "decimals", - "name", - "symbol", - "total_supply" - ], - "properties": { - "decimals": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "name": { - "type": "string" - }, - "symbol": { - "type": "string" - }, - "total_supply": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-escrow/schema/details_response.json b/contracts/cw20-escrow/schema/details_response.json deleted file mode 100644 index 49aa39622..000000000 --- a/contracts/cw20-escrow/schema/details_response.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "DetailsResponse", - "type": "object", - "required": [ - "arbiter", - "cw20_balance", - "cw20_whitelist", - "id", - "native_balance", - "recipient", - "source" - ], - "properties": { - "arbiter": { - "description": "arbiter can decide to approve or refund the escrow", - "type": "string" - }, - "cw20_balance": { - "description": "Balance in cw20 tokens", - "type": "array", - "items": { - "$ref": "#/definitions/Cw20Coin" - } - }, - "cw20_whitelist": { - "description": "Whitelisted cw20 tokens", - "type": "array", - "items": { - "type": "string" - } - }, - "end_height": { - "description": "When end height set and block height exceeds this value, the escrow is expired. Once an escrow is expired, it can be returned to the original funder (via \"refund\").", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "end_time": { - "description": "When end time (in seconds since epoch 00:00:00 UTC on 1 January 1970) is set and block time exceeds this value, the escrow is expired. Once an escrow is expired, it can be returned to the original funder (via \"refund\").", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "id": { - "description": "id of this escrow", - "type": "string" - }, - "native_balance": { - "description": "Balance in native tokens", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "recipient": { - "description": "if approved, funds go to the recipient", - "type": "string" - }, - "source": { - "description": "if refunded, funds go to the source", - "type": "string" - } - }, - "definitions": { - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "Cw20Coin": { - "type": "object", - "required": [ - "address", - "amount" - ], - "properties": { - "address": { - "type": "string" - }, - "amount": { - "$ref": "#/definitions/Uint128" - } - } - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-escrow/schema/execute_msg.json b/contracts/cw20-escrow/schema/execute_msg.json deleted file mode 100644 index 8c397b1bd..000000000 --- a/contracts/cw20-escrow/schema/execute_msg.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "create" - ], - "properties": { - "create": { - "$ref": "#/definitions/CreateMsg" - } - }, - "additionalProperties": false - }, - { - "description": "Adds all sent native tokens to the contract", - "type": "object", - "required": [ - "top_up" - ], - "properties": { - "top_up": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Approve sends all tokens to the recipient. Only the arbiter can do this", - "type": "object", - "required": [ - "approve" - ], - "properties": { - "approve": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "description": "id is a human-readable name for the escrow from create", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Refund returns all remaining tokens to the original sender, The arbiter can do this any time, or anyone can do this after a timeout", - "type": "object", - "required": [ - "refund" - ], - "properties": { - "refund": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "description": "id is a human-readable name for the escrow from create", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This accepts a properly-encoded ReceiveMsg from a cw20 contract", - "type": "object", - "required": [ - "receive" - ], - "properties": { - "receive": { - "$ref": "#/definitions/Cw20ReceiveMsg" - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "CreateMsg": { - "type": "object", - "required": [ - "arbiter", - "id", - "recipient" - ], - "properties": { - "arbiter": { - "description": "arbiter can decide to approve or refund the escrow", - "type": "string" - }, - "cw20_whitelist": { - "description": "Besides any possible tokens sent with the CreateMsg, this is a list of all cw20 token addresses that are accepted by the escrow during a top-up. This is required to avoid a DoS attack by topping-up with an invalid cw20 contract. See https://github.com/CosmWasm/cosmwasm-plus/issues/19", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "end_height": { - "description": "When end height set and block height exceeds this value, the escrow is expired. Once an escrow is expired, it can be returned to the original funder (via \"refund\").", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "end_time": { - "description": "When end time (in seconds since epoch 00:00:00 UTC on 1 January 1970) is set and block time exceeds this value, the escrow is expired. Once an escrow is expired, it can be returned to the original funder (via \"refund\").", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "id": { - "description": "id is a human-readable name for the escrow to use later 3-20 bytes of utf-8 text", - "type": "string" - }, - "recipient": { - "description": "if approved, funds go to the recipient", - "type": "string" - } - } - }, - "Cw20ReceiveMsg": { - "description": "Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg", - "type": "object", - "required": [ - "amount", - "msg", - "sender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "sender": { - "type": "string" - } - } - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-escrow/schema/instantiate_msg.json b/contracts/cw20-escrow/schema/instantiate_msg.json deleted file mode 100644 index 44588cf22..000000000 --- a/contracts/cw20-escrow/schema/instantiate_msg.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object" -} diff --git a/contracts/cw20-escrow/schema/list_response.json b/contracts/cw20-escrow/schema/list_response.json deleted file mode 100644 index c775191a2..000000000 --- a/contracts/cw20-escrow/schema/list_response.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ListResponse", - "type": "object", - "required": [ - "escrows" - ], - "properties": { - "escrows": { - "description": "list all registered ids", - "type": "array", - "items": { - "type": "string" - } - } - } -} diff --git a/contracts/cw20-escrow/schema/query_msg.json b/contracts/cw20-escrow/schema/query_msg.json deleted file mode 100644 index 8befec1aa..000000000 --- a/contracts/cw20-escrow/schema/query_msg.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Show all open escrows. Return type is ListResponse.", - "type": "object", - "required": [ - "list" - ], - "properties": { - "list": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Returns the details of the named escrow, error if not created Return type: DetailsResponse.", - "type": "object", - "required": [ - "details" - ], - "properties": { - "details": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw20-escrow/schema/receive_msg.json b/contracts/cw20-escrow/schema/receive_msg.json deleted file mode 100644 index 15dd2342b..000000000 --- a/contracts/cw20-escrow/schema/receive_msg.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ReceiveMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "create" - ], - "properties": { - "create": { - "$ref": "#/definitions/CreateMsg" - } - }, - "additionalProperties": false - }, - { - "description": "Adds all sent native tokens to the contract", - "type": "object", - "required": [ - "top_up" - ], - "properties": { - "top_up": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "CreateMsg": { - "type": "object", - "required": [ - "arbiter", - "id", - "recipient" - ], - "properties": { - "arbiter": { - "description": "arbiter can decide to approve or refund the escrow", - "type": "string" - }, - "cw20_whitelist": { - "description": "Besides any possible tokens sent with the CreateMsg, this is a list of all cw20 token addresses that are accepted by the escrow during a top-up. This is required to avoid a DoS attack by topping-up with an invalid cw20 contract. See https://github.com/CosmWasm/cosmwasm-plus/issues/19", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "end_height": { - "description": "When end height set and block height exceeds this value, the escrow is expired. Once an escrow is expired, it can be returned to the original funder (via \"refund\").", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "end_time": { - "description": "When end time (in seconds since epoch 00:00:00 UTC on 1 January 1970) is set and block time exceeds this value, the escrow is expired. Once an escrow is expired, it can be returned to the original funder (via \"refund\").", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "id": { - "description": "id is a human-readable name for the escrow to use later 3-20 bytes of utf-8 text", - "type": "string" - }, - "recipient": { - "description": "if approved, funds go to the recipient", - "type": "string" - } - } - } - } -} diff --git a/contracts/cw20-ics20/schema/channel_response.json b/contracts/cw20-ics20/schema/channel_response.json deleted file mode 100644 index 89f70534d..000000000 --- a/contracts/cw20-ics20/schema/channel_response.json +++ /dev/null @@ -1,139 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ChannelResponse", - "type": "object", - "required": [ - "balances", - "info", - "total_sent" - ], - "properties": { - "balances": { - "description": "How many tokens we currently have pending over this channel", - "type": "array", - "items": { - "$ref": "#/definitions/Amount" - } - }, - "info": { - "description": "Information on the channel's connection", - "allOf": [ - { - "$ref": "#/definitions/ChannelInfo" - } - ] - }, - "total_sent": { - "description": "The total number of tokens that have been sent over this channel (even if many have been returned, so balance is low)", - "type": "array", - "items": { - "$ref": "#/definitions/Amount" - } - } - }, - "definitions": { - "Amount": { - "oneOf": [ - { - "type": "object", - "required": [ - "native" - ], - "properties": { - "native": { - "$ref": "#/definitions/Coin" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "cw20" - ], - "properties": { - "cw20": { - "$ref": "#/definitions/Cw20Coin" - } - }, - "additionalProperties": false - } - ] - }, - "ChannelInfo": { - "type": "object", - "required": [ - "connection_id", - "counterparty_endpoint", - "id" - ], - "properties": { - "connection_id": { - "description": "the connection this exists on (you can use to query client/consensus info)", - "type": "string" - }, - "counterparty_endpoint": { - "description": "the remote channel/port we connect to", - "allOf": [ - { - "$ref": "#/definitions/IbcEndpoint" - } - ] - }, - "id": { - "description": "id of this channel", - "type": "string" - } - } - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "Cw20Coin": { - "type": "object", - "required": [ - "address", - "amount" - ], - "properties": { - "address": { - "type": "string" - }, - "amount": { - "$ref": "#/definitions/Uint128" - } - } - }, - "IbcEndpoint": { - "type": "object", - "required": [ - "channel_id", - "port_id" - ], - "properties": { - "channel_id": { - "type": "string" - }, - "port_id": { - "type": "string" - } - } - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-ics20/schema/execute_msg.json b/contracts/cw20-ics20/schema/execute_msg.json deleted file mode 100644 index 5c6014ed8..000000000 --- a/contracts/cw20-ics20/schema/execute_msg.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "description": "This accepts a properly-encoded ReceiveMsg from a cw20 contract", - "type": "object", - "required": [ - "receive" - ], - "properties": { - "receive": { - "$ref": "#/definitions/Cw20ReceiveMsg" - } - }, - "additionalProperties": false - }, - { - "description": "This allows us to transfer *exactly one* native token", - "type": "object", - "required": [ - "transfer" - ], - "properties": { - "transfer": { - "$ref": "#/definitions/TransferMsg" - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Cw20ReceiveMsg": { - "description": "Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg", - "type": "object", - "required": [ - "amount", - "msg", - "sender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "sender": { - "type": "string" - } - } - }, - "TransferMsg": { - "description": "This is the message we accept via Receive", - "type": "object", - "required": [ - "channel", - "remote_address" - ], - "properties": { - "channel": { - "description": "The local channel to send the packets on", - "type": "string" - }, - "remote_address": { - "description": "The remote address to send to. Don't use HumanAddress as this will likely have a different Bech32 prefix than we use and cannot be validated locally", - "type": "string" - }, - "timeout": { - "description": "How long the packet lives in seconds. If not specified, use default_timeout", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-ics20/schema/init_msg.json b/contracts/cw20-ics20/schema/init_msg.json deleted file mode 100644 index 5d6d75f64..000000000 --- a/contracts/cw20-ics20/schema/init_msg.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InitMsg", - "type": "object", - "required": [ - "default_timeout" - ], - "properties": { - "default_timeout": { - "description": "Default timeout for ics20 packets, specified in seconds", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } -} diff --git a/contracts/cw20-ics20/schema/list_channels_response.json b/contracts/cw20-ics20/schema/list_channels_response.json deleted file mode 100644 index 69f020c93..000000000 --- a/contracts/cw20-ics20/schema/list_channels_response.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ListChannelsResponse", - "type": "object", - "required": [ - "channels" - ], - "properties": { - "channels": { - "type": "array", - "items": { - "$ref": "#/definitions/ChannelInfo" - } - } - }, - "definitions": { - "ChannelInfo": { - "type": "object", - "required": [ - "connection_id", - "counterparty_endpoint", - "id" - ], - "properties": { - "connection_id": { - "description": "the connection this exists on (you can use to query client/consensus info)", - "type": "string" - }, - "counterparty_endpoint": { - "description": "the remote channel/port we connect to", - "allOf": [ - { - "$ref": "#/definitions/IbcEndpoint" - } - ] - }, - "id": { - "description": "id of this channel", - "type": "string" - } - } - }, - "IbcEndpoint": { - "type": "object", - "required": [ - "channel_id", - "port_id" - ], - "properties": { - "channel_id": { - "type": "string" - }, - "port_id": { - "type": "string" - } - } - } - } -} diff --git a/contracts/cw20-ics20/schema/port_response.json b/contracts/cw20-ics20/schema/port_response.json deleted file mode 100644 index 4561b3a72..000000000 --- a/contracts/cw20-ics20/schema/port_response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "PortResponse", - "type": "object", - "required": [ - "port_id" - ], - "properties": { - "port_id": { - "type": "string" - } - } -} diff --git a/contracts/cw20-ics20/schema/query_msg.json b/contracts/cw20-ics20/schema/query_msg.json deleted file mode 100644 index 10ae51822..000000000 --- a/contracts/cw20-ics20/schema/query_msg.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Return the port ID bound by this contract. Returns PortResponse", - "type": "object", - "required": [ - "port" - ], - "properties": { - "port": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Show all channels we have connected to. Return type is ListChannelsResponse.", - "type": "object", - "required": [ - "list_channels" - ], - "properties": { - "list_channels": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Returns the details of the name channel, error if not created. Return type: ChannelResponse.", - "type": "object", - "required": [ - "channel" - ], - "properties": { - "channel": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw20-ics20/schema/transfer_msg.json b/contracts/cw20-ics20/schema/transfer_msg.json deleted file mode 100644 index ca47b20f8..000000000 --- a/contracts/cw20-ics20/schema/transfer_msg.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TransferMsg", - "description": "This is the message we accept via Receive", - "type": "object", - "required": [ - "channel", - "remote_address" - ], - "properties": { - "channel": { - "description": "The local channel to send the packets on", - "type": "string" - }, - "remote_address": { - "description": "The remote address to send to. Don't use HumanAddress as this will likely have a different Bech32 prefix than we use and cannot be validated locally", - "type": "string" - }, - "timeout": { - "description": "How long the packet lives in seconds. If not specified, use default_timeout", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } -} diff --git a/contracts/cw20-merkle-airdrop/schema/config_response.json b/contracts/cw20-merkle-airdrop/schema/config_response.json deleted file mode 100644 index a4db8a7a7..000000000 --- a/contracts/cw20-merkle-airdrop/schema/config_response.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ConfigResponse", - "type": "object", - "required": [ - "cw20_token_address" - ], - "properties": { - "cw20_token_address": { - "type": "string" - }, - "owner": { - "type": [ - "string", - "null" - ] - } - } -} diff --git a/contracts/cw20-merkle-airdrop/schema/execute_msg.json b/contracts/cw20-merkle-airdrop/schema/execute_msg.json deleted file mode 100644 index b4051d719..000000000 --- a/contracts/cw20-merkle-airdrop/schema/execute_msg.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "update_config" - ], - "properties": { - "update_config": { - "type": "object", - "properties": { - "new_owner": { - "description": "NewOwner if non sent, contract gets locked. Recipients can receive airdrops but owner cannot register new stages.", - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "register_merkle_root" - ], - "properties": { - "register_merkle_root": { - "type": "object", - "required": [ - "merkle_root" - ], - "properties": { - "merkle_root": { - "description": "MerkleRoot is hex-encoded merkle root.", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Claim does not check if contract has enough funds, owner must ensure it.", - "type": "object", - "required": [ - "claim" - ], - "properties": { - "claim": { - "type": "object", - "required": [ - "amount", - "proof", - "stage" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "proof": { - "description": "Proof is hex-encoded merkle proof.", - "type": "array", - "items": { - "type": "string" - } - }, - "stage": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-merkle-airdrop/schema/instantiate_msg.json b/contracts/cw20-merkle-airdrop/schema/instantiate_msg.json deleted file mode 100644 index 313cad00c..000000000 --- a/contracts/cw20-merkle-airdrop/schema/instantiate_msg.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "cw20_token_address" - ], - "properties": { - "cw20_token_address": { - "type": "string" - }, - "owner": { - "description": "Owner if none set to info.sender.", - "type": [ - "string", - "null" - ] - } - } -} diff --git a/contracts/cw20-merkle-airdrop/schema/is_claimed_response.json b/contracts/cw20-merkle-airdrop/schema/is_claimed_response.json deleted file mode 100644 index bc7fe782a..000000000 --- a/contracts/cw20-merkle-airdrop/schema/is_claimed_response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "IsClaimedResponse", - "type": "object", - "required": [ - "is_claimed" - ], - "properties": { - "is_claimed": { - "type": "boolean" - } - } -} diff --git a/contracts/cw20-merkle-airdrop/schema/latest_stage_response.json b/contracts/cw20-merkle-airdrop/schema/latest_stage_response.json deleted file mode 100644 index 4e274dc23..000000000 --- a/contracts/cw20-merkle-airdrop/schema/latest_stage_response.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "LatestStageResponse", - "type": "object", - "required": [ - "latest_stage" - ], - "properties": { - "latest_stage": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - } - } -} diff --git a/contracts/cw20-merkle-airdrop/schema/merkle_root_response.json b/contracts/cw20-merkle-airdrop/schema/merkle_root_response.json deleted file mode 100644 index 101b49f11..000000000 --- a/contracts/cw20-merkle-airdrop/schema/merkle_root_response.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MerkleRootResponse", - "type": "object", - "required": [ - "merkle_root", - "stage" - ], - "properties": { - "merkle_root": { - "description": "MerkleRoot is hex-encoded merkle root.", - "type": "string" - }, - "stage": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - } - } -} diff --git a/contracts/cw20-merkle-airdrop/schema/query_msg.json b/contracts/cw20-merkle-airdrop/schema/query_msg.json deleted file mode 100644 index 78da096b6..000000000 --- a/contracts/cw20-merkle-airdrop/schema/query_msg.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "config" - ], - "properties": { - "config": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "merkle_root" - ], - "properties": { - "merkle_root": { - "type": "object", - "required": [ - "stage" - ], - "properties": { - "stage": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "latest_stage" - ], - "properties": { - "latest_stage": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "is_claimed" - ], - "properties": { - "is_claimed": { - "type": "object", - "required": [ - "address", - "stage" - ], - "properties": { - "address": { - "type": "string" - }, - "stage": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw20-staking/schema/allowance_response.json b/contracts/cw20-staking/schema/allowance_response.json deleted file mode 100644 index c4f98d6fc..000000000 --- a/contracts/cw20-staking/schema/allowance_response.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AllowanceResponse", - "type": "object", - "required": [ - "allowance", - "expires" - ], - "properties": { - "allowance": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "$ref": "#/definitions/Expiration" - } - }, - "definitions": { - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-staking/schema/balance_response.json b/contracts/cw20-staking/schema/balance_response.json deleted file mode 100644 index 4e1a0be2b..000000000 --- a/contracts/cw20-staking/schema/balance_response.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BalanceResponse", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-staking/schema/claims_response.json b/contracts/cw20-staking/schema/claims_response.json deleted file mode 100644 index 08211a3c8..000000000 --- a/contracts/cw20-staking/schema/claims_response.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ClaimsResponse", - "type": "object", - "required": [ - "claims" - ], - "properties": { - "claims": { - "type": "array", - "items": { - "$ref": "#/definitions/Claim" - } - } - }, - "definitions": { - "Claim": { - "type": "object", - "required": [ - "amount", - "release_at" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "release_at": { - "$ref": "#/definitions/Expiration" - } - } - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-staking/schema/execute_msg.json b/contracts/cw20-staking/schema/execute_msg.json deleted file mode 100644 index 505a88d8d..000000000 --- a/contracts/cw20-staking/schema/execute_msg.json +++ /dev/null @@ -1,379 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "description": "Bond will bond all staking tokens sent with the message and release derivative tokens", - "type": "object", - "required": [ - "bond" - ], - "properties": { - "bond": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Unbond will \"burn\" the given amount of derivative tokens and send the unbonded staking tokens to the message sender (after exit tax is deducted)", - "type": "object", - "required": [ - "unbond" - ], - "properties": { - "unbond": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Claim is used to claim your native tokens that you previously \"unbonded\" after the chain-defined waiting period (eg. 3 weeks)", - "type": "object", - "required": [ - "claim" - ], - "properties": { - "claim": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Reinvest will check for all accumulated rewards, withdraw them, and re-bond them to the same validator. Anyone can call this, which updates the value of the token (how much under custody).", - "type": "object", - "required": [ - "reinvest" - ], - "properties": { - "reinvest": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "_BondAllTokens can only be called by the contract itself, after all rewards have been withdrawn. This is an example of using \"callbacks\" in message flows. This can only be invoked by the contract itself as a return from Reinvest", - "type": "object", - "required": [ - "__bond_all_tokens" - ], - "properties": { - "__bond_all_tokens": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20. Transfer is a base message to move tokens to another account without triggering actions", - "type": "object", - "required": [ - "transfer" - ], - "properties": { - "transfer": { - "type": "object", - "required": [ - "amount", - "recipient" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "recipient": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20. Burn is a base message to destroy tokens forever", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20. Send is a base message to transfer tokens to a contract and trigger an action on the receiving contract.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "contract", - "msg" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "contract": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"approval\" extension. Allows spender to access an additional amount tokens from the owner's (env.sender) account. If expires is Some(), overwrites current allowance expiration with this one.", - "type": "object", - "required": [ - "increase_allowance" - ], - "properties": { - "increase_allowance": { - "type": "object", - "required": [ - "amount", - "spender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"approval\" extension. Lowers the spender's access of tokens from the owner's (env.sender) account by amount. If expires is Some(), overwrites current allowance expiration with this one.", - "type": "object", - "required": [ - "decrease_allowance" - ], - "properties": { - "decrease_allowance": { - "type": "object", - "required": [ - "amount", - "spender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "expires": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"approval\" extension. Transfers amount tokens from owner -> recipient if `env.sender` has sufficient pre-approval.", - "type": "object", - "required": [ - "transfer_from" - ], - "properties": { - "transfer_from": { - "type": "object", - "required": [ - "amount", - "owner", - "recipient" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "owner": { - "type": "string" - }, - "recipient": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"approval\" extension. Sends amount tokens from owner -> contract if `env.sender` has sufficient pre-approval.", - "type": "object", - "required": [ - "send_from" - ], - "properties": { - "send_from": { - "type": "object", - "required": [ - "amount", - "contract", - "msg", - "owner" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "contract": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "owner": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"approval\" extension. Destroys tokens forever", - "type": "object", - "required": [ - "burn_from" - ], - "properties": { - "burn_from": { - "type": "object", - "required": [ - "amount", - "owner" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "owner": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-staking/schema/instantiate_msg.json b/contracts/cw20-staking/schema/instantiate_msg.json deleted file mode 100644 index 9979bf2ab..000000000 --- a/contracts/cw20-staking/schema/instantiate_msg.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "decimals", - "exit_tax", - "min_withdrawal", - "name", - "symbol", - "unbonding_period", - "validator" - ], - "properties": { - "decimals": { - "description": "decimal places of the derivative token (for UI)", - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "exit_tax": { - "description": "this is how much the owner takes as a cut when someone unbonds", - "allOf": [ - { - "$ref": "#/definitions/Decimal" - } - ] - }, - "min_withdrawal": { - "description": "This is the minimum amount we will pull out to reinvest, as well as a minimum that can be unbonded (to avoid needless staking tx)", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "name": { - "description": "name of the derivative token", - "type": "string" - }, - "symbol": { - "description": "symbol / ticker of the derivative token", - "type": "string" - }, - "unbonding_period": { - "description": "This is the unbonding period of the native staking module We need this to only allow claims to be redeemed after the money has arrived", - "allOf": [ - { - "$ref": "#/definitions/Duration" - } - ] - }, - "validator": { - "description": "This is the validator that all tokens will be bonded to", - "type": "string" - } - }, - "definitions": { - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - }, - "Duration": { - "description": "Duration is a delta of time. You can add it to a BlockInfo or Expiration to move that further in the future. Note that an height-based Duration and a time-based Expiration cannot be combined", - "oneOf": [ - { - "type": "object", - "required": [ - "height" - ], - "properties": { - "height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "Time in seconds", - "type": "object", - "required": [ - "time" - ], - "properties": { - "time": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-staking/schema/investment_response.json b/contracts/cw20-staking/schema/investment_response.json deleted file mode 100644 index c79ca56d3..000000000 --- a/contracts/cw20-staking/schema/investment_response.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InvestmentResponse", - "type": "object", - "required": [ - "exit_tax", - "min_withdrawal", - "nominal_value", - "owner", - "staked_tokens", - "token_supply", - "validator" - ], - "properties": { - "exit_tax": { - "description": "this is how much the owner takes as a cut when someone unbonds", - "allOf": [ - { - "$ref": "#/definitions/Decimal" - } - ] - }, - "min_withdrawal": { - "description": "This is the minimum amount we will pull out to reinvest, as well as a minimum that can be unbonded (to avoid needless staking tx)", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "nominal_value": { - "$ref": "#/definitions/Decimal" - }, - "owner": { - "description": "owner created the contract and takes a cut", - "type": "string" - }, - "staked_tokens": { - "$ref": "#/definitions/Coin" - }, - "token_supply": { - "$ref": "#/definitions/Uint128" - }, - "validator": { - "description": "All tokens are bonded to this validator", - "type": "string" - } - }, - "definitions": { - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw20-staking/schema/query_msg.json b/contracts/cw20-staking/schema/query_msg.json deleted file mode 100644 index bca894a7f..000000000 --- a/contracts/cw20-staking/schema/query_msg.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Claims shows the number of tokens this address can access when they are done unbonding", - "type": "object", - "required": [ - "claims" - ], - "properties": { - "claims": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Investment shows metadata on the staking info of the contract", - "type": "object", - "required": [ - "investment" - ], - "properties": { - "investment": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20. Returns the current balance of the given address, 0 if unset.", - "type": "object", - "required": [ - "balance" - ], - "properties": { - "balance": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20. Returns metadata on the contract - name, decimals, supply, etc.", - "type": "object", - "required": [ - "token_info" - ], - "properties": { - "token_info": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Implements CW20 \"allowance\" extension. Returns how much spender can use from owner account, 0 if unset.", - "type": "object", - "required": [ - "allowance" - ], - "properties": { - "allowance": { - "type": "object", - "required": [ - "owner", - "spender" - ], - "properties": { - "owner": { - "type": "string" - }, - "spender": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw20-staking/schema/token_info_response.json b/contracts/cw20-staking/schema/token_info_response.json deleted file mode 100644 index 9920c841f..000000000 --- a/contracts/cw20-staking/schema/token_info_response.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TokenInfoResponse", - "type": "object", - "required": [ - "decimals", - "name", - "symbol", - "total_supply" - ], - "properties": { - "decimals": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "name": { - "type": "string" - }, - "symbol": { - "type": "string" - }, - "total_supply": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw3-fixed-multisig/schema/execute_msg.json b/contracts/cw3-fixed-multisig/schema/execute_msg.json deleted file mode 100644 index 3c29a4fb6..000000000 --- a/contracts/cw3-fixed-multisig/schema/execute_msg.json +++ /dev/null @@ -1,642 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "propose" - ], - "properties": { - "propose": { - "type": "object", - "required": [ - "description", - "msgs", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "latest": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "msgs": { - "type": "array", - "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - } - }, - "title": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "vote" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "vote": { - "$ref": "#/definitions/Vote" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "close" - ], - "properties": { - "close": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "staking" - ], - "properties": { - "staking": { - "$ref": "#/definitions/StakingMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "distribution" - ], - "properties": { - "distribution": { - "$ref": "#/definitions/DistributionMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "redelegate" - ], - "properties": { - "redelegate": { - "type": "object", - "required": [ - "amount", - "dst_validator", - "src_validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "dst_validator": { - "type": "string" - }, - "src_validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - }, - "Vote": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "veto" - ] - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/contracts/cw3-fixed-multisig/schema/instantiate_msg.json b/contracts/cw3-fixed-multisig/schema/instantiate_msg.json deleted file mode 100644 index cabbc8d0b..000000000 --- a/contracts/cw3-fixed-multisig/schema/instantiate_msg.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "max_voting_period", - "required_weight", - "voters" - ], - "properties": { - "max_voting_period": { - "$ref": "#/definitions/Duration" - }, - "required_weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "voters": { - "type": "array", - "items": { - "$ref": "#/definitions/Voter" - } - } - }, - "definitions": { - "Duration": { - "description": "Duration is a delta of time. You can add it to a BlockInfo or Expiration to move that further in the future. Note that an height-based Duration and a time-based Expiration cannot be combined", - "oneOf": [ - { - "type": "object", - "required": [ - "height" - ], - "properties": { - "height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "Time in seconds", - "type": "object", - "required": [ - "time" - ], - "properties": { - "time": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - ] - }, - "Voter": { - "type": "object", - "required": [ - "addr", - "weight" - ], - "properties": { - "addr": { - "type": "string" - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - } -} diff --git a/contracts/cw3-fixed-multisig/schema/query_msg.json b/contracts/cw3-fixed-multisig/schema/query_msg.json deleted file mode 100644 index 42aea7141..000000000 --- a/contracts/cw3-fixed-multisig/schema/query_msg.json +++ /dev/null @@ -1,218 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Return ThresholdResponse", - "type": "object", - "required": [ - "threshold" - ], - "properties": { - "threshold": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Returns ProposalResponse", - "type": "object", - "required": [ - "proposal" - ], - "properties": { - "proposal": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns ProposalListResponse", - "type": "object", - "required": [ - "list_proposals" - ], - "properties": { - "list_proposals": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns ProposalListResponse", - "type": "object", - "required": [ - "reverse_proposals" - ], - "properties": { - "reverse_proposals": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_before": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns VoteResponse", - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "voter" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "voter": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns VoteListResponse", - "type": "object", - "required": [ - "list_votes" - ], - "properties": { - "list_votes": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns VoterInfo", - "type": "object", - "required": [ - "voter" - ], - "properties": { - "voter": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns VoterListResponse", - "type": "object", - "required": [ - "list_voters" - ], - "properties": { - "list_voters": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw3-flex-multisig/schema/execute_msg.json b/contracts/cw3-flex-multisig/schema/execute_msg.json deleted file mode 100644 index 62a31181e..000000000 --- a/contracts/cw3-flex-multisig/schema/execute_msg.json +++ /dev/null @@ -1,698 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "propose" - ], - "properties": { - "propose": { - "type": "object", - "required": [ - "description", - "msgs", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "latest": { - "anyOf": [ - { - "$ref": "#/definitions/Expiration" - }, - { - "type": "null" - } - ] - }, - "msgs": { - "type": "array", - "items": { - "$ref": "#/definitions/CosmosMsg_for_Empty" - } - }, - "title": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "vote" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "vote": { - "$ref": "#/definitions/Vote" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "close" - ], - "properties": { - "close": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Handles update hook messages from the group contract", - "type": "object", - "required": [ - "member_changed_hook" - ], - "properties": { - "member_changed_hook": { - "$ref": "#/definitions/MemberChangedHookMsg" - } - }, - "additionalProperties": false - } - ], - "definitions": { - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "staking" - ], - "properties": { - "staking": { - "$ref": "#/definitions/StakingMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "distribution" - ], - "properties": { - "distribution": { - "$ref": "#/definitions/DistributionMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - } - ] - }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "MemberChangedHookMsg": { - "description": "MemberChangedHookMsg should be de/serialized under `MemberChangedHook()` variant in a ExecuteMsg. This contains a list of all diffs on the given transaction.", - "type": "object", - "required": [ - "diffs" - ], - "properties": { - "diffs": { - "type": "array", - "items": { - "$ref": "#/definitions/MemberDiff" - } - } - } - }, - "MemberDiff": { - "description": "MemberDiff shows the old and new states for a given cw4 member They cannot both be None. old = None, new = Some -> Insert old = Some, new = Some -> Update old = Some, new = None -> Delete", - "type": "object", - "required": [ - "key" - ], - "properties": { - "key": { - "type": "string" - }, - "new": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "old": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "redelegate" - ], - "properties": { - "redelegate": { - "type": "object", - "required": [ - "amount", - "dst_validator", - "src_validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "dst_validator": { - "type": "string" - }, - "src_validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - }, - "Vote": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "veto" - ] - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/contracts/cw3-flex-multisig/schema/instantiate_msg.json b/contracts/cw3-flex-multisig/schema/instantiate_msg.json deleted file mode 100644 index 42c078f66..000000000 --- a/contracts/cw3-flex-multisig/schema/instantiate_msg.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "group_addr", - "max_voting_period", - "threshold" - ], - "properties": { - "group_addr": { - "type": "string" - }, - "max_voting_period": { - "$ref": "#/definitions/Duration" - }, - "threshold": { - "$ref": "#/definitions/Threshold" - } - }, - "definitions": { - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - }, - "Duration": { - "description": "Duration is a delta of time. You can add it to a BlockInfo or Expiration to move that further in the future. Note that an height-based Duration and a time-based Expiration cannot be combined", - "oneOf": [ - { - "type": "object", - "required": [ - "height" - ], - "properties": { - "height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "Time in seconds", - "type": "object", - "required": [ - "time" - ], - "properties": { - "time": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - ] - }, - "Threshold": { - "description": "This defines the different ways tallies can happen.\n\nThe total_weight used for calculating success as well as the weights of each individual voter used in tallying should be snapshotted at the beginning of the block at which the proposal starts (this is likely the responsibility of a correct cw4 implementation). See also `ThresholdResponse` in the cw3 spec.", - "oneOf": [ - { - "description": "Declares that a fixed weight of Yes votes is needed to pass. See `ThresholdResponse.AbsoluteCount` in the cw3 spec for details.", - "type": "object", - "required": [ - "absolute_count" - ], - "properties": { - "absolute_count": { - "type": "object", - "required": [ - "weight" - ], - "properties": { - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Declares a percentage of the total weight that must cast Yes votes in order for a proposal to pass. See `ThresholdResponse.AbsolutePercentage` in the cw3 spec for details.", - "type": "object", - "required": [ - "absolute_percentage" - ], - "properties": { - "absolute_percentage": { - "type": "object", - "required": [ - "percentage" - ], - "properties": { - "percentage": { - "$ref": "#/definitions/Decimal" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Declares a `quorum` of the total votes that must participate in the election in order for the vote to be considered at all. See `ThresholdResponse.ThresholdQuorum` in the cw3 spec for details.", - "type": "object", - "required": [ - "threshold_quorum" - ], - "properties": { - "threshold_quorum": { - "type": "object", - "required": [ - "quorum", - "threshold" - ], - "properties": { - "quorum": { - "$ref": "#/definitions/Decimal" - }, - "threshold": { - "$ref": "#/definitions/Decimal" - } - } - } - }, - "additionalProperties": false - } - ] - } - } -} diff --git a/contracts/cw3-flex-multisig/schema/query_msg.json b/contracts/cw3-flex-multisig/schema/query_msg.json deleted file mode 100644 index 42aea7141..000000000 --- a/contracts/cw3-flex-multisig/schema/query_msg.json +++ /dev/null @@ -1,218 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Return ThresholdResponse", - "type": "object", - "required": [ - "threshold" - ], - "properties": { - "threshold": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Returns ProposalResponse", - "type": "object", - "required": [ - "proposal" - ], - "properties": { - "proposal": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns ProposalListResponse", - "type": "object", - "required": [ - "list_proposals" - ], - "properties": { - "list_proposals": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns ProposalListResponse", - "type": "object", - "required": [ - "reverse_proposals" - ], - "properties": { - "reverse_proposals": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_before": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns VoteResponse", - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "voter" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "voter": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns VoteListResponse", - "type": "object", - "required": [ - "list_votes" - ], - "properties": { - "list_votes": { - "type": "object", - "required": [ - "proposal_id" - ], - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns VoterInfo", - "type": "object", - "required": [ - "voter" - ], - "properties": { - "voter": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns VoterListResponse", - "type": "object", - "required": [ - "list_voters" - ], - "properties": { - "list_voters": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw4-group/schema/admin_response.json b/contracts/cw4-group/schema/admin_response.json deleted file mode 100644 index 82bf62a3a..000000000 --- a/contracts/cw4-group/schema/admin_response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AdminResponse", - "type": "object", - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - } - } -} diff --git a/contracts/cw4-group/schema/execute_msg.json b/contracts/cw4-group/schema/execute_msg.json deleted file mode 100644 index 4322f89a9..000000000 --- a/contracts/cw4-group/schema/execute_msg.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "description": "Change the admin", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "apply a diff to the existing members. remove is applied after add, so if an address is in both, it is removed", - "type": "object", - "required": [ - "update_members" - ], - "properties": { - "update_members": { - "type": "object", - "required": [ - "add", - "remove" - ], - "properties": { - "add": { - "type": "array", - "items": { - "$ref": "#/definitions/Member" - } - }, - "remove": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Add a new hook to be informed of all membership changes. Must be called by Admin", - "type": "object", - "required": [ - "add_hook" - ], - "properties": { - "add_hook": { - "type": "object", - "required": [ - "addr" - ], - "properties": { - "addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Remove a hook. Must be called by Admin", - "type": "object", - "required": [ - "remove_hook" - ], - "properties": { - "remove_hook": { - "type": "object", - "required": [ - "addr" - ], - "properties": { - "addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Member": { - "description": "A group member has a weight associated with them. This may all be equal, or may have meaning in the app that makes use of the group (eg. voting power)", - "type": "object", - "required": [ - "addr", - "weight" - ], - "properties": { - "addr": { - "type": "string" - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - } -} diff --git a/contracts/cw4-group/schema/instantiate_msg.json b/contracts/cw4-group/schema/instantiate_msg.json deleted file mode 100644 index efa676c03..000000000 --- a/contracts/cw4-group/schema/instantiate_msg.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "members" - ], - "properties": { - "admin": { - "description": "The admin is the only account that can update the group state. Omit it to make the group immutable.", - "type": [ - "string", - "null" - ] - }, - "members": { - "type": "array", - "items": { - "$ref": "#/definitions/Member" - } - } - }, - "definitions": { - "Member": { - "description": "A group member has a weight associated with them. This may all be equal, or may have meaning in the app that makes use of the group (eg. voting power)", - "type": "object", - "required": [ - "addr", - "weight" - ], - "properties": { - "addr": { - "type": "string" - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - } -} diff --git a/contracts/cw4-group/schema/member_list_response.json b/contracts/cw4-group/schema/member_list_response.json deleted file mode 100644 index ae09f9bba..000000000 --- a/contracts/cw4-group/schema/member_list_response.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MemberListResponse", - "type": "object", - "required": [ - "members" - ], - "properties": { - "members": { - "type": "array", - "items": { - "$ref": "#/definitions/Member" - } - } - }, - "definitions": { - "Member": { - "description": "A group member has a weight associated with them. This may all be equal, or may have meaning in the app that makes use of the group (eg. voting power)", - "type": "object", - "required": [ - "addr", - "weight" - ], - "properties": { - "addr": { - "type": "string" - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - } -} diff --git a/contracts/cw4-group/schema/member_response.json b/contracts/cw4-group/schema/member_response.json deleted file mode 100644 index c78ed8623..000000000 --- a/contracts/cw4-group/schema/member_response.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MemberResponse", - "type": "object", - "properties": { - "weight": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } -} diff --git a/contracts/cw4-group/schema/query_msg.json b/contracts/cw4-group/schema/query_msg.json deleted file mode 100644 index f7987c626..000000000 --- a/contracts/cw4-group/schema/query_msg.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Return AdminResponse", - "type": "object", - "required": [ - "admin" - ], - "properties": { - "admin": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Return TotalWeightResponse", - "type": "object", - "required": [ - "total_weight" - ], - "properties": { - "total_weight": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Returns MembersListResponse", - "type": "object", - "required": [ - "list_members" - ], - "properties": { - "list_members": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns MemberResponse", - "type": "object", - "required": [ - "member" - ], - "properties": { - "member": { - "type": "object", - "required": [ - "addr" - ], - "properties": { - "addr": { - "type": "string" - }, - "at_height": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Shows all registered hooks. Returns HooksResponse.", - "type": "object", - "required": [ - "hooks" - ], - "properties": { - "hooks": { - "type": "object" - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw4-group/schema/total_weight_response.json b/contracts/cw4-group/schema/total_weight_response.json deleted file mode 100644 index 61db7a998..000000000 --- a/contracts/cw4-group/schema/total_weight_response.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TotalWeightResponse", - "type": "object", - "required": [ - "weight" - ], - "properties": { - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } -} diff --git a/contracts/cw4-stake/schema/admin_response.json b/contracts/cw4-stake/schema/admin_response.json deleted file mode 100644 index 82bf62a3a..000000000 --- a/contracts/cw4-stake/schema/admin_response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "AdminResponse", - "type": "object", - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - } - } -} diff --git a/contracts/cw4-stake/schema/claims_response.json b/contracts/cw4-stake/schema/claims_response.json deleted file mode 100644 index 08211a3c8..000000000 --- a/contracts/cw4-stake/schema/claims_response.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ClaimsResponse", - "type": "object", - "required": [ - "claims" - ], - "properties": { - "claims": { - "type": "array", - "items": { - "$ref": "#/definitions/Claim" - } - } - }, - "definitions": { - "Claim": { - "type": "object", - "required": [ - "amount", - "release_at" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "release_at": { - "$ref": "#/definitions/Expiration" - } - } - }, - "Expiration": { - "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", - "oneOf": [ - { - "description": "AtHeight will expire when `env.block.height` >= height", - "type": "object", - "required": [ - "at_height" - ], - "properties": { - "at_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "AtTime will expire when `env.block.time` >= time", - "type": "object", - "required": [ - "at_time" - ], - "properties": { - "at_time": { - "$ref": "#/definitions/Timestamp" - } - }, - "additionalProperties": false - }, - { - "description": "Never will never expire. Used to express the empty variant", - "type": "object", - "required": [ - "never" - ], - "properties": { - "never": { - "type": "object" - } - }, - "additionalProperties": false - } - ] - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw4-stake/schema/execute_msg.json b/contracts/cw4-stake/schema/execute_msg.json deleted file mode 100644 index 4b627d09d..000000000 --- a/contracts/cw4-stake/schema/execute_msg.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "description": "Bond will bond all staking tokens sent with the message and update membership weight", - "type": "object", - "required": [ - "bond" - ], - "properties": { - "bond": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Unbond will start the unbonding process for the given number of tokens. The sender immediately loses weight from these tokens, and can claim them back to his wallet after `unbonding_period`", - "type": "object", - "required": [ - "unbond" - ], - "properties": { - "unbond": { - "type": "object", - "required": [ - "tokens" - ], - "properties": { - "tokens": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Claim is used to claim your native tokens that you previously \"unbonded\" after the contract-defined waiting period (eg. 1 week)", - "type": "object", - "required": [ - "claim" - ], - "properties": { - "claim": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Change the admin", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Add a new hook to be informed of all membership changes. Must be called by Admin", - "type": "object", - "required": [ - "add_hook" - ], - "properties": { - "add_hook": { - "type": "object", - "required": [ - "addr" - ], - "properties": { - "addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Remove a hook. Must be called by Admin", - "type": "object", - "required": [ - "remove_hook" - ], - "properties": { - "remove_hook": { - "type": "object", - "required": [ - "addr" - ], - "properties": { - "addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This accepts a properly-encoded ReceiveMsg from a cw20 contract", - "type": "object", - "required": [ - "receive" - ], - "properties": { - "receive": { - "$ref": "#/definitions/Cw20ReceiveMsg" - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", - "type": "string" - }, - "Cw20ReceiveMsg": { - "description": "Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg", - "type": "object", - "required": [ - "amount", - "msg", - "sender" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "sender": { - "type": "string" - } - } - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw4-stake/schema/instantiate_msg.json b/contracts/cw4-stake/schema/instantiate_msg.json deleted file mode 100644 index d996eda1c..000000000 --- a/contracts/cw4-stake/schema/instantiate_msg.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "denom", - "min_bond", - "tokens_per_weight", - "unbonding_period" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "denom": { - "description": "denom of the token to stake", - "allOf": [ - { - "$ref": "#/definitions/Denom" - } - ] - }, - "min_bond": { - "$ref": "#/definitions/Uint128" - }, - "tokens_per_weight": { - "$ref": "#/definitions/Uint128" - }, - "unbonding_period": { - "$ref": "#/definitions/Duration" - } - }, - "definitions": { - "Addr": { - "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", - "type": "string" - }, - "Denom": { - "oneOf": [ - { - "type": "object", - "required": [ - "native" - ], - "properties": { - "native": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "cw20" - ], - "properties": { - "cw20": { - "$ref": "#/definitions/Addr" - } - }, - "additionalProperties": false - } - ] - }, - "Duration": { - "description": "Duration is a delta of time. You can add it to a BlockInfo or Expiration to move that further in the future. Note that an height-based Duration and a time-based Expiration cannot be combined", - "oneOf": [ - { - "type": "object", - "required": [ - "height" - ], - "properties": { - "height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "Time in seconds", - "type": "object", - "required": [ - "time" - ], - "properties": { - "time": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw4-stake/schema/member_list_response.json b/contracts/cw4-stake/schema/member_list_response.json deleted file mode 100644 index ae09f9bba..000000000 --- a/contracts/cw4-stake/schema/member_list_response.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MemberListResponse", - "type": "object", - "required": [ - "members" - ], - "properties": { - "members": { - "type": "array", - "items": { - "$ref": "#/definitions/Member" - } - } - }, - "definitions": { - "Member": { - "description": "A group member has a weight associated with them. This may all be equal, or may have meaning in the app that makes use of the group (eg. voting power)", - "type": "object", - "required": [ - "addr", - "weight" - ], - "properties": { - "addr": { - "type": "string" - }, - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - } -} diff --git a/contracts/cw4-stake/schema/member_response.json b/contracts/cw4-stake/schema/member_response.json deleted file mode 100644 index c78ed8623..000000000 --- a/contracts/cw4-stake/schema/member_response.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MemberResponse", - "type": "object", - "properties": { - "weight": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } -} diff --git a/contracts/cw4-stake/schema/query_msg.json b/contracts/cw4-stake/schema/query_msg.json deleted file mode 100644 index 33d7a6c52..000000000 --- a/contracts/cw4-stake/schema/query_msg.json +++ /dev/null @@ -1,144 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Claims shows the tokens in process of unbonding for this address", - "type": "object", - "required": [ - "claims" - ], - "properties": { - "claims": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "staked" - ], - "properties": { - "staked": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Return AdminResponse", - "type": "object", - "required": [ - "admin" - ], - "properties": { - "admin": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Return TotalWeightResponse", - "type": "object", - "required": [ - "total_weight" - ], - "properties": { - "total_weight": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Returns MembersListResponse", - "type": "object", - "required": [ - "list_members" - ], - "properties": { - "list_members": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Returns MemberResponse", - "type": "object", - "required": [ - "member" - ], - "properties": { - "member": { - "type": "object", - "required": [ - "addr" - ], - "properties": { - "addr": { - "type": "string" - }, - "at_height": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Shows all registered hooks. Returns HooksResponse.", - "type": "object", - "required": [ - "hooks" - ], - "properties": { - "hooks": { - "type": "object" - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw4-stake/schema/receive_msg.json b/contracts/cw4-stake/schema/receive_msg.json deleted file mode 100644 index ea681d68b..000000000 --- a/contracts/cw4-stake/schema/receive_msg.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ReceiveMsg", - "oneOf": [ - { - "description": "Only valid cw20 message is to bond the tokens", - "type": "object", - "required": [ - "bond" - ], - "properties": { - "bond": { - "type": "object" - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/cw4-stake/schema/staked_response.json b/contracts/cw4-stake/schema/staked_response.json deleted file mode 100644 index ab5fcb992..000000000 --- a/contracts/cw4-stake/schema/staked_response.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "StakedResponse", - "type": "object", - "required": [ - "denom", - "stake" - ], - "properties": { - "denom": { - "$ref": "#/definitions/Denom" - }, - "stake": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Addr": { - "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", - "type": "string" - }, - "Denom": { - "oneOf": [ - { - "type": "object", - "required": [ - "native" - ], - "properties": { - "native": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "cw20" - ], - "properties": { - "cw20": { - "$ref": "#/definitions/Addr" - } - }, - "additionalProperties": false - } - ] - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/cw4-stake/schema/total_weight_response.json b/contracts/cw4-stake/schema/total_weight_response.json deleted file mode 100644 index 61db7a998..000000000 --- a/contracts/cw4-stake/schema/total_weight_response.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TotalWeightResponse", - "type": "object", - "required": [ - "weight" - ], - "properties": { - "weight": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } -} From 0925703ad9fc28638176c9c531618345da63973e Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 21 Dec 2021 16:09:49 +0100 Subject: [PATCH 073/352] Update gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 58379de3e..62abf6fb6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,7 @@ contracts.txt artifacts/ # code coverage -tarpaulin-report.* \ No newline at end of file +tarpaulin-report.* + +packages/*/schema +contracts/*/schema From 466b1c82dcd8a8b4224acd62f8c68ed549b4b5b3 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 21 Dec 2021 17:22:45 +0100 Subject: [PATCH 074/352] Add MIGRATING.md Add breaking changes list / migration points for 0.10.x to 0.11.0 --- MIGRATING.md | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 MIGRATING.md diff --git a/MIGRATING.md b/MIGRATING.md new file mode 100644 index 000000000..9c08f1621 --- /dev/null +++ b/MIGRATING.md @@ -0,0 +1,115 @@ +# Migrating + +This guide lists API changes between *cw-plus* major releases. + +## v0.10.3 -> v0.11.0 + +### Breaking Issues / PRs + +- Rename cw0 to utils [\#471](https://github.com/CosmWasm/cw-plus/issues/471) / Cw0 rename [\#508](https://github.com/CosmWasm/cw-plus/pull/508) + +The `cw0` package was renamed to `utils`. The required changes are straightforward: + +```diff +diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml +index 1924b655..37af477d 100644 +--- a/contracts/cw1-subkeys/Cargo.toml ++++ b/contracts/cw1-subkeys/Cargo.toml +@@ -19,7 +19,7 @@ library = [] + test-utils = [] + + [dependencies] +-cw0 = { path = "../../packages/cw0", version = "0.10.3" } ++utils = { path = "../../packages/utils", version = "0.10.3" } + cw1 = { path = "../../packages/cw1", version = "0.10.3" } + cw2 = { path = "../../packages/cw2", version = "0.10.3" } + cw1-whitelist = { path = "../cw1-whitelist", version = "0.10.3", features = ["library"] } +``` + +```diff +diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/contract.rs +index b4852225..f20a65ec 100644 +--- a/contracts/cw1-subkeys/src/contract.rs ++++ b/contracts/cw1-subkeys/src/contract.rs +@@ -8,7 +8,6 @@ use cosmwasm_std::{ + ensure, ensure_ne, to_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, DistributionMsg, + Empty, Env, MessageInfo, Order, Response, StakingMsg, StdResult, + }; +-use cw0::Expiration; + use cw1::CanExecuteResponse; + use cw1_whitelist::{ + contract::{ +@@ -21,6 +20,7 @@ use cw1_whitelist::{ + use cw2::{get_contract_version, set_contract_version}; + use cw_storage_plus::Bound; + use semver::Version; ++use utils::Expiration; + + use crate::error::ContractError; + use crate::msg::{ +``` + +- Deprecate `range` to `range_raw` [\#460](https://github.com/CosmWasm/cw-plus/issues/460) / +`range` to `range raw` [\#576](https://github.com/CosmWasm/cw-plus/pull/576). + +`range` was renamed to `range_raw` (no key deserialization), and `range_de` to `range`. This means you can now count +on the key to be deserialized for you, which results in cleaner / simpler code. + +There are many examples in the contracts code base, by example: +```diff + +``` + +If / when you don't need key deserialization, just can just rename `range` to `range_raw` and you are good to go. + +If you need / want key deserialization for **indexes**, you need to specify the primary key type as a last (optional) +argument in the index key specification. If not specified, it defaults to `()`, which means that primary keys will +not only not be deserialized, but also not provided. This is for backwards-compatibility with current indexes +specifications, and may change in the future once these features are stabilized. + +Also, as part of this issue, `keys` was renamed to `keys_raw`, and `keys_de` to `keys`. `prefix_range` was also renamed, +to `prefix_range_raw`, and its key deserialization counterpart (`prefix_range_de`) to `prefix_range` in turn. + +Finally, this applies to all the `Map`-like types, including indexed maps. + +- `UniqueIndex` / `MultiIndex` key consistency [\#532](https://github.com/CosmWasm/cw-plus/issues/532) / +Index keys consistency [\#568](https://github.com/CosmWasm/cw-plus/pull/568) + +For both `UniqueIndex` and `MultiIndex`, returned keys (deserialized or not) are now the associated *primary keys* of +the data. This is a breaking change for `MultiIndex`, as the previous version returned a composite of the index key and +the primary key. + +Required changes are: +```diff +``` + +- Remove the primary key from the `MultiIndex` key specification [\#533](https://github.com/CosmWasm/cw-plus/issues/533) / +`MultiIndex` primary key spec removal [\#569](https://github.com/CosmWasm/cw-plus/pull/569) + +The primary key is no longer needed when specifying `MultiIndex` keys. This simplifies both `MultiIndex` definitions +and usage. + +Required changes are along the lines of: +```diff +``` + +- Incorrect I32Key Index Ordering [\#489](https://github.com/CosmWasm/cw-plus/issues/489) / +Signed int keys order [\#582](https://github.com/CosmWasm/cw-plus/pull/582) + +As part of range iterators revamping, we fixed the order of signed integer keys. You shouldn't change anything in your +code base for this, but if you were using signed keys and relying on their ordering, that has now changed for the better. +Take into account also that **the internal representation of signed integer keys has changed**. So, if you +have data stored under signed integer keys you would need to **migrate it**, or recreate it under the new representation. + +As part of this, a couple helpers for handling int keys serialization and deserialization were introduced: + - `from_cw_bytes` Integer (signed and unsigned) values deserialization. + - `to_cw_bytes` - Integer (signed and unsigned) values serialization. + +You shouldn't need these, except when manually handling raw integer keys serialization / deserialization. + +### Non-breaking Issues / PRs + +- Deprecate `IntKey` [\#472](https://github.com/CosmWasm/cw-plus/issues/472) / +Deprecate IntKey [\#547](https://github.com/CosmWasm/cw-plus/pull/547) + +See [CHANGELOG.md](CHANGELOG.md) for the full list. From d32cadfa7edd1b567124365d274200c06aca6ee9 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 22 Dec 2021 10:10:14 +0100 Subject: [PATCH 075/352] Add / simplify migation code examples --- MIGRATING.md | 149 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 24 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index 9c08f1621..8b5df4b54 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -15,15 +15,8 @@ diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 1924b655..37af477d 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml -@@ -19,7 +19,7 @@ library = [] - test-utils = [] - - [dependencies] -cw0 = { path = "../../packages/cw0", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.10.3" } - cw1 = { path = "../../packages/cw1", version = "0.10.3" } - cw2 = { path = "../../packages/cw2", version = "0.10.3" } - cw1-whitelist = { path = "../cw1-whitelist", version = "0.10.3", features = ["library"] } ``` ```diff @@ -31,22 +24,8 @@ diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/c index b4852225..f20a65ec 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs -@@ -8,7 +8,6 @@ use cosmwasm_std::{ - ensure, ensure_ne, to_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, DistributionMsg, - Empty, Env, MessageInfo, Order, Response, StakingMsg, StdResult, - }; -use cw0::Expiration; - use cw1::CanExecuteResponse; - use cw1_whitelist::{ - contract::{ -@@ -21,6 +20,7 @@ use cw1_whitelist::{ - use cw2::{get_contract_version, set_contract_version}; - use cw_storage_plus::Bound; - use semver::Version; +use utils::Expiration; - - use crate::error::ContractError; - use crate::msg::{ ``` - Deprecate `range` to `range_raw` [\#460](https://github.com/CosmWasm/cw-plus/issues/460) / @@ -55,9 +34,40 @@ index b4852225..f20a65ec 100644 `range` was renamed to `range_raw` (no key deserialization), and `range_de` to `range`. This means you can now count on the key to be deserialized for you, which results in cleaner / simpler code. -There are many examples in the contracts code base, by example: +There are some examples in the contracts code base, by example: ```diff - +diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs +index 48a60083..2f2ef70d 100644 +--- a/contracts/cw3-fixed-multisig/src/contract.rs ++++ b/contracts/cw3-fixed-multisig/src/contract.rs +@@ -385,21 +384,20 @@ fn list_votes( + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + +- let votes: StdResult> = BALLOTS ++ let votes = BALLOTS + .prefix(proposal_id) +- .range_raw(deps.storage, start, None, Order::Ascending) ++ .range(deps.storage, start, None, Order::Ascending) + .take(limit) + .map(|item| { +- let (key, ballot) = item?; +- Ok(VoteInfo { +- voter: String::from_utf8(key)?, ++ item.map(|(addr, ballot)| VoteInfo { ++ voter: addr.into(), + vote: ballot.vote, + weight: ballot.weight, + }) + }) +- .collect(); ++ .collect::>()?; + +- Ok(VoteListResponse { votes: votes? }) ++ Ok(VoteListResponse { votes }) + } + + fn query_voter(deps: Deps, voter: String) -> StdResult { ``` If / when you don't need key deserialization, just can just rename `range` to `range_raw` and you are good to go. @@ -66,6 +76,7 @@ If you need / want key deserialization for **indexes**, you need to specify the argument in the index key specification. If not specified, it defaults to `()`, which means that primary keys will not only not be deserialized, but also not provided. This is for backwards-compatibility with current indexes specifications, and may change in the future once these features are stabilized. +See `packages/storage-plus/src/indexed_map.rs` tests for reference. Also, as part of this issue, `keys` was renamed to `keys_raw`, and `keys_de` to `keys`. `prefix_range` was also renamed, to `prefix_range_raw`, and its key deserialization counterpart (`prefix_range_de`) to `prefix_range` in turn. @@ -79,8 +90,59 @@ For both `UniqueIndex` and `MultiIndex`, returned keys (deserialized or not) are the data. This is a breaking change for `MultiIndex`, as the previous version returned a composite of the index key and the primary key. -Required changes are: +Examples of required changes are: ```diff +diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs +index 9f7178af..d11d501e 100644 +--- a/packages/storage-plus/src/indexed_map.rs ++++ b/packages/storage-plus/src/indexed_map.rs +@@ -722,7 +722,7 @@ mod test { + last_name: "".to_string(), + age: 42, + }; +- let pk1: &[u8] = b"5627"; ++ let pk1: &str = "5627"; + map.save(&mut store, pk1, &data1).unwrap(); + + let data2 = Data { +@@ -730,7 +730,7 @@ mod test { + last_name: "Perez".to_string(), + age: 13, + }; +- let pk2: &[u8] = b"5628"; ++ let pk2: &str = "5628"; + map.save(&mut store, pk2, &data2).unwrap(); + + let data3 = Data { +@@ -738,7 +738,7 @@ mod test { + last_name: "Young".to_string(), + age: 24, + }; +- let pk3: &[u8] = b"5629"; ++ let pk3: &str = "5629"; + map.save(&mut store, pk3, &data3).unwrap(); + + let data4 = Data { +@@ -746,7 +746,7 @@ mod test { + last_name: "Bemberg".to_string(), + age: 43, + }; +- let pk4: &[u8] = b"5630"; ++ let pk4: &str = "5630"; + map.save(&mut store, pk4, &data4).unwrap(); + + let marias: Vec<_> = map +@@ -760,8 +760,8 @@ mod test { + assert_eq!(2, count); + + // Remaining part (age) of the index keys, plus pks (bytes) (sorted by age descending) +- assert_eq!((42, pk1.to_vec()), marias[0].0); +- assert_eq!((24, pk3.to_vec()), marias[1].0); ++ assert_eq!(pk1, marias[0].0); ++ assert_eq!(pk3, marias[1].0); + + // Data + assert_eq!(data1, marias[0].1); ``` - Remove the primary key from the `MultiIndex` key specification [\#533](https://github.com/CosmWasm/cw-plus/issues/533) / @@ -91,6 +153,45 @@ and usage. Required changes are along the lines of: ```diff +diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs +index 022a4504..c7a3bb9d 100644 +--- a/packages/storage-plus/src/indexed_map.rs ++++ b/packages/storage-plus/src/indexed_map.rs +@@ -295,8 +295,8 @@ mod test { + } + + struct DataIndexes<'a> { +- // Second arg is for storing pk +- pub name: MultiIndex<'a, (String, String), Data, String>, ++ // Last args are for signaling pk deserialization ++ pub name: MultiIndex<'a, String, Data, String>, + pub age: UniqueIndex<'a, u32, Data, String>, + pub name_lastname: UniqueIndex<'a, (Vec, Vec), Data, String>, + } +@@ -326,11 +326,7 @@ mod test { + // Can we make it easier to define this? (less wordy generic) + fn build_map<'a>() -> IndexedMap<'a, &'a str, Data, DataIndexes<'a>> { + let indexes = DataIndexes { +- name: MultiIndex::new( +- |d, k| (d.name.clone(), unsafe { String::from_utf8_unchecked(k) }), +- "data", +- "data__name", +- ), ++ name: MultiIndex::new(|d| d.name.clone(), "data", "data__name"), + age: UniqueIndex::new(|d| d.age, "data__age"), + name_lastname: UniqueIndex::new( + |d| index_string_tuple(&d.name, &d.last_name), +@@ -469,8 +462,8 @@ mod test { + // index_key() over MultiIndex works (empty pk) + // In a MultiIndex, an index key is composed by the index and the primary key. + // Primary key may be empty (so that to iterate over all elements that match just the index) +- let key = ("Maria".to_string(), "".to_string()); +- // Use the index_key() helper to build the (raw) index key ++ let key = "Maria".to_string(); ++ // Use the index_key() helper to build the (raw) index key with an empty pk + let key = map.idx.name.index_key(key); + // Iterate using a bound over the raw key + let count = map ``` - Incorrect I32Key Index Ordering [\#489](https://github.com/CosmWasm/cw-plus/issues/489) / From 3085c2ac31b97b79d48829aee242496b565d110f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 22 Dec 2021 10:18:33 +0100 Subject: [PATCH 076/352] Add extra example for int keys migration --- MIGRATING.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/MIGRATING.md b/MIGRATING.md index 8b5df4b54..fca504b82 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -213,4 +213,30 @@ You shouldn't need these, except when manually handling raw integer keys seriali - Deprecate `IntKey` [\#472](https://github.com/CosmWasm/cw-plus/issues/472) / Deprecate IntKey [\#547](https://github.com/CosmWasm/cw-plus/pull/547) -See [CHANGELOG.md](CHANGELOG.md) for the full list. +The `IntKey` wrapper and its type aliases are marked as deprecated, and will be removed in the next major version. +The migration is straightforward, just remove the wrappers: +```diff +diff --git a/contracts/cw20-merkle-airdrop/src/contract.rs b/contracts/cw20-merkle-airdrop/src/contract.rs +index e8d5ea57..bdf555e8 100644 +--- a/contracts/cw20-merkle-airdrop/src/contract.rs ++++ b/contracts/cw20-merkle-airdrop/src/contract.rs +@@ -6,7 +6,6 @@ use cosmwasm_std::{ + }; + use cw2::{get_contract_version, set_contract_version}; + use cw20::Cw20ExecuteMsg; +-use cw_storage_plus::U8Key; + use sha2::Digest; + use std::convert::TryInto; + +@@ -113,7 +112,7 @@ pub fn execute_register_merkle_root( + + let stage = LATEST_STAGE.update(deps.storage, |stage| -> StdResult<_> { Ok(stage + 1) })?; + +- MERKLE_ROOT.save(deps.storage, U8Key::from(stage), &merkle_root)?; ++ MERKLE_ROOT.save(deps.storage, stage, &merkle_root)?; + LATEST_STAGE.save(deps.storage, &stage)?; + + Ok(Response::new().add_attributes(vec![ +``` + +- See [CHANGELOG.md](CHANGELOG.md) for the full list of non-breaking changes. From c14ca18d5fb2395c11cd3efb955e661f6036fa4c Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 22 Dec 2021 10:37:54 +0100 Subject: [PATCH 077/352] Add code stub for migrating signed int keys --- MIGRATING.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/MIGRATING.md b/MIGRATING.md index fca504b82..1d50e4809 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -208,6 +208,36 @@ As part of this, a couple helpers for handling int keys serialization and deseri You shouldn't need these, except when manually handling raw integer keys serialization / deserialization. +Migration code example: +```rust +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + let version = get_contract_version(deps.storage)?; + if version.contract != CONTRACT_NAME { + return Err(ContractError::CannotMigrate { + previous_contract: version.contract, + }); + } + // Original map + signed_int_map: Map = Map::new("signed_int_map"); + // New map + signed_int_map_new: Map = Map::new("signed_int_map-v2"); + + signed_int_map + .range_raw(deps.storage, None, None, Order::Ascending) + .map(|(k, v)| { + let signed = i8::from_be_bytes(k); + signed_int_map_new.save(deps.storage, signed, v); + }) + .collect()?; + + // Code to remove the old map keys + ... + + Ok(Response::default()) +} +``` + ### Non-breaking Issues / PRs - Deprecate `IntKey` [\#472](https://github.com/CosmWasm/cw-plus/issues/472) / From 61edf31db4a14cc58b4103565975e4064ab6c581 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 22 Dec 2021 10:41:32 +0100 Subject: [PATCH 078/352] Clarify / simplify comments :-) --- MIGRATING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index 1d50e4809..84b736303 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -70,9 +70,9 @@ index 48a60083..2f2ef70d 100644 fn query_voter(deps: Deps, voter: String) -> StdResult { ``` -If / when you don't need key deserialization, just can just rename `range` to `range_raw` and you are good to go. +If you don't need key deserialization, just can just rename `range` to `range_raw` and you are good to go. -If you need / want key deserialization for **indexes**, you need to specify the primary key type as a last (optional) +If you want key deserialization for **indexes**, you need to specify the primary key type as a last (optional) argument in the index key specification. If not specified, it defaults to `()`, which means that primary keys will not only not be deserialized, but also not provided. This is for backwards-compatibility with current indexes specifications, and may change in the future once these features are stabilized. From 799ee37225f89f1f9466a102b2dc8cc8f7cdb191 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 22 Dec 2021 10:46:47 +0100 Subject: [PATCH 079/352] Simplify range migration example --- MIGRATING.md | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index 84b736303..dbcaf802f 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -41,14 +41,7 @@ index 48a60083..2f2ef70d 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -385,21 +384,20 @@ fn list_votes( - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); - -- let votes: StdResult> = BALLOTS -+ let votes = BALLOTS - .prefix(proposal_id) -- .range_raw(deps.storage, start, None, Order::Ascending) -+ .range(deps.storage, start, None, Order::Ascending) + .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { - let (key, ballot) = item?; @@ -59,15 +52,6 @@ index 48a60083..2f2ef70d 100644 vote: ballot.vote, weight: ballot.weight, }) - }) -- .collect(); -+ .collect::>()?; - -- Ok(VoteListResponse { votes: votes? }) -+ Ok(VoteListResponse { votes }) - } - - fn query_voter(deps: Deps, voter: String) -> StdResult { ``` If you don't need key deserialization, just can just rename `range` to `range_raw` and you are good to go. From 4513ae26aa97889b89452de59f85d35da4e73efb Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 22 Dec 2021 10:49:50 +0100 Subject: [PATCH 080/352] Simplify list of renames --- MIGRATING.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index dbcaf802f..e7f10f35e 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -62,8 +62,13 @@ not only not be deserialized, but also not provided. This is for backwards-compa specifications, and may change in the future once these features are stabilized. See `packages/storage-plus/src/indexed_map.rs` tests for reference. -Also, as part of this issue, `keys` was renamed to `keys_raw`, and `keys_de` to `keys`. `prefix_range` was also renamed, -to `prefix_range_raw`, and its key deserialization counterpart (`prefix_range_de`) to `prefix_range` in turn. +Renamed methods: +- `range` -> `range_raw` +- `keys` -> `keys_raw` +- `prefix_range` -> `prefix_range_raw` +- `range_de` -> `range` +- `keys_de` -> `keys` +- `prefix_range_de` -> `prefix_range` Finally, this applies to all the `Map`-like types, including indexed maps. From 33c49211c766680eb6d9743a54dd80c138a52ad1 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 22 Dec 2021 10:50:33 +0100 Subject: [PATCH 081/352] Rename to type params for correctness --- MIGRATING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MIGRATING.md b/MIGRATING.md index e7f10f35e..551082fca 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -152,7 +152,7 @@ index 022a4504..c7a3bb9d 100644 struct DataIndexes<'a> { - // Second arg is for storing pk - pub name: MultiIndex<'a, (String, String), Data, String>, -+ // Last args are for signaling pk deserialization ++ // Last type parameters are for signaling pk deserialization + pub name: MultiIndex<'a, String, Data, String>, pub age: UniqueIndex<'a, u32, Data, String>, pub name_lastname: UniqueIndex<'a, (Vec, Vec), Data, String>, From d91d83794d86444ca60ab340bba2d01e888fe6d2 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Tue, 21 Dec 2021 17:15:34 +0100 Subject: [PATCH 082/352] Move Threshold and coexisting implementations into packages/utils --- contracts/cw3-fixed-multisig/src/contract.rs | 6 +- contracts/cw3-flex-multisig/src/contract.rs | 19 +- contracts/cw3-flex-multisig/src/error.rs | 18 +- contracts/cw3-flex-multisig/src/msg.rs | 253 +------------- contracts/cw3-flex-multisig/src/state.rs | 4 +- packages/cw3/examples/schema.rs | 5 +- packages/cw3/src/lib.rs | 12 +- packages/cw3/src/query.rs | 73 +--- packages/utils/src/lib.rs | 2 + packages/utils/src/threshold.rs | 341 +++++++++++++++++++ 10 files changed, 373 insertions(+), 360 deletions(-) create mode 100644 packages/utils/src/threshold.rs diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 2f2ef70d5..ece844dc0 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -9,11 +9,11 @@ use cosmwasm_std::{ use cw2::set_contract_version; use cw3::{ - ProposalListResponse, ProposalResponse, Status, ThresholdResponse, Vote, VoteInfo, - VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, + ProposalListResponse, ProposalResponse, Status, Vote, VoteInfo, VoteListResponse, VoteResponse, + VoterDetail, VoterListResponse, VoterResponse, }; use cw_storage_plus::Bound; -use utils::Expiration; +use utils::{Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 38169b6b5..d870652c5 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -9,12 +9,12 @@ use cosmwasm_std::{ use cw2::set_contract_version; use cw3::{ - ProposalListResponse, ProposalResponse, Status, ThresholdResponse, Vote, VoteInfo, - VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, + ProposalListResponse, ProposalResponse, Status, Vote, VoteInfo, VoteListResponse, VoteResponse, + VoterDetail, VoterListResponse, VoterResponse, }; use cw4::{Cw4Contract, MemberChangedHookMsg, MemberDiff}; use cw_storage_plus::Bound; -use utils::{maybe_addr, Expiration}; +use utils::{maybe_addr, Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; @@ -431,10 +431,9 @@ mod tests { use cw4::{Cw4ExecuteMsg, Member}; use cw4_group::helpers::Cw4GroupContract; use cw_multi_test::{next_block, App, AppBuilder, Contract, ContractWrapper, Executor}; - use utils::Duration; + use utils::{Duration, Threshold}; use super::*; - use crate::msg::Threshold; const OWNER: &str = "admin0001"; const VOTER1: &str = "voter0001"; @@ -625,7 +624,10 @@ mod tests { None, ) .unwrap_err(); - assert_eq!(ContractError::InvalidThreshold {}, err.downcast().unwrap()); + assert_eq!( + ContractError::Threshold(utils::ThresholdError::InvalidThreshold {}), + err.downcast().unwrap() + ); // Total weight less than required weight not allowed let instantiate_msg = InstantiateMsg { @@ -643,7 +645,10 @@ mod tests { None, ) .unwrap_err(); - assert_eq!(ContractError::UnreachableWeight {}, err.downcast().unwrap()); + assert_eq!( + ContractError::Threshold(utils::ThresholdError::UnreachableWeight {}), + err.downcast().unwrap() + ); // All valid let instantiate_msg = InstantiateMsg { diff --git a/contracts/cw3-flex-multisig/src/error.rs b/contracts/cw3-flex-multisig/src/error.rs index 0c104222a..4a56312bb 100644 --- a/contracts/cw3-flex-multisig/src/error.rs +++ b/contracts/cw3-flex-multisig/src/error.rs @@ -1,4 +1,6 @@ use cosmwasm_std::StdError; +use utils::ThresholdError; + use thiserror::Error; #[derive(Error, Debug, PartialEq)] @@ -6,20 +8,8 @@ pub enum ContractError { #[error("{0}")] Std(#[from] StdError), - #[error("Invalid voting threshold percentage, must be in the 0.5-1.0 range")] - InvalidThreshold {}, - - #[error("Required quorum threshold cannot be zero")] - ZeroQuorumThreshold {}, - - #[error("Not possible to reach required quorum threshold")] - UnreachableQuorumThreshold {}, - - #[error("Required weight cannot be zero")] - ZeroWeight {}, - - #[error("Not possible to reach required (passing) weight")] - UnreachableWeight {}, + #[error("{0}")] + Threshold(#[from] ThresholdError), #[error("Group contract invalid address '{addr}'")] InvalidGroup { addr: String }, diff --git a/contracts/cw3-flex-multisig/src/msg.rs b/contracts/cw3-flex-multisig/src/msg.rs index 1bb2301d4..9b6fa67ef 100644 --- a/contracts/cw3-flex-multisig/src/msg.rs +++ b/contracts/cw3-flex-multisig/src/msg.rs @@ -1,11 +1,10 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::error::ContractError; -use cosmwasm_std::{CosmosMsg, Decimal, Empty}; -use cw3::{ThresholdResponse, Vote}; +use cosmwasm_std::{CosmosMsg, Empty}; +use cw3::Vote; use cw4::MemberChangedHookMsg; -use utils::{Duration, Expiration}; +use utils::{Duration, Expiration, Threshold}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct InstantiateMsg { @@ -15,102 +14,6 @@ pub struct InstantiateMsg { pub max_voting_period: Duration, } -/// This defines the different ways tallies can happen. -/// -/// The total_weight used for calculating success as well as the weights of each -/// individual voter used in tallying should be snapshotted at the beginning of -/// the block at which the proposal starts (this is likely the responsibility of a -/// correct cw4 implementation). -/// See also `ThresholdResponse` in the cw3 spec. -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] -pub enum Threshold { - /// Declares that a fixed weight of Yes votes is needed to pass. - /// See `ThresholdResponse.AbsoluteCount` in the cw3 spec for details. - AbsoluteCount { weight: u64 }, - - /// Declares a percentage of the total weight that must cast Yes votes in order for - /// a proposal to pass. - /// See `ThresholdResponse.AbsolutePercentage` in the cw3 spec for details. - AbsolutePercentage { percentage: Decimal }, - - /// Declares a `quorum` of the total votes that must participate in the election in order - /// for the vote to be considered at all. - /// See `ThresholdResponse.ThresholdQuorum` in the cw3 spec for details. - ThresholdQuorum { threshold: Decimal, quorum: Decimal }, -} - -impl Threshold { - /// returns error if this is an unreachable value, - /// given a total weight of all members in the group - pub fn validate(&self, total_weight: u64) -> Result<(), ContractError> { - match self { - Threshold::AbsoluteCount { - weight: weight_needed, - } => { - if *weight_needed == 0 { - Err(ContractError::ZeroWeight {}) - } else if *weight_needed > total_weight { - Err(ContractError::UnreachableWeight {}) - } else { - Ok(()) - } - } - Threshold::AbsolutePercentage { - percentage: percentage_needed, - } => valid_threshold(percentage_needed), - Threshold::ThresholdQuorum { - threshold, - quorum: quroum, - } => { - valid_threshold(threshold)?; - valid_quorum(quroum) - } - } - } - - /// Creates a response from the saved data, just missing the total_weight info - pub fn to_response(&self, total_weight: u64) -> ThresholdResponse { - match self.clone() { - Threshold::AbsoluteCount { weight } => ThresholdResponse::AbsoluteCount { - weight, - total_weight, - }, - Threshold::AbsolutePercentage { percentage } => ThresholdResponse::AbsolutePercentage { - percentage, - total_weight, - }, - Threshold::ThresholdQuorum { threshold, quorum } => { - ThresholdResponse::ThresholdQuorum { - threshold, - quorum, - total_weight, - } - } - } - } -} - -/// Asserts that the 0.5 < percent <= 1.0 -fn valid_threshold(percent: &Decimal) -> Result<(), ContractError> { - if *percent > Decimal::percent(100) || *percent < Decimal::percent(50) { - Err(ContractError::InvalidThreshold {}) - } else { - Ok(()) - } -} - -/// Asserts that the 0.5 < percent <= 1.0 -fn valid_quorum(percent: &Decimal) -> Result<(), ContractError> { - if percent.is_zero() { - Err(ContractError::ZeroQuorumThreshold {}) - } else if *percent > Decimal::one() { - Err(ContractError::UnreachableQuorumThreshold {}) - } else { - Ok(()) - } -} - // TODO: add some T variants? Maybe good enough as fixed Empty for now #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] @@ -170,153 +73,3 @@ pub enum QueryMsg { limit: Option, }, } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn validate_quorum_percentage() { - // TODO: test the error messages - - // 0 is never a valid percentage - let err = valid_quorum(&Decimal::zero()).unwrap_err(); - assert_eq!( - err.to_string(), - ContractError::ZeroQuorumThreshold {}.to_string() - ); - - // 100% is - valid_quorum(&Decimal::one()).unwrap(); - - // 101% is not - let err = valid_quorum(&Decimal::percent(101)).unwrap_err(); - assert_eq!( - err.to_string(), - ContractError::UnreachableQuorumThreshold {}.to_string() - ); - // not 100.1% - let err = valid_quorum(&Decimal::permille(1001)).unwrap_err(); - assert_eq!( - err.to_string(), - ContractError::UnreachableQuorumThreshold {}.to_string() - ); - } - - #[test] - fn validate_threshold_percentage() { - // other values in between 0.5 and 1 are valid - valid_threshold(&Decimal::percent(51)).unwrap(); - valid_threshold(&Decimal::percent(67)).unwrap(); - valid_threshold(&Decimal::percent(99)).unwrap(); - let err = valid_threshold(&Decimal::percent(101)).unwrap_err(); - assert_eq!( - err.to_string(), - ContractError::InvalidThreshold {}.to_string() - ); - } - - #[test] - fn validate_threshold() { - // absolute count ensures 0 < required <= total_weight - let err = Threshold::AbsoluteCount { weight: 0 } - .validate(5) - .unwrap_err(); - // TODO: remove to_string() when PartialEq implemented - assert_eq!(err.to_string(), ContractError::ZeroWeight {}.to_string()); - let err = Threshold::AbsoluteCount { weight: 6 } - .validate(5) - .unwrap_err(); - assert_eq!( - err.to_string(), - ContractError::UnreachableWeight {}.to_string() - ); - - Threshold::AbsoluteCount { weight: 1 }.validate(5).unwrap(); - Threshold::AbsoluteCount { weight: 5 }.validate(5).unwrap(); - - // AbsolutePercentage just enforces valid_percentage (tested above) - let err = Threshold::AbsolutePercentage { - percentage: Decimal::zero(), - } - .validate(5) - .unwrap_err(); - assert_eq!( - err.to_string(), - ContractError::InvalidThreshold {}.to_string() - ); - Threshold::AbsolutePercentage { - percentage: Decimal::percent(51), - } - .validate(5) - .unwrap(); - - // Quorum enforces both valid just enforces valid_percentage (tested above) - Threshold::ThresholdQuorum { - threshold: Decimal::percent(51), - quorum: Decimal::percent(40), - } - .validate(5) - .unwrap(); - let err = Threshold::ThresholdQuorum { - threshold: Decimal::percent(101), - quorum: Decimal::percent(40), - } - .validate(5) - .unwrap_err(); - assert_eq!( - err.to_string(), - ContractError::InvalidThreshold {}.to_string() - ); - let err = Threshold::ThresholdQuorum { - threshold: Decimal::percent(51), - quorum: Decimal::percent(0), - } - .validate(5) - .unwrap_err(); - assert_eq!( - err.to_string(), - ContractError::ZeroQuorumThreshold {}.to_string() - ); - } - - #[test] - fn threshold_response() { - let total_weight: u64 = 100; - - let res = Threshold::AbsoluteCount { weight: 42 }.to_response(total_weight); - assert_eq!( - res, - ThresholdResponse::AbsoluteCount { - weight: 42, - total_weight - } - ); - - let res = Threshold::AbsolutePercentage { - percentage: Decimal::percent(51), - } - .to_response(total_weight); - assert_eq!( - res, - ThresholdResponse::AbsolutePercentage { - percentage: Decimal::percent(51), - total_weight - } - ); - - let res = Threshold::ThresholdQuorum { - threshold: Decimal::percent(66), - quorum: Decimal::percent(50), - } - .to_response(total_weight); - assert_eq!( - res, - ThresholdResponse::ThresholdQuorum { - threshold: Decimal::percent(66), - quorum: Decimal::percent(50), - total_weight - } - ); - } -} diff --git a/contracts/cw3-flex-multisig/src/state.rs b/contracts/cw3-flex-multisig/src/state.rs index 013757beb..59b1518b4 100644 --- a/contracts/cw3-flex-multisig/src/state.rs +++ b/contracts/cw3-flex-multisig/src/state.rs @@ -6,9 +6,7 @@ use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Decimal, Empty, StdResult, Storag use cw3::{Status, Vote}; use cw4::Cw4Contract; use cw_storage_plus::{Item, Map}; -use utils::{Duration, Expiration}; - -use crate::msg::Threshold; +use utils::{Duration, Expiration, Threshold}; // we multiply by this when calculating needed_votes in order to round up properly // Note: `10u128.pow(9)` fails as "u128::pow` is not yet stable as a const fn" diff --git a/packages/cw3/examples/schema.rs b/packages/cw3/examples/schema.rs index 2cbd5f59b..53329e81e 100644 --- a/packages/cw3/examples/schema.rs +++ b/packages/cw3/examples/schema.rs @@ -4,9 +4,10 @@ use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for}; use cw3::{ - Cw3ExecuteMsg, Cw3QueryMsg, ProposalListResponse, ProposalResponse, ThresholdResponse, - VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, + Cw3ExecuteMsg, Cw3QueryMsg, ProposalListResponse, ProposalResponse, VoteListResponse, + VoteResponse, VoterDetail, VoterListResponse, VoterResponse, }; +use utils::ThresholdResponse; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/packages/cw3/src/lib.rs b/packages/cw3/src/lib.rs index 307bea09a..bda9d2d93 100644 --- a/packages/cw3/src/lib.rs +++ b/packages/cw3/src/lib.rs @@ -6,14 +6,6 @@ mod query; pub use crate::helpers::Cw3Contract; pub use crate::msg::{Cw3ExecuteMsg, Vote}; pub use crate::query::{ - Cw3QueryMsg, ProposalListResponse, ProposalResponse, Status, ThresholdResponse, VoteInfo, - VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, + Cw3QueryMsg, ProposalListResponse, ProposalResponse, Status, VoteInfo, VoteListResponse, + VoteResponse, VoterDetail, VoterListResponse, VoterResponse, }; - -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - // test me - } -} diff --git a/packages/cw3/src/query.rs b/packages/cw3/src/query.rs index 5cfd17189..ea28e918e 100644 --- a/packages/cw3/src/query.rs +++ b/packages/cw3/src/query.rs @@ -2,8 +2,8 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::fmt; -use cosmwasm_std::{CosmosMsg, Decimal, Empty}; -use utils::Expiration; +use cosmwasm_std::{CosmosMsg, Empty}; +use utils::{Expiration, ThresholdResponse}; use crate::msg::Vote; @@ -49,75 +49,6 @@ pub enum Cw3QueryMsg { }, } -/// This defines the different ways tallies can happen. -/// Every contract should support a subset of these, ideally all. -/// -/// The total_weight used for calculating success as well as the weights of each -/// individual voter used in tallying should be snapshotted at the beginning of -/// the block at which the proposal starts (this is likely the responsibility of a -/// correct cw4 implementation). -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] -pub enum ThresholdResponse { - /// Declares that a fixed weight of yes votes is needed to pass. - /// It does not matter how many no votes are cast, or how many do not vote, - /// as long as `weight` yes votes are cast. - /// - /// This is the simplest format and usually suitable for small multisigs of trusted parties, - /// like 3 of 5. (weight: 3, total_weight: 5) - /// - /// A proposal of this type can pass early as soon as the needed weight of yes votes has been cast. - AbsoluteCount { weight: u64, total_weight: u64 }, - - /// Declares a percentage of the total weight that must cast Yes votes, in order for - /// a proposal to pass. The passing weight is computed over the total weight minus the weight of the - /// abstained votes. - /// - /// This is useful for similar circumstances as `AbsoluteCount`, where we have a relatively - /// small set of voters, and participation is required. - /// It is understood that if the voting set (group) changes between different proposals that - /// refer to the same group, each proposal will work with a different set of voter weights - /// (the ones snapshotted at proposal creation), and the passing weight for each proposal - /// will be computed based on the absolute percentage, times the total weights of the members - /// at the time of each proposal creation. - /// - /// Example: we set `percentage` to 51%. Proposal 1 starts when there is a `total_weight` of 5. - /// This will require 3 weight of Yes votes in order to pass. Later, the Proposal 2 starts but the - /// `total_weight` of the group has increased to 9. That proposal will then automatically - /// require 5 Yes of 9 to pass, rather than 3 yes of 9 as would be the case with `AbsoluteCount`. - AbsolutePercentage { - percentage: Decimal, - total_weight: u64, - }, - - /// In addition to a `threshold`, declares a `quorum` of the total votes that must participate - /// in the election in order for the vote to be considered at all. Within the votes that - /// were cast, it requires `threshold` votes in favor. That is calculated by ignoring - /// the Abstain votes (they count towards `quorum`, but do not influence `threshold`). - /// That is, we calculate `Yes / (Yes + No + Veto)` and compare it with `threshold` to consider - /// if the proposal was passed. - /// - /// It is rather difficult for a proposal of this type to pass early. That can only happen if - /// the required quorum has been already met, and there are already enough Yes votes for the - /// proposal to pass. - /// - /// 30% Yes votes, 10% No votes, and 20% Abstain would pass early if quorum <= 60% - /// (who has cast votes) and if the threshold is <= 37.5% (the remaining 40% voting - /// no => 30% yes + 50% no). Once the voting period has passed with no additional votes, - /// that same proposal would be considered successful if quorum <= 60% and threshold <= 75% - /// (percent in favor if we ignore abstain votes). - /// - /// This type is more common in general elections, where participation is often expected to - /// be low, and `AbsolutePercentage` would either be too high to pass anything, - /// or allow low percentages to pass, independently of if there was high participation in the - /// election or not. - ThresholdQuorum { - threshold: Decimal, - quorum: Decimal, - total_weight: u64, - }, -} - /// Note, if you are storing custom messages in the proposal, /// the querier needs to know what possible custom message types /// those are in order to parse the response diff --git a/packages/utils/src/lib.rs b/packages/utils/src/lib.rs index 939599c00..c39b1005e 100644 --- a/packages/utils/src/lib.rs +++ b/packages/utils/src/lib.rs @@ -4,6 +4,7 @@ mod expiration; mod pagination; mod parse_reply; mod payment; +mod threshold; pub use pagination::{ calc_range_end, calc_range_start, calc_range_start_string, maybe_addr, maybe_canonical, @@ -14,6 +15,7 @@ pub use parse_reply::{ ParseReplyError, }; pub use payment::{may_pay, must_pay, nonpayable, one_coin, PaymentError}; +pub use threshold::{Threshold, ThresholdError, ThresholdResponse}; pub use crate::balance::NativeBalance; pub use crate::event::Event; diff --git a/packages/utils/src/threshold.rs b/packages/utils/src/threshold.rs new file mode 100644 index 000000000..b919f7a02 --- /dev/null +++ b/packages/utils/src/threshold.rs @@ -0,0 +1,341 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use cosmwasm_std::{Decimal, StdError}; +use thiserror::Error; + +/// This defines the different ways tallies can happen. +/// +/// The total_weight used for calculating success as well as the weights of each +/// individual voter used in tallying should be snapshotted at the beginning of +/// the block at which the proposal starts (this is likely the responsibility of a +/// correct cw4 implementation). +/// See also `ThresholdResponse` in the cw3 spec. +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +pub enum Threshold { + /// Declares that a fixed weight of Yes votes is needed to pass. + /// See `ThresholdResponse.AbsoluteCount` in the cw3 spec for details. + AbsoluteCount { weight: u64 }, + + /// Declares a percentage of the total weight that must cast Yes votes in order for + /// a proposal to pass. + /// See `ThresholdResponse.AbsolutePercentage` in the cw3 spec for details. + AbsolutePercentage { percentage: Decimal }, + + /// Declares a `quorum` of the total votes that must participate in the election in order + /// for the vote to be considered at all. + /// See `ThresholdResponse.ThresholdQuorum` in the cw3 spec for details. + ThresholdQuorum { threshold: Decimal, quorum: Decimal }, +} + +impl Threshold { + /// returns error if this is an unreachable value, + /// given a total weight of all members in the group + pub fn validate(&self, total_weight: u64) -> Result<(), ThresholdError> { + match self { + Threshold::AbsoluteCount { + weight: weight_needed, + } => { + if *weight_needed == 0 { + Err(ThresholdError::ZeroWeight {}) + } else if *weight_needed > total_weight { + Err(ThresholdError::UnreachableWeight {}) + } else { + Ok(()) + } + } + Threshold::AbsolutePercentage { + percentage: percentage_needed, + } => valid_threshold(percentage_needed), + Threshold::ThresholdQuorum { + threshold, + quorum: quroum, + } => { + valid_threshold(threshold)?; + valid_quorum(quroum) + } + } + } + + /// Creates a response from the saved data, just missing the total_weight info + pub fn to_response(&self, total_weight: u64) -> ThresholdResponse { + match self.clone() { + Threshold::AbsoluteCount { weight } => ThresholdResponse::AbsoluteCount { + weight, + total_weight, + }, + Threshold::AbsolutePercentage { percentage } => ThresholdResponse::AbsolutePercentage { + percentage, + total_weight, + }, + Threshold::ThresholdQuorum { threshold, quorum } => { + ThresholdResponse::ThresholdQuorum { + threshold, + quorum, + total_weight, + } + } + } + } +} + +/// Asserts that the 0.5 < percent <= 1.0 +fn valid_threshold(percent: &Decimal) -> Result<(), ThresholdError> { + if *percent > Decimal::percent(100) || *percent < Decimal::percent(50) { + Err(ThresholdError::InvalidThreshold {}) + } else { + Ok(()) + } +} + +/// Asserts that the 0.5 < percent <= 1.0 +fn valid_quorum(percent: &Decimal) -> Result<(), ThresholdError> { + if percent.is_zero() { + Err(ThresholdError::ZeroQuorumThreshold {}) + } else if *percent > Decimal::one() { + Err(ThresholdError::UnreachableQuorumThreshold {}) + } else { + Ok(()) + } +} + +/// This defines the different ways tallies can happen. +/// Every contract should support a subset of these, ideally all. +/// +/// The total_weight used for calculating success as well as the weights of each +/// individual voter used in tallying should be snapshotted at the beginning of +/// the block at which the proposal starts (this is likely the responsibility of a +/// correct cw4 implementation). +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +pub enum ThresholdResponse { + /// Declares that a fixed weight of yes votes is needed to pass. + /// It does not matter how many no votes are cast, or how many do not vote, + /// as long as `weight` yes votes are cast. + /// + /// This is the simplest format and usually suitable for small multisigs of trusted parties, + /// like 3 of 5. (weight: 3, total_weight: 5) + /// + /// A proposal of this type can pass early as soon as the needed weight of yes votes has been cast. + AbsoluteCount { weight: u64, total_weight: u64 }, + + /// Declares a percentage of the total weight that must cast Yes votes, in order for + /// a proposal to pass. The passing weight is computed over the total weight minus the weight of the + /// abstained votes. + /// + /// This is useful for similar circumstances as `AbsoluteCount`, where we have a relatively + /// small set of voters, and participation is required. + /// It is understood that if the voting set (group) changes between different proposals that + /// refer to the same group, each proposal will work with a different set of voter weights + /// (the ones snapshotted at proposal creation), and the passing weight for each proposal + /// will be computed based on the absolute percentage, times the total weights of the members + /// at the time of each proposal creation. + /// + /// Example: we set `percentage` to 51%. Proposal 1 starts when there is a `total_weight` of 5. + /// This will require 3 weight of Yes votes in order to pass. Later, the Proposal 2 starts but the + /// `total_weight` of the group has increased to 9. That proposal will then automatically + /// require 5 Yes of 9 to pass, rather than 3 yes of 9 as would be the case with `AbsoluteCount`. + AbsolutePercentage { + percentage: Decimal, + total_weight: u64, + }, + + /// In addition to a `threshold`, declares a `quorum` of the total votes that must participate + /// in the election in order for the vote to be considered at all. Within the votes that + /// were cast, it requires `threshold` votes in favor. That is calculated by ignoring + /// the Abstain votes (they count towards `quorum`, but do not influence `threshold`). + /// That is, we calculate `Yes / (Yes + No + Veto)` and compare it with `threshold` to consider + /// if the proposal was passed. + /// + /// It is rather difficult for a proposal of this type to pass early. That can only happen if + /// the required quorum has been already met, and there are already enough Yes votes for the + /// proposal to pass. + /// + /// 30% Yes votes, 10% No votes, and 20% Abstain would pass early if quorum <= 60% + /// (who has cast votes) and if the threshold is <= 37.5% (the remaining 40% voting + /// no => 30% yes + 50% no). Once the voting period has passed with no additional votes, + /// that same proposal would be considered successful if quorum <= 60% and threshold <= 75% + /// (percent in favor if we ignore abstain votes). + /// + /// This type is more common in general elections, where participation is often expected to + /// be low, and `AbsolutePercentage` would either be too high to pass anything, + /// or allow low percentages to pass, independently of if there was high participation in the + /// election or not. + ThresholdQuorum { + threshold: Decimal, + quorum: Decimal, + total_weight: u64, + }, +} + +#[derive(Error, Debug, PartialEq)] +pub enum ThresholdError { + #[error("{0}")] + Std(#[from] StdError), + + #[error("Invalid voting threshold percentage, must be in the 0.5-1.0 range")] + InvalidThreshold {}, + + #[error("Required quorum threshold cannot be zero")] + ZeroQuorumThreshold {}, + + #[error("Not possible to reach required quorum threshold")] + UnreachableQuorumThreshold {}, + + #[error("Required weight cannot be zero")] + ZeroWeight {}, + + #[error("Not possible to reach required (passing) weight")] + UnreachableWeight {}, +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn validate_quorum_percentage() { + // TODO: test the error messages + + // 0 is never a valid percentage + let err = valid_quorum(&Decimal::zero()).unwrap_err(); + assert_eq!( + err.to_string(), + ThresholdError::ZeroQuorumThreshold {}.to_string() + ); + + // 100% is + valid_quorum(&Decimal::one()).unwrap(); + + // 101% is not + let err = valid_quorum(&Decimal::percent(101)).unwrap_err(); + assert_eq!( + err.to_string(), + ThresholdError::UnreachableQuorumThreshold {}.to_string() + ); + // not 100.1% + let err = valid_quorum(&Decimal::permille(1001)).unwrap_err(); + assert_eq!( + err.to_string(), + ThresholdError::UnreachableQuorumThreshold {}.to_string() + ); + } + + #[test] + fn validate_threshold_percentage() { + // other values in between 0.5 and 1 are valid + valid_threshold(&Decimal::percent(51)).unwrap(); + valid_threshold(&Decimal::percent(67)).unwrap(); + valid_threshold(&Decimal::percent(99)).unwrap(); + let err = valid_threshold(&Decimal::percent(101)).unwrap_err(); + assert_eq!( + err.to_string(), + ThresholdError::InvalidThreshold {}.to_string() + ); + } + + #[test] + fn validate_threshold() { + // absolute count ensures 0 < required <= total_weight + let err = Threshold::AbsoluteCount { weight: 0 } + .validate(5) + .unwrap_err(); + // TODO: remove to_string() when PartialEq implemented + assert_eq!(err.to_string(), ThresholdError::ZeroWeight {}.to_string()); + let err = Threshold::AbsoluteCount { weight: 6 } + .validate(5) + .unwrap_err(); + assert_eq!( + err.to_string(), + ThresholdError::UnreachableWeight {}.to_string() + ); + + Threshold::AbsoluteCount { weight: 1 }.validate(5).unwrap(); + Threshold::AbsoluteCount { weight: 5 }.validate(5).unwrap(); + + // AbsolutePercentage just enforces valid_percentage (tested above) + let err = Threshold::AbsolutePercentage { + percentage: Decimal::zero(), + } + .validate(5) + .unwrap_err(); + assert_eq!( + err.to_string(), + ThresholdError::InvalidThreshold {}.to_string() + ); + Threshold::AbsolutePercentage { + percentage: Decimal::percent(51), + } + .validate(5) + .unwrap(); + + // Quorum enforces both valid just enforces valid_percentage (tested above) + Threshold::ThresholdQuorum { + threshold: Decimal::percent(51), + quorum: Decimal::percent(40), + } + .validate(5) + .unwrap(); + let err = Threshold::ThresholdQuorum { + threshold: Decimal::percent(101), + quorum: Decimal::percent(40), + } + .validate(5) + .unwrap_err(); + assert_eq!( + err.to_string(), + ThresholdError::InvalidThreshold {}.to_string() + ); + let err = Threshold::ThresholdQuorum { + threshold: Decimal::percent(51), + quorum: Decimal::percent(0), + } + .validate(5) + .unwrap_err(); + assert_eq!( + err.to_string(), + ThresholdError::ZeroQuorumThreshold {}.to_string() + ); + } + + #[test] + fn threshold_response() { + let total_weight: u64 = 100; + + let res = Threshold::AbsoluteCount { weight: 42 }.to_response(total_weight); + assert_eq!( + res, + ThresholdResponse::AbsoluteCount { + weight: 42, + total_weight + } + ); + + let res = Threshold::AbsolutePercentage { + percentage: Decimal::percent(51), + } + .to_response(total_weight); + assert_eq!( + res, + ThresholdResponse::AbsolutePercentage { + percentage: Decimal::percent(51), + total_weight + } + ); + + let res = Threshold::ThresholdQuorum { + threshold: Decimal::percent(66), + quorum: Decimal::percent(50), + } + .to_response(total_weight); + assert_eq!( + res, + ThresholdResponse::ThresholdQuorum { + threshold: Decimal::percent(66), + quorum: Decimal::percent(50), + total_weight + } + ); + } +} From 1b43516fb06e875919e8fbad9fdd92d727f3cdf6 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Tue, 21 Dec 2021 14:05:32 +0100 Subject: [PATCH 083/352] cw3-fixed-multisig: require >=1 weight for proposing and voting --- contracts/cw3-fixed-multisig/src/contract.rs | 70 +++++++++++++++++--- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index ece844dc0..b2eba9c25 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -89,10 +89,12 @@ pub fn execute_propose( // we ignore earliest latest: Option, ) -> Result, ContractError> { - // only members of the multisig can create a proposal - let vote_power = VOTERS - .may_load(deps.storage, &info.sender)? - .ok_or(ContractError::Unauthorized {})?; + // only members of the multisig with weight >= 1 can create a proposal + let voter_power = VOTERS.may_load(deps.storage, &info.sender)?; + let vote_power = match voter_power { + Some(power) if power >= 1 => power, + _ => return Err(ContractError::Unauthorized {}), + }; let cfg = CONFIG.load(deps.storage)?; @@ -146,10 +148,12 @@ pub fn execute_vote( proposal_id: u64, vote: Vote, ) -> Result, ContractError> { - // only members of the multisig can vote - let vote_power = VOTERS - .may_load(deps.storage, &info.sender)? - .ok_or(ContractError::Unauthorized {})?; + // only members of the multisig with weight >= 1 can vote + let voter_power = VOTERS.may_load(deps.storage, &info.sender)?; + let vote_power = match voter_power { + Some(power) if power >= 1 => power, + _ => return Err(ContractError::Unauthorized {}), + }; // ensure proposal exists and can be voted on let mut prop = PROPOSALS.load(deps.storage, proposal_id)?; @@ -458,6 +462,7 @@ mod tests { const VOTER3: &str = "voter0003"; const VOTER4: &str = "voter0004"; const VOTER5: &str = "voter0005"; + const NOWEIGHT_VOTER: &str = "voterxxxx"; const SOMEBODY: &str = "somebody"; fn voter>(addr: T, weight: u64) -> Voter { @@ -468,6 +473,7 @@ mod tests { } // this will set up the instantiation for other tests + #[track_caller] fn setup_test_case( deps: DepsMut, info: MessageInfo, @@ -476,12 +482,13 @@ mod tests { ) -> Result, ContractError> { // Instantiate a contract with voters let voters = vec![ - voter(&info.sender, 0), + voter(&info.sender, 1), voter(VOTER1, 1), voter(VOTER2, 2), voter(VOTER3, 3), voter(VOTER4, 4), voter(VOTER5, 5), + voter(NOWEIGHT_VOTER, 0), ]; let instantiate_msg = InstantiateMsg { @@ -564,6 +571,51 @@ mod tests { // TODO: query() tests + #[test] + fn zero_weight_member_cant_propose_and_vote() { + let mut deps = mock_dependencies(); + + let required_weight = 4; + let voting_period = Duration::Time(2000000); + + let info = mock_info(OWNER, &[]); + setup_test_case(deps.as_mut(), info, required_weight, voting_period).unwrap(); + + let bank_msg = BankMsg::Send { + to_address: SOMEBODY.into(), + amount: vec![coin(1, "BTC")], + }; + let msgs = vec![CosmosMsg::Bank(bank_msg)]; + + // Only voters with weight can propose + let info = mock_info(NOWEIGHT_VOTER, &[]); + let proposal = ExecuteMsg::Propose { + title: "Rewarding somebody".to_string(), + description: "Do we reward her?".to_string(), + msgs, + latest: None, + }; + let err = execute(deps.as_mut(), mock_env(), info, proposal.clone()).unwrap_err(); + assert_eq!(err, ContractError::Unauthorized {}); + + // Propose proposal + let info = mock_info(OWNER, &[]); + let res = execute(deps.as_mut(), mock_env(), info, proposal).unwrap(); + + // Get the proposal id from the logs + let proposal_id: u64 = res.attributes[2].value.parse().unwrap(); + + // Cast a No vote + let no_vote = ExecuteMsg::Vote { + proposal_id, + vote: Vote::No, + }; + // Only voters with weight can vote + let info = mock_info(NOWEIGHT_VOTER, &[]); + execute(deps.as_mut(), mock_env(), info, no_vote).unwrap_err(); + assert_eq!(err, ContractError::Unauthorized {}); + } + #[test] fn test_propose_works() { let mut deps = mock_dependencies(); From 0faeaf4aba9e1be0120db8ffc3cd8bfdea73d8fc Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Tue, 21 Dec 2021 15:17:54 +0100 Subject: [PATCH 084/352] cw3-fixed-multisig: reuse or copy most of existing implementation from cw3-flex-multisig --- Cargo.lock | 1 + contracts/cw3-fixed-multisig/Cargo.toml | 1 + contracts/cw3-fixed-multisig/src/contract.rs | 91 +++++++------------- contracts/cw3-fixed-multisig/src/error.rs | 4 + contracts/cw3-fixed-multisig/src/msg.rs | 3 +- contracts/cw3-fixed-multisig/src/state.rs | 54 +----------- contracts/cw3-flex-multisig/src/lib.rs | 2 +- 7 files changed, 42 insertions(+), 114 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43fed7b8b..bace81e43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -530,6 +530,7 @@ dependencies = [ "cw20", "cw20-base", "cw3", + "cw3-flex-multisig", "schemars", "serde", "thiserror", diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index edab67af4..5843d0ebe 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -21,6 +21,7 @@ library = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw3 = { path = "../../packages/cw3", version = "0.10.3" } +cw3-flex-multisig = { path = "../cw3-flex-multisig", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index b2eba9c25..f37275010 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -12,12 +12,14 @@ use cw3::{ ProposalListResponse, ProposalResponse, Status, Vote, VoteInfo, VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, }; +use cw3_flex_multisig::state::{next_id, Ballot, Proposal, Votes, BALLOTS, PROPOSALS}; + use cw_storage_plus::Bound; use utils::{Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{next_id, Ballot, Config, Proposal, BALLOTS, CONFIG, PROPOSALS, VOTERS}; +use crate::state::{Config, CONFIG, VOTERS}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw3-fixed-multisig"; @@ -30,22 +32,17 @@ pub fn instantiate( _info: MessageInfo, msg: InstantiateMsg, ) -> Result { - if msg.required_weight == 0 { - return Err(ContractError::ZeroWeight {}); - } if msg.voters.is_empty() { return Err(ContractError::NoVoters {}); } let total_weight = msg.voters.iter().map(|v| v.weight).sum(); - if total_weight < msg.required_weight { - return Err(ContractError::UnreachableWeight {}); - } + msg.threshold.validate(total_weight)?; set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; let cfg = Config { - required_weight: msg.required_weight, + threshold: msg.threshold, total_weight, max_voting_period: msg.max_voting_period, }; @@ -89,12 +86,10 @@ pub fn execute_propose( // we ignore earliest latest: Option, ) -> Result, ContractError> { - // only members of the multisig with weight >= 1 can create a proposal - let voter_power = VOTERS.may_load(deps.storage, &info.sender)?; - let vote_power = match voter_power { - Some(power) if power >= 1 => power, - _ => return Err(ContractError::Unauthorized {}), - }; + // only members of the multisig can create a proposal + let vote_power = VOTERS + .may_load(deps.storage, &info.sender)? + .ok_or(ContractError::Unauthorized {})?; let cfg = CONFIG.load(deps.storage)?; @@ -108,22 +103,19 @@ pub fn execute_propose( return Err(ContractError::WrongExpiration {}); } - let status = if vote_power < cfg.required_weight { - Status::Open - } else { - Status::Passed - }; - // create a proposal - let prop = Proposal { + let mut prop = Proposal { title, description, + start_height: env.block.height, expires, msgs, - status, - yes_weight: vote_power, - required_weight: cfg.required_weight, + status: Status::Open, + votes: Votes::yes(vote_power), + threshold: cfg.threshold, + total_weight: cfg.total_weight, }; + prop.update_status(&env.block); let id = next_id(deps.storage)?; PROPOSALS.save(deps.storage, id, &prop)?; @@ -173,15 +165,10 @@ pub fn execute_vote( }), })?; - // if yes vote, update tally - if vote == Vote::Yes { - prop.yes_weight += vote_power; - // update status when the passing vote comes in - if prop.yes_weight >= prop.required_weight { - prop.status = Status::Passed; - } - PROPOSALS.save(deps.storage, proposal_id, &prop)?; - } + // update vote tally + prop.votes.add_vote(vote, vote_power); + prop.update_status(&env.block); + PROPOSALS.save(deps.storage, proposal_id, &prop)?; Ok(Response::new() .add_attribute("action", "vote") @@ -273,21 +260,13 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { fn query_threshold(deps: Deps) -> StdResult { let cfg = CONFIG.load(deps.storage)?; - Ok(ThresholdResponse::AbsoluteCount { - weight: cfg.required_weight, - total_weight: cfg.total_weight, - }) + Ok(cfg.threshold.to_response(cfg.total_weight)) } fn query_proposal(deps: Deps, env: Env, id: u64) -> StdResult { let prop = PROPOSALS.load(deps.storage, id)?; let status = prop.current_status(&env.block); - - let cfg = CONFIG.load(deps.storage)?; - let threshold = ThresholdResponse::AbsoluteCount { - weight: cfg.required_weight, - total_weight: cfg.total_weight, - }; + let threshold = prop.threshold.to_response(prop.total_weight); Ok(ProposalResponse { id, title: prop.title, @@ -309,18 +288,12 @@ fn list_proposals( start_after: Option, limit: Option, ) -> StdResult { - let cfg = CONFIG.load(deps.storage)?; - let threshold = ThresholdResponse::AbsoluteCount { - weight: cfg.required_weight, - total_weight: cfg.total_weight, - }; - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let start = start_after.map(Bound::exclusive_int); let proposals = PROPOSALS .range(deps.storage, start, None, Order::Ascending) .take(limit) - .map(|p| map_proposal(&env.block, &threshold, p)) + .map(|p| map_proposal(&env.block, p)) .collect::>()?; Ok(ProposalListResponse { proposals }) @@ -332,30 +305,24 @@ fn reverse_proposals( start_before: Option, limit: Option, ) -> StdResult { - let cfg = CONFIG.load(deps.storage)?; - let threshold = ThresholdResponse::AbsoluteCount { - weight: cfg.required_weight, - total_weight: cfg.total_weight, - }; - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let end = start_before.map(Bound::exclusive_int); - let proposals = PROPOSALS + let props: StdResult> = PROPOSALS .range(deps.storage, None, end, Order::Descending) .take(limit) - .map(|p| map_proposal(&env.block, &threshold, p)) - .collect::>()?; + .map(|p| map_proposal(&env.block, p)) + .collect(); - Ok(ProposalListResponse { proposals }) + Ok(ProposalListResponse { proposals: props? }) } fn map_proposal( block: &BlockInfo, - threshold: &ThresholdResponse, item: StdResult<(u64, Proposal)>, ) -> StdResult { item.map(|(id, prop)| { let status = prop.current_status(block); + let threshold = prop.threshold.to_response(prop.total_weight); ProposalResponse { id, title: prop.title, @@ -363,7 +330,7 @@ fn map_proposal( msgs: prop.msgs, status, expires: prop.expires, - threshold: threshold.clone(), + threshold, } }) } diff --git a/contracts/cw3-fixed-multisig/src/error.rs b/contracts/cw3-fixed-multisig/src/error.rs index 78e0eb036..83ab07362 100644 --- a/contracts/cw3-fixed-multisig/src/error.rs +++ b/contracts/cw3-fixed-multisig/src/error.rs @@ -1,4 +1,5 @@ use cosmwasm_std::StdError; +use cw3_flex_multisig::error::ContractError as Cw3FlexMultisigError; use thiserror::Error; #[derive(Error, Debug, PartialEq)] @@ -6,6 +7,9 @@ pub enum ContractError { #[error("{0}")] Std(#[from] StdError), + #[error("{0}")] + FlexMultisig(#[from] Cw3FlexMultisigError), + #[error("Required weight cannot be zero")] ZeroWeight {}, diff --git a/contracts/cw3-fixed-multisig/src/msg.rs b/contracts/cw3-fixed-multisig/src/msg.rs index 41aae35eb..81ed7801a 100644 --- a/contracts/cw3-fixed-multisig/src/msg.rs +++ b/contracts/cw3-fixed-multisig/src/msg.rs @@ -3,12 +3,13 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{CosmosMsg, Empty}; use cw3::Vote; +use cw3_flex_multisig::msg::Threshold; use utils::{Duration, Expiration}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct InstantiateMsg { pub voters: Vec, - pub required_weight: u64, + pub threshold: Threshold, pub max_voting_period: Duration, } diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index b596ef605..27e2d2801 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -1,67 +1,21 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Empty, StdResult, Storage}; - -use cw3::{Status, Vote}; +use cosmwasm_std::Addr; +use cw3_flex_multisig::msg::Threshold; use cw_storage_plus::{Item, Map}; -use utils::{Duration, Expiration}; +use utils::Duration; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { - pub required_weight: u64, + pub threshold: Threshold, pub total_weight: u64, pub max_voting_period: Duration, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct Proposal { - pub title: String, - pub description: String, - pub expires: Expiration, - pub msgs: Vec>, - pub status: Status, - /// how many votes have already said yes - pub yes_weight: u64, - /// how many votes needed to pass - pub required_weight: u64, -} - -impl Proposal { - pub fn current_status(&self, block: &BlockInfo) -> Status { - let mut status = self.status; - - // if open, check if voting is passed or timed out - if status == Status::Open && self.yes_weight >= self.required_weight { - status = Status::Passed; - } - if status == Status::Open && self.expires.is_expired(block) { - status = Status::Rejected; - } - - status - } -} - -// we cast a ballot with our chosen vote and a given weight -// stored under the key that voted -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct Ballot { - pub weight: u64, - pub vote: Vote, -} - // unique items pub const CONFIG: Item = Item::new("config"); pub const PROPOSAL_COUNT: Item = Item::new("proposal_count"); // multiple-item maps pub const VOTERS: Map<&Addr, u64> = Map::new("voters"); -pub const PROPOSALS: Map = Map::new("proposals"); -pub const BALLOTS: Map<(u64, &Addr), Ballot> = Map::new("ballots"); - -pub fn next_id(store: &mut dyn Storage) -> StdResult { - let id: u64 = PROPOSAL_COUNT.may_load(store)?.unwrap_or_default() + 1; - PROPOSAL_COUNT.save(store, &id)?; - Ok(id) -} diff --git a/contracts/cw3-flex-multisig/src/lib.rs b/contracts/cw3-flex-multisig/src/lib.rs index dfedc9dc6..e5ff7237e 100644 --- a/contracts/cw3-flex-multisig/src/lib.rs +++ b/contracts/cw3-flex-multisig/src/lib.rs @@ -1,5 +1,5 @@ pub mod contract; -mod error; +pub mod error; pub mod msg; pub mod state; From 2942b8a1c1908463abe887a9263b6f5bd54fa333 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Tue, 21 Dec 2021 15:44:50 +0100 Subject: [PATCH 085/352] cw3-fixed-multisig: adapt tests so that now quorum is checked --- contracts/cw3-fixed-multisig/src/contract.rs | 76 +++++++++---------- .../src/integration_tests.rs | 8 +- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index f37275010..9097e37ad 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -402,9 +402,10 @@ fn list_voters( #[cfg(test)] mod tests { use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{coin, from_binary, BankMsg}; + use cosmwasm_std::{coin, from_binary, BankMsg, Decimal}; use cw2::{get_contract_version, ContractVersion}; + use cw3_flex_multisig::msg::Threshold; use utils::Duration; use crate::msg::Voter; @@ -444,7 +445,7 @@ mod tests { fn setup_test_case( deps: DepsMut, info: MessageInfo, - required_weight: u64, + threshold: Threshold, max_voting_period: Duration, ) -> Result, ContractError> { // Instantiate a contract with voters @@ -460,7 +461,7 @@ mod tests { let instantiate_msg = InstantiateMsg { voters, - required_weight, + threshold, max_voting_period, }; instantiate(deps, mock_env(), info, instantiate_msg) @@ -494,37 +495,41 @@ mod tests { // No voters fails let instantiate_msg = InstantiateMsg { voters: vec![], - required_weight: 1, + threshold: Threshold::ThresholdQuorum { + threshold: Decimal::zero(), + quorum: Decimal::percent(1), + }, max_voting_period, }; - let err = - instantiate(deps.as_mut(), mock_env(), info.clone(), instantiate_msg).unwrap_err(); + let err = instantiate( + deps.as_mut(), + mock_env(), + info.clone(), + instantiate_msg.clone(), + ) + .unwrap_err(); assert_eq!(err, ContractError::NoVoters {}); // Zero required weight fails let instantiate_msg = InstantiateMsg { voters: vec![voter(OWNER, 1)], - required_weight: 0, - max_voting_period, + ..instantiate_msg }; let err = instantiate(deps.as_mut(), mock_env(), info.clone(), instantiate_msg).unwrap_err(); - assert_eq!(err, ContractError::ZeroWeight {}); + + use cw3_flex_multisig::ContractError::{InvalidThreshold, UnreachableWeight}; + assert_eq!(err, ContractError::FlexMultisig(InvalidThreshold {})); // Total weight less than required weight not allowed - let required_weight = 100; - let err = setup_test_case( - deps.as_mut(), - info.clone(), - required_weight, - max_voting_period, - ) - .unwrap_err(); - assert_eq!(err, ContractError::UnreachableWeight {}); + let threshold = Threshold::AbsoluteCount { weight: 100 }; + let err = + setup_test_case(deps.as_mut(), info.clone(), threshold, max_voting_period).unwrap_err(); + assert_eq!(err, ContractError::FlexMultisig(UnreachableWeight {})); // All valid - let required_weight = 1; - setup_test_case(deps.as_mut(), info, required_weight, max_voting_period).unwrap(); + let threshold = Threshold::AbsoluteCount { weight: 1 }; + setup_test_case(deps.as_mut(), info, threshold, max_voting_period).unwrap(); // Verify assert_eq!( @@ -539,14 +544,14 @@ mod tests { // TODO: query() tests #[test] - fn zero_weight_member_cant_propose_and_vote() { + fn zero_weight_member_cant_vote() { let mut deps = mock_dependencies(); - let required_weight = 4; + let threshold = Threshold::AbsoluteCount { weight: 4 }; let voting_period = Duration::Time(2000000); let info = mock_info(OWNER, &[]); - setup_test_case(deps.as_mut(), info, required_weight, voting_period).unwrap(); + setup_test_case(deps.as_mut(), info, threshold, voting_period).unwrap(); let bank_msg = BankMsg::Send { to_address: SOMEBODY.into(), @@ -554,7 +559,7 @@ mod tests { }; let msgs = vec![CosmosMsg::Bank(bank_msg)]; - // Only voters with weight can propose + // Voter without voting power still can create proposal let info = mock_info(NOWEIGHT_VOTER, &[]); let proposal = ExecuteMsg::Propose { title: "Rewarding somebody".to_string(), @@ -562,11 +567,6 @@ mod tests { msgs, latest: None, }; - let err = execute(deps.as_mut(), mock_env(), info, proposal.clone()).unwrap_err(); - assert_eq!(err, ContractError::Unauthorized {}); - - // Propose proposal - let info = mock_info(OWNER, &[]); let res = execute(deps.as_mut(), mock_env(), info, proposal).unwrap(); // Get the proposal id from the logs @@ -579,7 +579,7 @@ mod tests { }; // Only voters with weight can vote let info = mock_info(NOWEIGHT_VOTER, &[]); - execute(deps.as_mut(), mock_env(), info, no_vote).unwrap_err(); + let err = execute(deps.as_mut(), mock_env(), info, no_vote).unwrap_err(); assert_eq!(err, ContractError::Unauthorized {}); } @@ -587,11 +587,11 @@ mod tests { fn test_propose_works() { let mut deps = mock_dependencies(); - let required_weight = 4; + let threshold = Threshold::AbsoluteCount { weight: 4 }; let voting_period = Duration::Time(2000000); let info = mock_info(OWNER, &[]); - setup_test_case(deps.as_mut(), info, required_weight, voting_period).unwrap(); + setup_test_case(deps.as_mut(), info, threshold, voting_period).unwrap(); let bank_msg = BankMsg::Send { to_address: SOMEBODY.into(), @@ -654,11 +654,11 @@ mod tests { fn test_vote_works() { let mut deps = mock_dependencies(); - let required_weight = 3; + let threshold = Threshold::AbsoluteCount { weight: 3 }; let voting_period = Duration::Time(2000000); let info = mock_info(OWNER, &[]); - setup_test_case(deps.as_mut(), info.clone(), required_weight, voting_period).unwrap(); + setup_test_case(deps.as_mut(), info.clone(), threshold, voting_period).unwrap(); // Propose let bank_msg = BankMsg::Send { @@ -767,11 +767,11 @@ mod tests { fn test_execute_works() { let mut deps = mock_dependencies(); - let required_weight = 3; + let threshold = Threshold::AbsoluteCount { weight: 3 }; let voting_period = Duration::Time(2000000); let info = mock_info(OWNER, &[]); - setup_test_case(deps.as_mut(), info.clone(), required_weight, voting_period).unwrap(); + setup_test_case(deps.as_mut(), info.clone(), threshold, voting_period).unwrap(); // Propose let bank_msg = BankMsg::Send { @@ -842,11 +842,11 @@ mod tests { fn test_close_works() { let mut deps = mock_dependencies(); - let required_weight = 3; + let threshold = Threshold::AbsoluteCount { weight: 3 }; let voting_period = Duration::Height(2000000); let info = mock_info(OWNER, &[]); - setup_test_case(deps.as_mut(), info.clone(), required_weight, voting_period).unwrap(); + setup_test_case(deps.as_mut(), info.clone(), threshold, voting_period).unwrap(); // Propose let bank_msg = BankMsg::Send { diff --git a/contracts/cw3-fixed-multisig/src/integration_tests.rs b/contracts/cw3-fixed-multisig/src/integration_tests.rs index 6da82182d..e2d7dcab5 100644 --- a/contracts/cw3-fixed-multisig/src/integration_tests.rs +++ b/contracts/cw3-fixed-multisig/src/integration_tests.rs @@ -1,14 +1,16 @@ #![cfg(test)] -use crate::contract::{execute, instantiate, query}; -use crate::msg::{ExecuteMsg, InstantiateMsg, Voter}; use cosmwasm_std::{to_binary, Addr, Empty, Uint128, WasmMsg}; use cw20::{BalanceResponse, MinterResponse}; use cw20_base::msg::QueryMsg; use cw3::Vote; +use cw3_flex_multisig::msg::Threshold; use cw_multi_test::{App, Contract, ContractWrapper, Executor}; use utils::Duration; +use crate::contract::{execute, instantiate, query}; +use crate::msg::{ExecuteMsg, InstantiateMsg, Voter}; + fn mock_app() -> App { App::default() } @@ -53,7 +55,7 @@ fn cw3_controls_cw20() { weight: 1, }, ], - required_weight: 2, + threshold: Threshold::AbsoluteCount { weight: 2 }, max_voting_period: Duration::Height(3), }; From 8c843cb9d53dfd6c9204b83104d323fbb2516647 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 22 Dec 2021 12:45:45 +0100 Subject: [PATCH 086/352] cw3-fixed-multisig: adapt to threshold implementation being moved to utils --- contracts/cw3-fixed-multisig/src/contract.rs | 15 +++++++++------ contracts/cw3-fixed-multisig/src/error.rs | 5 +++-- .../cw3-fixed-multisig/src/integration_tests.rs | 3 +-- contracts/cw3-fixed-multisig/src/msg.rs | 3 +-- contracts/cw3-fixed-multisig/src/state.rs | 3 +-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 9097e37ad..5dd423cb7 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -405,8 +405,7 @@ mod tests { use cosmwasm_std::{coin, from_binary, BankMsg, Decimal}; use cw2::{get_contract_version, ContractVersion}; - use cw3_flex_multisig::msg::Threshold; - use utils::Duration; + use utils::{Duration, Threshold}; use crate::msg::Voter; @@ -517,15 +516,19 @@ mod tests { }; let err = instantiate(deps.as_mut(), mock_env(), info.clone(), instantiate_msg).unwrap_err(); - - use cw3_flex_multisig::ContractError::{InvalidThreshold, UnreachableWeight}; - assert_eq!(err, ContractError::FlexMultisig(InvalidThreshold {})); + assert_eq!( + err, + ContractError::Threshold(utils::ThresholdError::InvalidThreshold {}) + ); // Total weight less than required weight not allowed let threshold = Threshold::AbsoluteCount { weight: 100 }; let err = setup_test_case(deps.as_mut(), info.clone(), threshold, max_voting_period).unwrap_err(); - assert_eq!(err, ContractError::FlexMultisig(UnreachableWeight {})); + assert_eq!( + err, + ContractError::Threshold(utils::ThresholdError::UnreachableWeight {}) + ); // All valid let threshold = Threshold::AbsoluteCount { weight: 1 }; diff --git a/contracts/cw3-fixed-multisig/src/error.rs b/contracts/cw3-fixed-multisig/src/error.rs index 83ab07362..1b4dcebf3 100644 --- a/contracts/cw3-fixed-multisig/src/error.rs +++ b/contracts/cw3-fixed-multisig/src/error.rs @@ -1,5 +1,6 @@ use cosmwasm_std::StdError; -use cw3_flex_multisig::error::ContractError as Cw3FlexMultisigError; +use utils::ThresholdError; + use thiserror::Error; #[derive(Error, Debug, PartialEq)] @@ -8,7 +9,7 @@ pub enum ContractError { Std(#[from] StdError), #[error("{0}")] - FlexMultisig(#[from] Cw3FlexMultisigError), + Threshold(#[from] ThresholdError), #[error("Required weight cannot be zero")] ZeroWeight {}, diff --git a/contracts/cw3-fixed-multisig/src/integration_tests.rs b/contracts/cw3-fixed-multisig/src/integration_tests.rs index e2d7dcab5..a0737a49b 100644 --- a/contracts/cw3-fixed-multisig/src/integration_tests.rs +++ b/contracts/cw3-fixed-multisig/src/integration_tests.rs @@ -4,9 +4,8 @@ use cosmwasm_std::{to_binary, Addr, Empty, Uint128, WasmMsg}; use cw20::{BalanceResponse, MinterResponse}; use cw20_base::msg::QueryMsg; use cw3::Vote; -use cw3_flex_multisig::msg::Threshold; use cw_multi_test::{App, Contract, ContractWrapper, Executor}; -use utils::Duration; +use utils::{Duration, Threshold}; use crate::contract::{execute, instantiate, query}; use crate::msg::{ExecuteMsg, InstantiateMsg, Voter}; diff --git a/contracts/cw3-fixed-multisig/src/msg.rs b/contracts/cw3-fixed-multisig/src/msg.rs index 81ed7801a..3ea74f2b5 100644 --- a/contracts/cw3-fixed-multisig/src/msg.rs +++ b/contracts/cw3-fixed-multisig/src/msg.rs @@ -3,8 +3,7 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{CosmosMsg, Empty}; use cw3::Vote; -use cw3_flex_multisig::msg::Threshold; -use utils::{Duration, Expiration}; +use utils::{Duration, Expiration, Threshold}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct InstantiateMsg { diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index 27e2d2801..5b6b2cab4 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -2,9 +2,8 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::Addr; -use cw3_flex_multisig::msg::Threshold; use cw_storage_plus::{Item, Map}; -use utils::Duration; +use utils::{Duration, Threshold}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { From 090ccdd57c4762fcf75bdc87b12ceb56db1eedf6 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 22 Dec 2021 12:55:43 +0100 Subject: [PATCH 087/352] Add note in MIGRATING.md file about breaking changes to cw3-fixed-multisig instantiate message --- MIGRATING.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/MIGRATING.md b/MIGRATING.md index 551082fca..1229109f8 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -28,6 +28,8 @@ index b4852225..f20a65ec 100644 +use utils::Expiration; ``` +--- + - Deprecate `range` to `range_raw` [\#460](https://github.com/CosmWasm/cw-plus/issues/460) / `range` to `range raw` [\#576](https://github.com/CosmWasm/cw-plus/pull/576). @@ -62,6 +64,8 @@ not only not be deserialized, but also not provided. This is for backwards-compa specifications, and may change in the future once these features are stabilized. See `packages/storage-plus/src/indexed_map.rs` tests for reference. +--- + Renamed methods: - `range` -> `range_raw` - `keys` -> `keys_raw` @@ -72,6 +76,8 @@ Renamed methods: Finally, this applies to all the `Map`-like types, including indexed maps. +--- + - `UniqueIndex` / `MultiIndex` key consistency [\#532](https://github.com/CosmWasm/cw-plus/issues/532) / Index keys consistency [\#568](https://github.com/CosmWasm/cw-plus/pull/568) @@ -134,6 +140,8 @@ index 9f7178af..d11d501e 100644 assert_eq!(data1, marias[0].1); ``` +--- + - Remove the primary key from the `MultiIndex` key specification [\#533](https://github.com/CosmWasm/cw-plus/issues/533) / `MultiIndex` primary key spec removal [\#569](https://github.com/CosmWasm/cw-plus/pull/569) @@ -183,6 +191,8 @@ index 022a4504..c7a3bb9d 100644 let count = map ``` +--- + - Incorrect I32Key Index Ordering [\#489](https://github.com/CosmWasm/cw-plus/issues/489) / Signed int keys order [\#582](https://github.com/CosmWasm/cw-plus/pull/582) @@ -227,6 +237,23 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result, +- pub required_weight: u64, ++ pub threshold: Threshold, + pub max_voting_period: Duration, +} +``` + ### Non-breaking Issues / PRs - Deprecate `IntKey` [\#472](https://github.com/CosmWasm/cw-plus/issues/472) / From 84228346da8c49d29186bb47d9916294d64efc0f Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 22 Dec 2021 13:06:20 +0100 Subject: [PATCH 088/352] Move common proposal and vote implementation so that cw3-flex-multisig would import it from cw3-fixed-multisig --- Cargo.lock | 2 +- contracts/cw3-fixed-multisig/Cargo.toml | 1 - contracts/cw3-fixed-multisig/src/contract.rs | 4 +- contracts/cw3-fixed-multisig/src/state.rs | 359 +++++++++++++++++- contracts/cw3-flex-multisig/Cargo.toml | 1 + contracts/cw3-flex-multisig/src/contract.rs | 3 +- contracts/cw3-flex-multisig/src/state.rs | 361 +------------------ 7 files changed, 364 insertions(+), 367 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bace81e43..76114ddc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -530,7 +530,6 @@ dependencies = [ "cw20", "cw20-base", "cw3", - "cw3-flex-multisig", "schemars", "serde", "thiserror", @@ -547,6 +546,7 @@ dependencies = [ "cw-storage-plus", "cw2", "cw3", + "cw3-fixed-multisig", "cw4", "cw4-group", "schemars", diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index 5843d0ebe..edab67af4 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -21,7 +21,6 @@ library = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw3 = { path = "../../packages/cw3", version = "0.10.3" } -cw3-flex-multisig = { path = "../cw3-flex-multisig", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 5dd423cb7..b8ce7f05f 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -12,14 +12,12 @@ use cw3::{ ProposalListResponse, ProposalResponse, Status, Vote, VoteInfo, VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, }; -use cw3_flex_multisig::state::{next_id, Ballot, Proposal, Votes, BALLOTS, PROPOSALS}; - use cw_storage_plus::Bound; use utils::{Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{Config, CONFIG, VOTERS}; +use crate::state::{next_id, Ballot, Config, Proposal, Votes, BALLOTS, CONFIG, PROPOSALS, VOTERS}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw3-fixed-multisig"; diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index 5b6b2cab4..22a7ae50e 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -1,9 +1,15 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::Addr; +use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Decimal, Empty, StdResult, Storage, Uint128}; + +use cw3::{Status, Vote}; use cw_storage_plus::{Item, Map}; -use utils::{Duration, Threshold}; +use utils::{Duration, Expiration, Threshold}; + +// we multiply by this when calculating needed_votes in order to round up properly +// Note: `10u128.pow(9)` fails as "u128::pow` is not yet stable as a const fn" +const PRECISION_FACTOR: u128 = 1_000_000_000; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { @@ -12,9 +18,358 @@ pub struct Config { pub max_voting_period: Duration, } +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct Proposal { + pub title: String, + pub description: String, + pub start_height: u64, + pub expires: Expiration, + pub msgs: Vec>, + pub status: Status, + /// pass requirements + pub threshold: Threshold, + // the total weight when the proposal started (used to calculate percentages) + pub total_weight: u64, + // summary of existing votes + pub votes: Votes, +} + +impl Proposal { + /// current_status is non-mutable and returns what the status should be. + /// (designed for queries) + pub fn current_status(&self, block: &BlockInfo) -> Status { + let mut status = self.status; + + // if open, check if voting is passed or timed out + if status == Status::Open && self.is_passed(block) { + status = Status::Passed; + } + if status == Status::Open && self.expires.is_expired(block) { + status = Status::Rejected; + } + + status + } + + /// update_status sets the status of the proposal to current_status. + /// (designed for handler logic) + pub fn update_status(&mut self, block: &BlockInfo) { + self.status = self.current_status(block); + } + + // returns true iff this proposal is sure to pass (even before expiration if no future + // sequence of possible votes can cause it to fail) + pub fn is_passed(&self, block: &BlockInfo) -> bool { + match self.threshold { + Threshold::AbsoluteCount { + weight: weight_needed, + } => self.votes.yes >= weight_needed, + Threshold::AbsolutePercentage { + percentage: percentage_needed, + } => { + self.votes.yes + >= votes_needed(self.total_weight - self.votes.abstain, percentage_needed) + } + Threshold::ThresholdQuorum { threshold, quorum } => { + // we always require the quorum + if self.votes.total() < votes_needed(self.total_weight, quorum) { + return false; + } + if self.expires.is_expired(block) { + // If expired, we compare Yes votes against the total number of votes (minus abstain). + let opinions = self.votes.total() - self.votes.abstain; + self.votes.yes >= votes_needed(opinions, threshold) + } else { + // If not expired, we must assume all non-votes will be cast as No. + // We compare threshold against the total weight (minus abstain). + let possible_opinions = self.total_weight - self.votes.abstain; + self.votes.yes >= votes_needed(possible_opinions, threshold) + } + } + } + } +} + +// weight of votes for each option +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct Votes { + pub yes: u64, + pub no: u64, + pub abstain: u64, + pub veto: u64, +} + +impl Votes { + /// sum of all votes + pub fn total(&self) -> u64 { + self.yes + self.no + self.abstain + self.veto + } + + /// create it with a yes vote for this much + pub fn yes(init_weight: u64) -> Self { + Votes { + yes: init_weight, + no: 0, + abstain: 0, + veto: 0, + } + } + + pub fn add_vote(&mut self, vote: Vote, weight: u64) { + match vote { + Vote::Yes => self.yes += weight, + Vote::Abstain => self.abstain += weight, + Vote::No => self.no += weight, + Vote::Veto => self.veto += weight, + } + } +} + +// this is a helper function so Decimal works with u64 rather than Uint128 +// also, we must *round up* here, as we need 8, not 7 votes to reach 50% of 15 total +fn votes_needed(weight: u64, percentage: Decimal) -> u64 { + let applied = percentage * Uint128::new(PRECISION_FACTOR * weight as u128); + // Divide by PRECISION_FACTOR, rounding up to the nearest integer + ((applied.u128() + PRECISION_FACTOR - 1) / PRECISION_FACTOR) as u64 +} + +// we cast a ballot with our chosen vote and a given weight +// stored under the key that voted +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct Ballot { + pub weight: u64, + pub vote: Vote, +} + // unique items pub const CONFIG: Item = Item::new("config"); pub const PROPOSAL_COUNT: Item = Item::new("proposal_count"); +// multiple-item map +pub const BALLOTS: Map<(u64, &Addr), Ballot> = Map::new("votes"); +pub const PROPOSALS: Map = Map::new("proposals"); + // multiple-item maps pub const VOTERS: Map<&Addr, u64> = Map::new("voters"); + +pub fn next_id(store: &mut dyn Storage) -> StdResult { + let id: u64 = PROPOSAL_COUNT.may_load(store)?.unwrap_or_default() + 1; + PROPOSAL_COUNT.save(store, &id)?; + Ok(id) +} + +#[cfg(test)] +mod test { + use super::*; + use cosmwasm_std::testing::mock_env; + + #[test] + fn count_votes() { + let mut votes = Votes::yes(5); + votes.add_vote(Vote::No, 10); + votes.add_vote(Vote::Veto, 20); + votes.add_vote(Vote::Yes, 30); + votes.add_vote(Vote::Abstain, 40); + + assert_eq!(votes.total(), 105); + assert_eq!(votes.yes, 35); + assert_eq!(votes.no, 10); + assert_eq!(votes.veto, 20); + assert_eq!(votes.abstain, 40); + } + + #[test] + // we ensure this rounds up (as it calculates needed votes) + fn votes_needed_rounds_properly() { + // round up right below 1 + assert_eq!(1, votes_needed(3, Decimal::permille(333))); + // round up right over 1 + assert_eq!(2, votes_needed(3, Decimal::permille(334))); + assert_eq!(11, votes_needed(30, Decimal::permille(334))); + + // exact matches don't round + assert_eq!(17, votes_needed(34, Decimal::percent(50))); + assert_eq!(12, votes_needed(48, Decimal::percent(25))); + } + + fn check_is_passed( + threshold: Threshold, + votes: Votes, + total_weight: u64, + is_expired: bool, + ) -> bool { + let block = mock_env().block; + let expires = match is_expired { + true => Expiration::AtHeight(block.height - 5), + false => Expiration::AtHeight(block.height + 100), + }; + let prop = Proposal { + title: "Demo".to_string(), + description: "Info".to_string(), + start_height: 100, + expires, + msgs: vec![], + status: Status::Open, + threshold, + total_weight, + votes, + }; + prop.is_passed(&block) + } + + #[test] + fn proposal_passed_absolute_count() { + let fixed = Threshold::AbsoluteCount { weight: 10 }; + let mut votes = Votes::yes(7); + votes.add_vote(Vote::Veto, 4); + // same expired or not, total_weight or whatever + assert!(!check_is_passed(fixed.clone(), votes.clone(), 30, false)); + assert!(!check_is_passed(fixed.clone(), votes.clone(), 30, true)); + // a few more yes votes and we are good + votes.add_vote(Vote::Yes, 3); + assert!(check_is_passed(fixed.clone(), votes.clone(), 30, false)); + assert!(check_is_passed(fixed, votes, 30, true)); + } + + #[test] + fn proposal_passed_absolute_percentage() { + let percent = Threshold::AbsolutePercentage { + percentage: Decimal::percent(50), + }; + let mut votes = Votes::yes(7); + votes.add_vote(Vote::No, 4); + votes.add_vote(Vote::Abstain, 2); + // same expired or not, if yes >= ceiling(0.5 * (total - abstained)) + // 7 of (15-2) passes + assert!(check_is_passed(percent.clone(), votes.clone(), 15, false)); + assert!(check_is_passed(percent.clone(), votes.clone(), 15, true)); + // but 7 of (17-2) fails + assert!(!check_is_passed(percent.clone(), votes.clone(), 17, false)); + + // if the total were a bit lower, this would pass + assert!(check_is_passed(percent.clone(), votes.clone(), 14, false)); + assert!(check_is_passed(percent, votes, 14, true)); + } + + #[test] + fn proposal_passed_quorum() { + let quorum = Threshold::ThresholdQuorum { + threshold: Decimal::percent(50), + quorum: Decimal::percent(40), + }; + // all non-yes votes are counted for quorum + let passing = Votes { + yes: 7, + no: 3, + abstain: 2, + veto: 1, + }; + // abstain votes are not counted for threshold => yes / (yes + no + veto) + let passes_ignoring_abstain = Votes { + yes: 6, + no: 4, + abstain: 5, + veto: 2, + }; + // fails any way you look at it + let failing = Votes { + yes: 6, + no: 5, + abstain: 2, + veto: 2, + }; + + // first, expired (voting period over) + // over quorum (40% of 30 = 12), over threshold (7/11 > 50%) + assert!(check_is_passed(quorum.clone(), passing.clone(), 30, true)); + // under quorum it is not passing (40% of 33 = 13.2 > 13) + assert!(!check_is_passed(quorum.clone(), passing.clone(), 33, true)); + // over quorum, threshold passes if we ignore abstain + // 17 total votes w/ abstain => 40% quorum of 40 total + // 6 yes / (6 yes + 4 no + 2 votes) => 50% threshold + assert!(check_is_passed( + quorum.clone(), + passes_ignoring_abstain.clone(), + 40, + true + )); + // over quorum, but under threshold fails also + assert!(!check_is_passed(quorum.clone(), failing, 20, true)); + + // now, check with open voting period + // would pass if closed, but fail here, as remaining votes no -> fail + assert!(!check_is_passed(quorum.clone(), passing.clone(), 30, false)); + assert!(!check_is_passed( + quorum.clone(), + passes_ignoring_abstain.clone(), + 40, + false + )); + // if we have threshold * total_weight as yes votes this must pass + assert!(check_is_passed(quorum.clone(), passing.clone(), 14, false)); + // all votes have been cast, some abstain + assert!(check_is_passed( + quorum.clone(), + passes_ignoring_abstain, + 17, + false + )); + // 3 votes uncast, if they all vote no, we have 7 yes, 7 no+veto, 2 abstain (out of 16) + assert!(check_is_passed(quorum, passing, 16, false)); + } + + #[test] + fn quorum_edge_cases() { + // when we pass absolute threshold (everyone else voting no, we pass), but still don't hit quorum + let quorum = Threshold::ThresholdQuorum { + threshold: Decimal::percent(60), + quorum: Decimal::percent(80), + }; + + // try 9 yes, 1 no (out of 15) -> 90% voter threshold, 60% absolute threshold, still no quorum + // doesn't matter if expired or not + let missing_voters = Votes { + yes: 9, + no: 1, + abstain: 0, + veto: 0, + }; + assert!(!check_is_passed( + quorum.clone(), + missing_voters.clone(), + 15, + false + )); + assert!(!check_is_passed(quorum.clone(), missing_voters, 15, true)); + + // 1 less yes, 3 vetos and this passes only when expired + let wait_til_expired = Votes { + yes: 8, + no: 1, + abstain: 0, + veto: 3, + }; + assert!(!check_is_passed( + quorum.clone(), + wait_til_expired.clone(), + 15, + false + )); + assert!(check_is_passed(quorum.clone(), wait_til_expired, 15, true)); + + // 9 yes and 3 nos passes early + let passes_early = Votes { + yes: 9, + no: 3, + abstain: 0, + veto: 0, + }; + assert!(check_is_passed( + quorum.clone(), + passes_early.clone(), + 15, + false + )); + assert!(check_is_passed(quorum, passes_early, 15, true)); + } +} diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index d4d8e8608..07e8e689d 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -21,6 +21,7 @@ library = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw3 = { path = "../../packages/cw3", version = "0.10.3" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.10.3" } cw4 = { path = "../../packages/cw4", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } cosmwasm-std = { version = "1.0.0-beta3" } diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index d870652c5..dd8168c40 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -12,13 +12,14 @@ use cw3::{ ProposalListResponse, ProposalResponse, Status, Vote, VoteInfo, VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, }; +use cw3_fixed_multisig::state::{next_id, Ballot, Proposal, Votes, BALLOTS, PROPOSALS}; use cw4::{Cw4Contract, MemberChangedHookMsg, MemberDiff}; use cw_storage_plus::Bound; use utils::{maybe_addr, Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{next_id, Ballot, Config, Proposal, Votes, BALLOTS, CONFIG, PROPOSALS}; +use crate::state::{Config, CONFIG}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw3-flex-multisig"; diff --git a/contracts/cw3-flex-multisig/src/state.rs b/contracts/cw3-flex-multisig/src/state.rs index 59b1518b4..987c57237 100644 --- a/contracts/cw3-flex-multisig/src/state.rs +++ b/contracts/cw3-flex-multisig/src/state.rs @@ -1,16 +1,9 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Decimal, Empty, StdResult, Storage, Uint128}; - -use cw3::{Status, Vote}; use cw4::Cw4Contract; -use cw_storage_plus::{Item, Map}; -use utils::{Duration, Expiration, Threshold}; - -// we multiply by this when calculating needed_votes in order to round up properly -// Note: `10u128.pow(9)` fails as "u128::pow` is not yet stable as a const fn" -const PRECISION_FACTOR: u128 = 1_000_000_000; +use cw_storage_plus::Item; +use utils::{Duration, Threshold}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { @@ -20,355 +13,5 @@ pub struct Config { pub group_addr: Cw4Contract, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct Proposal { - pub title: String, - pub description: String, - pub start_height: u64, - pub expires: Expiration, - pub msgs: Vec>, - pub status: Status, - /// pass requirements - pub threshold: Threshold, - // the total weight when the proposal started (used to calculate percentages) - pub total_weight: u64, - // summary of existing votes - pub votes: Votes, -} - -// weight of votes for each option -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct Votes { - pub yes: u64, - pub no: u64, - pub abstain: u64, - pub veto: u64, -} - -impl Votes { - /// sum of all votes - pub fn total(&self) -> u64 { - self.yes + self.no + self.abstain + self.veto - } - - /// create it with a yes vote for this much - pub fn yes(init_weight: u64) -> Self { - Votes { - yes: init_weight, - no: 0, - abstain: 0, - veto: 0, - } - } - - pub fn add_vote(&mut self, vote: Vote, weight: u64) { - match vote { - Vote::Yes => self.yes += weight, - Vote::Abstain => self.abstain += weight, - Vote::No => self.no += weight, - Vote::Veto => self.veto += weight, - } - } -} - -impl Proposal { - /// current_status is non-mutable and returns what the status should be. - /// (designed for queries) - pub fn current_status(&self, block: &BlockInfo) -> Status { - let mut status = self.status; - - // if open, check if voting is passed or timed out - if status == Status::Open && self.is_passed(block) { - status = Status::Passed; - } - if status == Status::Open && self.expires.is_expired(block) { - status = Status::Rejected; - } - - status - } - - /// update_status sets the status of the proposal to current_status. - /// (designed for handler logic) - pub fn update_status(&mut self, block: &BlockInfo) { - self.status = self.current_status(block); - } - - // returns true iff this proposal is sure to pass (even before expiration if no future - // sequence of possible votes can cause it to fail) - pub fn is_passed(&self, block: &BlockInfo) -> bool { - match self.threshold { - Threshold::AbsoluteCount { - weight: weight_needed, - } => self.votes.yes >= weight_needed, - Threshold::AbsolutePercentage { - percentage: percentage_needed, - } => { - self.votes.yes - >= votes_needed(self.total_weight - self.votes.abstain, percentage_needed) - } - Threshold::ThresholdQuorum { threshold, quorum } => { - // we always require the quorum - if self.votes.total() < votes_needed(self.total_weight, quorum) { - return false; - } - if self.expires.is_expired(block) { - // If expired, we compare Yes votes against the total number of votes (minus abstain). - let opinions = self.votes.total() - self.votes.abstain; - self.votes.yes >= votes_needed(opinions, threshold) - } else { - // If not expired, we must assume all non-votes will be cast as No. - // We compare threshold against the total weight (minus abstain). - let possible_opinions = self.total_weight - self.votes.abstain; - self.votes.yes >= votes_needed(possible_opinions, threshold) - } - } - } - } -} - -// this is a helper function so Decimal works with u64 rather than Uint128 -// also, we must *round up* here, as we need 8, not 7 votes to reach 50% of 15 total -fn votes_needed(weight: u64, percentage: Decimal) -> u64 { - let applied = percentage * Uint128::new(PRECISION_FACTOR * weight as u128); - // Divide by PRECISION_FACTOR, rounding up to the nearest integer - ((applied.u128() + PRECISION_FACTOR - 1) / PRECISION_FACTOR) as u64 -} - -// we cast a ballot with our chosen vote and a given weight -// stored under the key that voted -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct Ballot { - pub weight: u64, - pub vote: Vote, -} - // unique items pub const CONFIG: Item = Item::new("config"); -pub const PROPOSAL_COUNT: Item = Item::new("proposal_count"); - -// multiple-item map -pub const BALLOTS: Map<(u64, &Addr), Ballot> = Map::new("votes"); -pub const PROPOSALS: Map = Map::new("proposals"); - -pub fn next_id(store: &mut dyn Storage) -> StdResult { - let id: u64 = PROPOSAL_COUNT.may_load(store)?.unwrap_or_default() + 1; - PROPOSAL_COUNT.save(store, &id)?; - Ok(id) -} - -#[cfg(test)] -mod test { - use super::*; - use cosmwasm_std::testing::mock_env; - - #[test] - fn count_votes() { - let mut votes = Votes::yes(5); - votes.add_vote(Vote::No, 10); - votes.add_vote(Vote::Veto, 20); - votes.add_vote(Vote::Yes, 30); - votes.add_vote(Vote::Abstain, 40); - - assert_eq!(votes.total(), 105); - assert_eq!(votes.yes, 35); - assert_eq!(votes.no, 10); - assert_eq!(votes.veto, 20); - assert_eq!(votes.abstain, 40); - } - - #[test] - // we ensure this rounds up (as it calculates needed votes) - fn votes_needed_rounds_properly() { - // round up right below 1 - assert_eq!(1, votes_needed(3, Decimal::permille(333))); - // round up right over 1 - assert_eq!(2, votes_needed(3, Decimal::permille(334))); - assert_eq!(11, votes_needed(30, Decimal::permille(334))); - - // exact matches don't round - assert_eq!(17, votes_needed(34, Decimal::percent(50))); - assert_eq!(12, votes_needed(48, Decimal::percent(25))); - } - - fn check_is_passed( - threshold: Threshold, - votes: Votes, - total_weight: u64, - is_expired: bool, - ) -> bool { - let block = mock_env().block; - let expires = match is_expired { - true => Expiration::AtHeight(block.height - 5), - false => Expiration::AtHeight(block.height + 100), - }; - let prop = Proposal { - title: "Demo".to_string(), - description: "Info".to_string(), - start_height: 100, - expires, - msgs: vec![], - status: Status::Open, - threshold, - total_weight, - votes, - }; - prop.is_passed(&block) - } - - #[test] - fn proposal_passed_absolute_count() { - let fixed = Threshold::AbsoluteCount { weight: 10 }; - let mut votes = Votes::yes(7); - votes.add_vote(Vote::Veto, 4); - // same expired or not, total_weight or whatever - assert!(!check_is_passed(fixed.clone(), votes.clone(), 30, false)); - assert!(!check_is_passed(fixed.clone(), votes.clone(), 30, true)); - // a few more yes votes and we are good - votes.add_vote(Vote::Yes, 3); - assert!(check_is_passed(fixed.clone(), votes.clone(), 30, false)); - assert!(check_is_passed(fixed, votes, 30, true)); - } - - #[test] - fn proposal_passed_absolute_percentage() { - let percent = Threshold::AbsolutePercentage { - percentage: Decimal::percent(50), - }; - let mut votes = Votes::yes(7); - votes.add_vote(Vote::No, 4); - votes.add_vote(Vote::Abstain, 2); - // same expired or not, if yes >= ceiling(0.5 * (total - abstained)) - // 7 of (15-2) passes - assert!(check_is_passed(percent.clone(), votes.clone(), 15, false)); - assert!(check_is_passed(percent.clone(), votes.clone(), 15, true)); - // but 7 of (17-2) fails - assert!(!check_is_passed(percent.clone(), votes.clone(), 17, false)); - - // if the total were a bit lower, this would pass - assert!(check_is_passed(percent.clone(), votes.clone(), 14, false)); - assert!(check_is_passed(percent, votes, 14, true)); - } - - #[test] - fn proposal_passed_quorum() { - let quorum = Threshold::ThresholdQuorum { - threshold: Decimal::percent(50), - quorum: Decimal::percent(40), - }; - // all non-yes votes are counted for quorum - let passing = Votes { - yes: 7, - no: 3, - abstain: 2, - veto: 1, - }; - // abstain votes are not counted for threshold => yes / (yes + no + veto) - let passes_ignoring_abstain = Votes { - yes: 6, - no: 4, - abstain: 5, - veto: 2, - }; - // fails any way you look at it - let failing = Votes { - yes: 6, - no: 5, - abstain: 2, - veto: 2, - }; - - // first, expired (voting period over) - // over quorum (40% of 30 = 12), over threshold (7/11 > 50%) - assert!(check_is_passed(quorum.clone(), passing.clone(), 30, true)); - // under quorum it is not passing (40% of 33 = 13.2 > 13) - assert!(!check_is_passed(quorum.clone(), passing.clone(), 33, true)); - // over quorum, threshold passes if we ignore abstain - // 17 total votes w/ abstain => 40% quorum of 40 total - // 6 yes / (6 yes + 4 no + 2 votes) => 50% threshold - assert!(check_is_passed( - quorum.clone(), - passes_ignoring_abstain.clone(), - 40, - true - )); - // over quorum, but under threshold fails also - assert!(!check_is_passed(quorum.clone(), failing, 20, true)); - - // now, check with open voting period - // would pass if closed, but fail here, as remaining votes no -> fail - assert!(!check_is_passed(quorum.clone(), passing.clone(), 30, false)); - assert!(!check_is_passed( - quorum.clone(), - passes_ignoring_abstain.clone(), - 40, - false - )); - // if we have threshold * total_weight as yes votes this must pass - assert!(check_is_passed(quorum.clone(), passing.clone(), 14, false)); - // all votes have been cast, some abstain - assert!(check_is_passed( - quorum.clone(), - passes_ignoring_abstain, - 17, - false - )); - // 3 votes uncast, if they all vote no, we have 7 yes, 7 no+veto, 2 abstain (out of 16) - assert!(check_is_passed(quorum, passing, 16, false)); - } - - #[test] - fn quorum_edge_cases() { - // when we pass absolute threshold (everyone else voting no, we pass), but still don't hit quorum - let quorum = Threshold::ThresholdQuorum { - threshold: Decimal::percent(60), - quorum: Decimal::percent(80), - }; - - // try 9 yes, 1 no (out of 15) -> 90% voter threshold, 60% absolute threshold, still no quorum - // doesn't matter if expired or not - let missing_voters = Votes { - yes: 9, - no: 1, - abstain: 0, - veto: 0, - }; - assert!(!check_is_passed( - quorum.clone(), - missing_voters.clone(), - 15, - false - )); - assert!(!check_is_passed(quorum.clone(), missing_voters, 15, true)); - - // 1 less yes, 3 vetos and this passes only when expired - let wait_til_expired = Votes { - yes: 8, - no: 1, - abstain: 0, - veto: 3, - }; - assert!(!check_is_passed( - quorum.clone(), - wait_til_expired.clone(), - 15, - false - )); - assert!(check_is_passed(quorum.clone(), wait_til_expired, 15, true)); - - // 9 yes and 3 nos passes early - let passes_early = Votes { - yes: 9, - no: 3, - abstain: 0, - veto: 0, - }; - assert!(check_is_passed( - quorum.clone(), - passes_early.clone(), - 15, - false - )); - assert!(check_is_passed(quorum, passes_early, 15, true)); - } -} From bf72c5496f93b0078eb7e0a608ffd705a613af74 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 22 Dec 2021 13:49:06 +0100 Subject: [PATCH 089/352] cw3-flex-multisig: Bring back common Ballot, Proposal etc. implementations --- Cargo.lock | 1 - contracts/cw3-flex-multisig/Cargo.toml | 1 - contracts/cw3-flex-multisig/src/contract.rs | 3 +- contracts/cw3-flex-multisig/src/state.rs | 145 +++++++++++++++++++- 4 files changed, 144 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76114ddc1..43fed7b8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -546,7 +546,6 @@ dependencies = [ "cw-storage-plus", "cw2", "cw3", - "cw3-fixed-multisig", "cw4", "cw4-group", "schemars", diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 07e8e689d..d4d8e8608 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -21,7 +21,6 @@ library = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw3 = { path = "../../packages/cw3", version = "0.10.3" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.10.3" } cw4 = { path = "../../packages/cw4", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } cosmwasm-std = { version = "1.0.0-beta3" } diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index dd8168c40..d870652c5 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -12,14 +12,13 @@ use cw3::{ ProposalListResponse, ProposalResponse, Status, Vote, VoteInfo, VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, }; -use cw3_fixed_multisig::state::{next_id, Ballot, Proposal, Votes, BALLOTS, PROPOSALS}; use cw4::{Cw4Contract, MemberChangedHookMsg, MemberDiff}; use cw_storage_plus::Bound; use utils::{maybe_addr, Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{Config, CONFIG}; +use crate::state::{next_id, Ballot, Config, Proposal, Votes, BALLOTS, CONFIG, PROPOSALS}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw3-flex-multisig"; diff --git a/contracts/cw3-flex-multisig/src/state.rs b/contracts/cw3-flex-multisig/src/state.rs index 987c57237..67ce09658 100644 --- a/contracts/cw3-flex-multisig/src/state.rs +++ b/contracts/cw3-flex-multisig/src/state.rs @@ -1,9 +1,16 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Decimal, Empty, StdResult, Storage, Uint128}; + +use cw3::{Status, Vote}; use cw4::Cw4Contract; -use cw_storage_plus::Item; -use utils::{Duration, Threshold}; +use cw_storage_plus::{Item, Map}; +use utils::{Duration, Expiration, Threshold}; + +// we multiply by this when calculating needed_votes in order to round up properly +// Note: `10u128.pow(9)` fails as "u128::pow` is not yet stable as a const fn" +const PRECISION_FACTOR: u128 = 1_000_000_000; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { @@ -13,5 +20,139 @@ pub struct Config { pub group_addr: Cw4Contract, } +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct Proposal { + pub title: String, + pub description: String, + pub start_height: u64, + pub expires: Expiration, + pub msgs: Vec>, + pub status: Status, + /// pass requirements + pub threshold: Threshold, + // the total weight when the proposal started (used to calculate percentages) + pub total_weight: u64, + // summary of existing votes + pub votes: Votes, +} + +// weight of votes for each option +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct Votes { + pub yes: u64, + pub no: u64, + pub abstain: u64, + pub veto: u64, +} + +impl Votes { + /// sum of all votes + pub fn total(&self) -> u64 { + self.yes + self.no + self.abstain + self.veto + } + + /// create it with a yes vote for this much + pub fn yes(init_weight: u64) -> Self { + Votes { + yes: init_weight, + no: 0, + abstain: 0, + veto: 0, + } + } + + pub fn add_vote(&mut self, vote: Vote, weight: u64) { + match vote { + Vote::Yes => self.yes += weight, + Vote::Abstain => self.abstain += weight, + Vote::No => self.no += weight, + Vote::Veto => self.veto += weight, + } + } +} + +impl Proposal { + /// current_status is non-mutable and returns what the status should be. + /// (designed for queries) + pub fn current_status(&self, block: &BlockInfo) -> Status { + let mut status = self.status; + + // if open, check if voting is passed or timed out + if status == Status::Open && self.is_passed(block) { + status = Status::Passed; + } + if status == Status::Open && self.expires.is_expired(block) { + status = Status::Rejected; + } + + status + } + + /// update_status sets the status of the proposal to current_status. + /// (designed for handler logic) + pub fn update_status(&mut self, block: &BlockInfo) { + self.status = self.current_status(block); + } + + // returns true iff this proposal is sure to pass (even before expiration if no future + // sequence of possible votes can cause it to fail) + pub fn is_passed(&self, block: &BlockInfo) -> bool { + match self.threshold { + Threshold::AbsoluteCount { + weight: weight_needed, + } => self.votes.yes >= weight_needed, + Threshold::AbsolutePercentage { + percentage: percentage_needed, + } => { + self.votes.yes + >= votes_needed(self.total_weight - self.votes.abstain, percentage_needed) + } + Threshold::ThresholdQuorum { threshold, quorum } => { + // we always require the quorum + if self.votes.total() < votes_needed(self.total_weight, quorum) { + return false; + } + if self.expires.is_expired(block) { + // If expired, we compare Yes votes against the total number of votes (minus abstain). + let opinions = self.votes.total() - self.votes.abstain; + self.votes.yes >= votes_needed(opinions, threshold) + } else { + // If not expired, we must assume all non-votes will be cast as No. + // We compare threshold against the total weight (minus abstain). + let possible_opinions = self.total_weight - self.votes.abstain; + self.votes.yes >= votes_needed(possible_opinions, threshold) + } + } + } + } +} + +// this is a helper function so Decimal works with u64 rather than Uint128 +// also, we must *round up* here, as we need 8, not 7 votes to reach 50% of 15 total +fn votes_needed(weight: u64, percentage: Decimal) -> u64 { + let applied = percentage * Uint128::new(PRECISION_FACTOR * weight as u128); + // Divide by PRECISION_FACTOR, rounding up to the nearest integer + ((applied.u128() + PRECISION_FACTOR - 1) / PRECISION_FACTOR) as u64 +} + +// we cast a ballot with our chosen vote and a given weight +// stored under the key that voted +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct Ballot { + pub weight: u64, + pub vote: Vote, +} + // unique items pub const CONFIG: Item = Item::new("config"); +pub const PROPOSAL_COUNT: Item = Item::new("proposal_count"); + +// multiple-item map +pub const BALLOTS: Map<(u64, &Addr), Ballot> = Map::new("votes"); +pub const PROPOSALS: Map = Map::new("proposals"); + +pub fn next_id(store: &mut dyn Storage) -> StdResult { + let id: u64 = PROPOSAL_COUNT.may_load(store)?.unwrap_or_default() + 1; + PROPOSAL_COUNT.save(store, &id)?; + Ok(id) +} From b5ead3dd5c07a274e1d0211bc8314fb57777de09 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 22 Dec 2021 15:18:18 +0100 Subject: [PATCH 090/352] Revert "cw3-flex-multisig: Bring back common Ballot, Proposal etc. implementations" This reverts commit bf72c5496f93b0078eb7e0a608ffd705a613af74. --- Cargo.lock | 1 + contracts/cw3-flex-multisig/Cargo.toml | 1 + contracts/cw3-flex-multisig/src/contract.rs | 3 +- contracts/cw3-flex-multisig/src/state.rs | 145 +------------------- 4 files changed, 6 insertions(+), 144 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43fed7b8b..76114ddc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -546,6 +546,7 @@ dependencies = [ "cw-storage-plus", "cw2", "cw3", + "cw3-fixed-multisig", "cw4", "cw4-group", "schemars", diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index d4d8e8608..07e8e689d 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -21,6 +21,7 @@ library = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw3 = { path = "../../packages/cw3", version = "0.10.3" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.10.3" } cw4 = { path = "../../packages/cw4", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } cosmwasm-std = { version = "1.0.0-beta3" } diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index d870652c5..dd8168c40 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -12,13 +12,14 @@ use cw3::{ ProposalListResponse, ProposalResponse, Status, Vote, VoteInfo, VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, }; +use cw3_fixed_multisig::state::{next_id, Ballot, Proposal, Votes, BALLOTS, PROPOSALS}; use cw4::{Cw4Contract, MemberChangedHookMsg, MemberDiff}; use cw_storage_plus::Bound; use utils::{maybe_addr, Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{next_id, Ballot, Config, Proposal, Votes, BALLOTS, CONFIG, PROPOSALS}; +use crate::state::{Config, CONFIG}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw3-flex-multisig"; diff --git a/contracts/cw3-flex-multisig/src/state.rs b/contracts/cw3-flex-multisig/src/state.rs index 67ce09658..987c57237 100644 --- a/contracts/cw3-flex-multisig/src/state.rs +++ b/contracts/cw3-flex-multisig/src/state.rs @@ -1,16 +1,9 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Decimal, Empty, StdResult, Storage, Uint128}; - -use cw3::{Status, Vote}; use cw4::Cw4Contract; -use cw_storage_plus::{Item, Map}; -use utils::{Duration, Expiration, Threshold}; - -// we multiply by this when calculating needed_votes in order to round up properly -// Note: `10u128.pow(9)` fails as "u128::pow` is not yet stable as a const fn" -const PRECISION_FACTOR: u128 = 1_000_000_000; +use cw_storage_plus::Item; +use utils::{Duration, Threshold}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { @@ -20,139 +13,5 @@ pub struct Config { pub group_addr: Cw4Contract, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct Proposal { - pub title: String, - pub description: String, - pub start_height: u64, - pub expires: Expiration, - pub msgs: Vec>, - pub status: Status, - /// pass requirements - pub threshold: Threshold, - // the total weight when the proposal started (used to calculate percentages) - pub total_weight: u64, - // summary of existing votes - pub votes: Votes, -} - -// weight of votes for each option -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct Votes { - pub yes: u64, - pub no: u64, - pub abstain: u64, - pub veto: u64, -} - -impl Votes { - /// sum of all votes - pub fn total(&self) -> u64 { - self.yes + self.no + self.abstain + self.veto - } - - /// create it with a yes vote for this much - pub fn yes(init_weight: u64) -> Self { - Votes { - yes: init_weight, - no: 0, - abstain: 0, - veto: 0, - } - } - - pub fn add_vote(&mut self, vote: Vote, weight: u64) { - match vote { - Vote::Yes => self.yes += weight, - Vote::Abstain => self.abstain += weight, - Vote::No => self.no += weight, - Vote::Veto => self.veto += weight, - } - } -} - -impl Proposal { - /// current_status is non-mutable and returns what the status should be. - /// (designed for queries) - pub fn current_status(&self, block: &BlockInfo) -> Status { - let mut status = self.status; - - // if open, check if voting is passed or timed out - if status == Status::Open && self.is_passed(block) { - status = Status::Passed; - } - if status == Status::Open && self.expires.is_expired(block) { - status = Status::Rejected; - } - - status - } - - /// update_status sets the status of the proposal to current_status. - /// (designed for handler logic) - pub fn update_status(&mut self, block: &BlockInfo) { - self.status = self.current_status(block); - } - - // returns true iff this proposal is sure to pass (even before expiration if no future - // sequence of possible votes can cause it to fail) - pub fn is_passed(&self, block: &BlockInfo) -> bool { - match self.threshold { - Threshold::AbsoluteCount { - weight: weight_needed, - } => self.votes.yes >= weight_needed, - Threshold::AbsolutePercentage { - percentage: percentage_needed, - } => { - self.votes.yes - >= votes_needed(self.total_weight - self.votes.abstain, percentage_needed) - } - Threshold::ThresholdQuorum { threshold, quorum } => { - // we always require the quorum - if self.votes.total() < votes_needed(self.total_weight, quorum) { - return false; - } - if self.expires.is_expired(block) { - // If expired, we compare Yes votes against the total number of votes (minus abstain). - let opinions = self.votes.total() - self.votes.abstain; - self.votes.yes >= votes_needed(opinions, threshold) - } else { - // If not expired, we must assume all non-votes will be cast as No. - // We compare threshold against the total weight (minus abstain). - let possible_opinions = self.total_weight - self.votes.abstain; - self.votes.yes >= votes_needed(possible_opinions, threshold) - } - } - } - } -} - -// this is a helper function so Decimal works with u64 rather than Uint128 -// also, we must *round up* here, as we need 8, not 7 votes to reach 50% of 15 total -fn votes_needed(weight: u64, percentage: Decimal) -> u64 { - let applied = percentage * Uint128::new(PRECISION_FACTOR * weight as u128); - // Divide by PRECISION_FACTOR, rounding up to the nearest integer - ((applied.u128() + PRECISION_FACTOR - 1) / PRECISION_FACTOR) as u64 -} - -// we cast a ballot with our chosen vote and a given weight -// stored under the key that voted -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct Ballot { - pub weight: u64, - pub vote: Vote, -} - // unique items pub const CONFIG: Item = Item::new("config"); -pub const PROPOSAL_COUNT: Item = Item::new("proposal_count"); - -// multiple-item map -pub const BALLOTS: Map<(u64, &Addr), Ballot> = Map::new("votes"); -pub const PROPOSALS: Map = Map::new("proposals"); - -pub fn next_id(store: &mut dyn Storage) -> StdResult { - let id: u64 = PROPOSAL_COUNT.may_load(store)?.unwrap_or_default() + 1; - PROPOSAL_COUNT.save(store, &id)?; - Ok(id) -} From 0c72eb1e455b96d5c8eff30bd0e17c3d022123cf Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 22 Dec 2021 15:18:51 +0100 Subject: [PATCH 091/352] Use feature library to avoid duplicated symbols --- contracts/cw3-flex-multisig/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 07e8e689d..cc9f70b8d 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -21,7 +21,7 @@ library = [] utils = { path = "../../packages/utils", version = "0.10.3" } cw2 = { path = "../../packages/cw2", version = "0.10.3" } cw3 = { path = "../../packages/cw3", version = "0.10.3" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.10.3" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.10.3", features = ["library"] } cw4 = { path = "../../packages/cw4", version = "0.10.3" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } cosmwasm-std = { version = "1.0.0-beta3" } From 718e5c73241b8529791aa6ef22453760a45aa0e9 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 22 Dec 2021 13:59:32 +0100 Subject: [PATCH 092/352] Set version: 0.11.0 --- Cargo.lock | 48 ++++++++++++------------ contracts/cw1-subkeys/Cargo.toml | 14 +++---- contracts/cw1-whitelist-ng/Cargo.toml | 14 +++---- contracts/cw1-whitelist/Cargo.toml | 12 +++--- contracts/cw1155-base/Cargo.toml | 10 ++--- contracts/cw20-atomic-swap/Cargo.toml | 10 ++--- contracts/cw20-base/Cargo.toml | 10 ++--- contracts/cw20-bonding/Cargo.toml | 12 +++--- contracts/cw20-escrow/Cargo.toml | 14 +++---- contracts/cw20-ics20/Cargo.toml | 10 ++--- contracts/cw20-merkle-airdrop/Cargo.toml | 8 ++-- contracts/cw20-staking/Cargo.toml | 14 +++---- contracts/cw3-fixed-multisig/Cargo.toml | 16 ++++---- contracts/cw3-flex-multisig/Cargo.toml | 17 ++++----- contracts/cw4-group/Cargo.toml | 12 +++--- contracts/cw4-stake/Cargo.toml | 14 +++---- packages/controllers/Cargo.toml | 6 +-- packages/cw1/Cargo.toml | 2 +- packages/cw1155/Cargo.toml | 4 +- packages/cw2/Cargo.toml | 4 +- packages/cw20/Cargo.toml | 4 +- packages/cw3/Cargo.toml | 4 +- packages/cw4/Cargo.toml | 4 +- packages/multi-test/Cargo.toml | 6 +-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 4 +- 26 files changed, 137 insertions(+), 138 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76114ddc1..4e2824967 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -241,7 +241,7 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -253,7 +253,7 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.10.3" +version = "0.11.0" dependencies = [ "anyhow", "cosmwasm-std", @@ -270,7 +270,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-std", "schemars", @@ -279,7 +279,7 @@ dependencies = [ [[package]] name = "cw1" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -289,7 +289,7 @@ dependencies = [ [[package]] name = "cw1-subkeys" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -306,7 +306,7 @@ dependencies = [ [[package]] name = "cw1-whitelist" -version = "0.10.3" +version = "0.11.0" dependencies = [ "anyhow", "assert_matches", @@ -325,7 +325,7 @@ dependencies = [ [[package]] name = "cw1-whitelist-ng" -version = "0.10.3" +version = "0.11.0" dependencies = [ "anyhow", "assert_matches", @@ -344,7 +344,7 @@ dependencies = [ [[package]] name = "cw1155" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -355,7 +355,7 @@ dependencies = [ [[package]] name = "cw1155-base" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -370,7 +370,7 @@ dependencies = [ [[package]] name = "cw2" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -380,7 +380,7 @@ dependencies = [ [[package]] name = "cw20" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -391,7 +391,7 @@ dependencies = [ [[package]] name = "cw20-atomic-swap" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -408,7 +408,7 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -423,7 +423,7 @@ dependencies = [ [[package]] name = "cw20-bonding" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -442,7 +442,7 @@ dependencies = [ [[package]] name = "cw20-escrow" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -459,7 +459,7 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -492,7 +492,7 @@ dependencies = [ [[package]] name = "cw20-staking" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -509,7 +509,7 @@ dependencies = [ [[package]] name = "cw3" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -520,7 +520,7 @@ dependencies = [ [[package]] name = "cw3-fixed-multisig" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -538,7 +538,7 @@ dependencies = [ [[package]] name = "cw3-flex-multisig" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -557,7 +557,7 @@ dependencies = [ [[package]] name = "cw4" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -568,7 +568,7 @@ dependencies = [ [[package]] name = "cw4-group" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -584,7 +584,7 @@ dependencies = [ [[package]] name = "cw4-stake" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -1170,7 +1170,7 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "utils" -version = "0.10.3" +version = "0.11.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index acdc2d8db..3bfa738ef 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-subkeys" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Implement subkeys for authorizing native tokens as a cw1 proxy contract" @@ -19,12 +19,12 @@ library = [] test-utils = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw1 = { path = "../../packages/cw1", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.10.3", features = ["library"] } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw1 = { path = "../../packages/cw1", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.11.0", features = ["library"] } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.23" @@ -32,4 +32,4 @@ semver = "1" [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.10.3", features = ["library", "test-utils"] } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.11.0", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index e439b6264..31d3ed5aa 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist-ng" -version = "0.10.3" +version = "0.11.0" authors = ["Bartłomiej Kuras "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -22,20 +22,20 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw1 = { path = "../../packages/cw1", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw1 = { path = "../../packages/cw1", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3", optional = true } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0", optional = true } anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index 22d7a9218..9ae2ddf08 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw1 = { path = "../../packages/cw1", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw1 = { path = "../../packages/cw1", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -32,5 +32,5 @@ thiserror = { version = "1.0.23" } anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 0e9859c4d..35cd30461 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155-base" -version = "0.10.3" +version = "0.11.0" authors = ["Huang Yi "] edition = "2018" description = "Basic implementation of a CosmWasm-1155 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw1155 = { path = "../../packages/cw1155", version = "0.10.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw1155 = { path = "../../packages/cw1155", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-atomic-swap/Cargo.toml b/contracts/cw20-atomic-swap/Cargo.toml index 7da558616..fd724cec8 100644 --- a/contracts/cw20-atomic-swap/Cargo.toml +++ b/contracts/cw20-atomic-swap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-atomic-swap" -version = "0.10.3" +version = "0.11.0" authors = ["Mauro Lacy "] edition = "2018" description = "Implementation of Atomic Swaps" @@ -15,11 +15,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw20 = { path = "../../packages/cw20", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw20 = { path = "../../packages/cw20", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index dbd87339a..40961b4ff 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-base" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation of a CosmWasm-20 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw20 = { path = "../../packages/cw20", version = "0.10.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw20 = { path = "../../packages/cw20", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-bonding/Cargo.toml b/contracts/cw20-bonding/Cargo.toml index 4479a7f67..e48160be3 100644 --- a/contracts/cw20-bonding/Cargo.toml +++ b/contracts/cw20-bonding/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-bonding" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Implement basic bonding curve to issue cw20 tokens" @@ -20,11 +20,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw20 = { path = "../../packages/cw20", version = "0.10.3" } -cw20-base = { path = "../../contracts/cw20-base", version = "0.10.3", features = ["library"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw20 = { path = "../../packages/cw20", version = "0.11.0" } +cw20-base = { path = "../../contracts/cw20-base", version = "0.11.0", features = ["library"] } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3", default-features = false, features = ["staking"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-escrow/Cargo.toml b/contracts/cw20-escrow/Cargo.toml index 9727002a8..2914a0b0f 100644 --- a/contracts/cw20-escrow/Cargo.toml +++ b/contracts/cw20-escrow/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-escrow" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an escrow that accepts CosmWasm-20 tokens as well as native tokens" @@ -18,16 +18,16 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw20 = { path = "../../packages/cw20", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw20 = { path = "../../packages/cw20", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3" } -cw20-base = { path = "../cw20-base", version = "0.10.3", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0" } +cw20-base = { path = "../cw20-base", version = "0.11.0", features = ["library"] } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 53443d2a7..6cc4050a8 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain" @@ -18,11 +18,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw20 = { path = "../../packages/cw20", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw20 = { path = "../../packages/cw20", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3", features = ["stargate"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw20-merkle-airdrop/Cargo.toml b/contracts/cw20-merkle-airdrop/Cargo.toml index f9ef8cc9c..8db60cd38 100644 --- a/contracts/cw20-merkle-airdrop/Cargo.toml +++ b/contracts/cw20-merkle-airdrop/Cargo.toml @@ -19,11 +19,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw20 = { path = "../../packages/cw20", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw20 = { path = "../../packages/cw20", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw20-staking/Cargo.toml b/contracts/cw20-staking/Cargo.toml index e3effd870..42c10175b 100644 --- a/contracts/cw20-staking/Cargo.toml +++ b/contracts/cw20-staking/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-staking" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Implement simple staking derivatives as a cw20 token" @@ -20,13 +20,13 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw20 = { path = "../../packages/cw20", version = "0.10.3" } -cw-controllers = { path = "../../packages/controllers", version = "0.10.3" } -cw20-base = { path = "../../contracts/cw20-base", version = "0.10.3", features = ["library"] } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw20 = { path = "../../packages/cw20", version = "0.11.0" } +cw-controllers = { path = "../../packages/controllers", version = "0.11.0" } +cw20-base = { path = "../../contracts/cw20-base", version = "0.11.0", features = ["library"] } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index edab67af4..c2a5cf04e 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-fixed-multisig" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with an fixed group multisig" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw3 = { path = "../../packages/cw3", version = "0.10.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw3 = { path = "../../packages/cw3", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -29,6 +29,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw20 = { path = "../../packages/cw20", version = "0.10.3" } -cw20-base = { path = "../cw20-base", version = "0.10.3", features = ["library"] } -cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3" } +cw20 = { path = "../../packages/cw20", version = "0.11.0" } +cw20-base = { path = "../cw20-base", version = "0.11.0", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index cc9f70b8d..be01f7a0f 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-flex-multisig" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with multiple voting patterns and dynamic groups" @@ -18,12 +18,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw3 = { path = "../../packages/cw3", version = "0.10.3" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.10.3", features = ["library"] } -cw4 = { path = "../../packages/cw4", version = "0.10.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw3 = { path = "../../packages/cw3", version = "0.11.0" } +cw4 = { path = "../../packages/cw4", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +30,5 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw4-group = { path = "../cw4-group", version = "0.10.3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.10.3" } +cw4-group = { path = "../cw4-group", version = "0.11.0" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index a4dc89f4b..cf599b1f6 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-group" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Simple cw4 implementation of group membership controlled by admin " @@ -26,11 +26,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw4 = { path = "../../packages/cw4", version = "0.10.3" } -cw-controllers = { path = "../../packages/controllers", version = "0.10.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw4 = { path = "../../packages/cw4", version = "0.11.0" } +cw-controllers = { path = "../../packages/controllers", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index c07504e07..041677d03 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-stake" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "CW4 implementation of group based on staked tokens" @@ -26,12 +26,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw2 = { path = "../../packages/cw2", version = "0.10.3" } -cw4 = { path = "../../packages/cw4", version = "0.10.3" } -cw20 = { path = "../../packages/cw20", version = "0.10.3" } -cw-controllers = { path = "../../packages/controllers", version = "0.10.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } +cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw4 = { path = "../../packages/cw4", version = "0.11.0" } +cw20 = { path = "../../packages/cw20", version = "0.11.0" } +cw-controllers = { path = "../../packages/controllers", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index 5d99266c3..783163a6e 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-controllers" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Common controllers we can reuse in many contracts" @@ -13,8 +13,8 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta3" } -utils = { path = "../utils", version = "0.10.3" } -cw-storage-plus = { path = "../storage-plus", version = "0.10.3" } +utils = { path = "../utils", version = "0.11.0" } +cw-storage-plus = { path = "../storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index 75b2bcdbf..01cdea229 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-1 interface" diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 808ab5625..9048f5217 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155" -version = "0.10.3" +version = "0.11.0" authors = ["Huang Yi "] edition = "2018" description = "Definition and types for the CosmWasm-1155 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index fc492461b..3d3e6bb71 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw2" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-2 interface" @@ -11,6 +11,6 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta3", default-features = false } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index fd47608e4..1ba7559ff 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-20 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index 1e483eac8..1031b591a 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-3 Interface: On-Chain MultiSig/Voting contracts" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } +utils = { path = "../../packages/utils", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index cd531b9da..bd428f71a 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-4 Interface: Groups Members" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-storage-plus = { path = "../storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../storage-plus", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index e2f7c0dfe..bf6c909ae 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-multi-test" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Test helpers for multi-contract interactions" @@ -18,8 +18,8 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -utils = { path = "../../packages/utils", version = "0.10.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3"} +utils = { path = "../../packages/utils", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0"} cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } cosmwasm-storage = { version = "1.0.0-beta3" } itertools = "0.10.1" diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 9635d6a49..30f622807 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-storage-plus" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Enhanced/experimental storage engines" diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index f0a2ecd3d..c85f70302 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "utils" -version = "0.10.3" +version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" description = "Common helpers for other cw specs" @@ -18,5 +18,5 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } [dev-dependencies] -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } prost = "0.9" From b1c393a95e92270ad99525da0572a0de08533344 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 22 Dec 2021 15:46:06 +0100 Subject: [PATCH 093/352] Update CHANGELOG.md --- CHANGELOG.md | 63 +++++++++++++++++++++++++- contracts/cw3-flex-multisig/Cargo.toml | 1 + 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74efa90ad..74f04f2e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,68 @@ ## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.10.3...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.11.0...HEAD) + +## [v0.11.0](https://github.com/CosmWasm/cw-plus/tree/v0.11.0) (2021-11-22) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.10.3...v0.11.0) + +**Breaking changes:** + +- Remove the primary key from the `MultiIndex` key specification [\#533](https://github.com/CosmWasm/cw-plus/issues/533) +- `UniqueIndex` / `MultiIndex` key consistency [\#532](https://github.com/CosmWasm/cw-plus/issues/532) +- Incorrect I32Key Index Ordering [\#489](https://github.com/CosmWasm/cw-plus/issues/489) +- Deprecate `range` to `range_raw` [\#460](https://github.com/CosmWasm/cw-plus/issues/460) + +**Implemented enhancements:** + +- Add `MIGRATING.md` [\#583](https://github.com/CosmWasm/cw-plus/issues/583) +- Remove schemas, and publish them with artifacts on release tags [\#529](https://github.com/CosmWasm/cw-plus/issues/529) + +**Closed issues:** + +- Check \(and possibly fix\) threshold and voting power implementation in `cw3-fixed-multisig` [\#551](https://github.com/CosmWasm/cw-plus/issues/551) +- Update to cosmwasm 1.0.0-beta3 [\#579](https://github.com/CosmWasm/cw-plus/issues/579) +- Cannot import non "library" features in dev-dependencies [\#577](https://github.com/CosmWasm/cw-plus/issues/577) +- `base-helpers.ts` doesn't belong to `contracts` [\#566](https://github.com/CosmWasm/cw-plus/issues/566) +- handle function [\#563](https://github.com/CosmWasm/cw-plus/issues/563) +- Migrate from `IntKey` to new naked int key [\#549](https://github.com/CosmWasm/cw-plus/issues/549) +- Refactor `UniqueIndex` and `MultiIndex` into their own files [\#530](https://github.com/CosmWasm/cw-plus/issues/530) +- Iterate over historical data in SnapshotMap [\#487](https://github.com/CosmWasm/cw-plus/issues/487) +- Rename cw0 to utils [\#471](https://github.com/CosmWasm/cw-plus/issues/471) +- Various `range_de` / `prefix_de` improvements [\#464](https://github.com/CosmWasm/cw-plus/issues/464) +- Add `range_de` to `Map`-like structs [\#461](https://github.com/CosmWasm/cw-plus/issues/461) +- Add url as input when mint cw1155 [\#449](https://github.com/CosmWasm/cw-plus/issues/449) +- Allow cw20 token as reserve token for bonding curve [\#191](https://github.com/CosmWasm/cw-plus/issues/191) +- Benchmark bonding curve functionality [\#190](https://github.com/CosmWasm/cw-plus/issues/190) +- Support Partial Indexes [\#177](https://github.com/CosmWasm/cw-plus/issues/177) +- Improve cw20-staking contract [\#59](https://github.com/CosmWasm/cw-plus/issues/59) + +**Merged pull requests:** + +- Add `MIGRATING.md` [\#591](https://github.com/CosmWasm/cw-plus/pull/591) ([maurolacy](https://github.com/maurolacy)) +- Move Threshold and coexisting implementations into packages/utils [\#590](https://github.com/CosmWasm/cw-plus/pull/590) ([ueco-jb](https://github.com/ueco-jb)) +- Build and upload schemas in CI [\#589](https://github.com/CosmWasm/cw-plus/pull/589) ([maurolacy](https://github.com/maurolacy)) +- Fix min threshold and vote power bugs in cw3-fixed-multisig [\#588](https://github.com/CosmWasm/cw-plus/pull/588) ([ueco-jb](https://github.com/ueco-jb)) +- Update to cosmwasm 1.0.0-beta3 [\#587](https://github.com/CosmWasm/cw-plus/pull/587) ([ueco-jb](https://github.com/ueco-jb)) +- Make `update_changelog.sh` use the latest version tag by default [\#585](https://github.com/CosmWasm/cw-plus/pull/585) ([maurolacy](https://github.com/maurolacy)) +- Signed int keys order [\#582](https://github.com/CosmWasm/cw-plus/pull/582) ([maurolacy](https://github.com/maurolacy)) +- `range` to `range raw` [\#576](https://github.com/CosmWasm/cw-plus/pull/576) ([maurolacy](https://github.com/maurolacy)) +- Remove helper.ts files for contracts [\#574](https://github.com/CosmWasm/cw-plus/pull/574) ([findolor](https://github.com/findolor)) +- Fix expiration type properties on cw1-subkeys helpers.ts [\#571](https://github.com/CosmWasm/cw-plus/pull/571) ([findolor](https://github.com/findolor)) +- `MultiIndex` primary key spec removal [\#569](https://github.com/CosmWasm/cw-plus/pull/569) ([maurolacy](https://github.com/maurolacy)) +- Index keys consistency [\#568](https://github.com/CosmWasm/cw-plus/pull/568) ([maurolacy](https://github.com/maurolacy)) +- Implement display for Balance and Coin [\#565](https://github.com/CosmWasm/cw-plus/pull/565) ([orkunkl](https://github.com/orkunkl)) +- Migrate from `IntKey` to new naked int key [\#564](https://github.com/CosmWasm/cw-plus/pull/564) ([ueco-jb](https://github.com/ueco-jb)) +- Add ParseReplyError to cw0 lib [\#562](https://github.com/CosmWasm/cw-plus/pull/562) ([shanev](https://github.com/shanev)) +- Update cw2 readme - contract\_info key [\#561](https://github.com/CosmWasm/cw-plus/pull/561) ([korzewski](https://github.com/korzewski)) +- Change pebblenet to uni and update wasm binary to 0.10.2 [\#560](https://github.com/CosmWasm/cw-plus/pull/560) ([findolor](https://github.com/findolor)) +- Update cw1-subkeys/helpers.ts wasm binary version to 0.10.2 from 0.9.1 [\#558](https://github.com/CosmWasm/cw-plus/pull/558) ([findolor](https://github.com/findolor)) +- Update base-helpers.ts options [\#557](https://github.com/CosmWasm/cw-plus/pull/557) ([findolor](https://github.com/findolor)) +- Update cw4-group/helpers.ts to work with base-helpers.ts [\#552](https://github.com/CosmWasm/cw-plus/pull/552) ([findolor](https://github.com/findolor)) +- Update cw3-flex-multisig/helpers.ts to work with cosmjs/cli v0.26 and base-helpers.ts [\#550](https://github.com/CosmWasm/cw-plus/pull/550) ([findolor](https://github.com/findolor)) +- Cw0 rename [\#508](https://github.com/CosmWasm/cw-plus/pull/508) ([maurolacy](https://github.com/maurolacy)) +- UniqueIndex range\_de [\#500](https://github.com/CosmWasm/cw-plus/pull/500) ([uint](https://github.com/uint)) ## [v0.10.3](https://github.com/CosmWasm/cw-plus/tree/v0.10.3) (2021-11-16) diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index be01f7a0f..448f6e947 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -21,6 +21,7 @@ library = [] utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw3 = { path = "../../packages/cw3", version = "0.11.0" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.11.0", features = ["library"] } cw4 = { path = "../../packages/cw4", version = "0.11.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } From bd88a92d9c653586bf94381e121ff775c8f7f89a Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 22 Dec 2021 16:26:50 +0100 Subject: [PATCH 094/352] Mantion latest workspace optimizer version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f9098648..6e088d295 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ To compile all the contracts, run the following in the repo root: docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/workspace-optimizer:0.12.3 + cosmwasm/workspace-optimizer:0.12.4 ``` This will compile all packages in the `contracts` directory and output the From 4c5b8bfb8ac4069e3aad3085b85fb19dc2e259c7 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 22 Dec 2021 16:41:23 +0100 Subject: [PATCH 095/352] Fix artifacts publishing so that schemas are not deleted --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 126a9c128..718b56953 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -848,7 +848,7 @@ jobs: -u "$CIRCLE_PROJECT_USERNAME" -r "$CIRCLE_PROJECT_REPONAME" \ -c "$CIRCLE_SHA1" \ -n "$TITLE" -b "$BODY" \ - -delete \ + -replace \ "$TAG" ./artifacts/ build_and_upload_schemas: From a478ec2d7e595a38670927bdd05447cda79dc64e Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 22 Dec 2021 16:43:06 +0100 Subject: [PATCH 096/352] Update workspace-optimizer to latest version in CI --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 718b56953..7bdf9d52e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -831,7 +831,7 @@ jobs: - run: name: Build development contracts command: | - docker run --volumes-from with_code cosmwasm/workspace-optimizer:0.12.3 + docker run --volumes-from with_code cosmwasm/workspace-optimizer:0.12.4 docker cp with_code:/code/artifacts ./artifacts - run: name: Show data From b4e8e671f96e0020ae92a262abf679db4bd8e27a Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Wed, 22 Dec 2021 21:47:34 +0100 Subject: [PATCH 097/352] add context to multitest execution errors --- packages/multi-test/src/contracts.rs | 26 +++++++++++++++++++------- packages/multi-test/src/executor.rs | 25 ++++++++++++++++++------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index 8b0af4079..bf88b1158 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -6,7 +6,7 @@ use cosmwasm_std::{ from_slice, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Reply, Response, SubMsg, }; -use anyhow::{anyhow, bail, Result as AnyResult}; +use anyhow::{anyhow, bail, Context, Result as AnyResult}; /// Interface to call into a Contract pub trait Contract @@ -65,7 +65,7 @@ pub struct ContractWrapper< T6 = Empty, E6 = anyhow::Error, > where - T1: DeserializeOwned, + T1: DeserializeOwned + Debug, T2: DeserializeOwned, T3: DeserializeOwned, T4: DeserializeOwned, @@ -88,7 +88,7 @@ pub struct ContractWrapper< impl ContractWrapper where - T1: DeserializeOwned + 'static, + T1: DeserializeOwned + Debug + 'static, T2: DeserializeOwned + 'static, T3: DeserializeOwned + 'static, E1: Display + Debug + Send + Sync + 'static, @@ -132,7 +132,7 @@ where impl ContractWrapper where - T1: DeserializeOwned + 'static, + T1: DeserializeOwned + Debug + 'static, T2: DeserializeOwned + 'static, T3: DeserializeOwned + 'static, T4: DeserializeOwned + 'static, @@ -317,7 +317,7 @@ where impl Contract for ContractWrapper where - T1: DeserializeOwned, + T1: DeserializeOwned + Debug + Clone, T2: DeserializeOwned, T3: DeserializeOwned, T4: DeserializeOwned, @@ -337,8 +337,20 @@ where info: MessageInfo, msg: Vec, ) -> AnyResult> { - let msg = from_slice(&msg)?; - (self.execute_fn)(deps, env, info, msg).map_err(|err| anyhow!(err)) + let msg: T1 = from_slice(&msg)?; + let address = env.contract.address.clone(); + (self.execute_fn)(deps, env, info.clone(), msg.clone()) + .map_err(|err| anyhow!("{}", err)) + .context(format!( + r#"Contract returned an error on execute +Contract address: {} +Message sender: {} +Funds: {:?} +Message dump: +{:?} +"#, + address, info.sender, info.funds, msg, + )) } fn instantiate( diff --git a/packages/multi-test/src/executor.rs b/packages/multi-test/src/executor.rs index 6e1e8678d..31fe75ee5 100644 --- a/packages/multi-test/src/executor.rs +++ b/packages/multi-test/src/executor.rs @@ -8,7 +8,7 @@ use schemars::JsonSchema; use serde::Serialize; use utils::{parse_execute_response_data, parse_instantiate_response_data}; -use anyhow::Result as AnyResult; +use anyhow::{Context, Result as AnyResult}; #[derive(Default, Clone, Debug)] pub struct AppResponse { @@ -98,20 +98,31 @@ where /// Execute a contract and process all returned messages. /// This is just a helper around execute(), /// but we parse out the data field to that what is returned by the contract (not the protobuf wrapper) - fn execute_contract( + fn execute_contract( &mut self, sender: Addr, contract_addr: Addr, msg: &T, send_funds: &[Coin], ) -> AnyResult { - let msg = to_binary(msg)?; - let msg = WasmMsg::Execute { - contract_addr: contract_addr.into(), - msg, + let binary_msg = to_binary(msg)?; + let wrapped_msg = WasmMsg::Execute { + contract_addr: contract_addr.to_string(), + msg: binary_msg, funds: send_funds.to_vec(), }; - let mut res = self.execute(sender, msg.into())?; + let mut res = self + .execute(sender.clone(), wrapped_msg.into()) + .context(format!( + r#"Contract returned an error on execute +Contract address: {} +Message sender: {} +Funds: {:?} +Message dump: +{:?} +"#, + contract_addr, sender, send_funds, msg, + ))?; res.data = res .data .and_then(|d| parse_execute_response_data(d.as_slice()).unwrap().data); From a4aa4b691c10e57bdcfc9a680c7cf4d7740f8ea9 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 22 Dec 2021 23:00:21 +0100 Subject: [PATCH 098/352] Rename utils to cw-utils --- Cargo.lock | 64 +++++++++---------- MIGRATING.md | 6 +- contracts/cw1-subkeys/Cargo.toml | 2 +- contracts/cw1-subkeys/src/contract.rs | 4 +- contracts/cw1-subkeys/src/error.rs | 2 +- contracts/cw1-subkeys/src/msg.rs | 4 +- contracts/cw1-subkeys/src/state.rs | 4 +- contracts/cw1-whitelist-ng/Cargo.toml | 2 +- contracts/cw1-whitelist/Cargo.toml | 2 +- contracts/cw1155-base/Cargo.toml | 2 +- contracts/cw1155-base/src/contract.rs | 2 +- contracts/cw20-atomic-swap/Cargo.toml | 2 +- contracts/cw20-base/Cargo.toml | 2 +- contracts/cw20-bonding/Cargo.toml | 2 +- contracts/cw20-bonding/src/contract.rs | 4 +- contracts/cw20-bonding/src/error.rs | 2 +- contracts/cw20-escrow/Cargo.toml | 2 +- contracts/cw20-ics20/Cargo.toml | 2 +- contracts/cw20-ics20/src/contract.rs | 4 +- contracts/cw20-ics20/src/error.rs | 2 +- contracts/cw20-merkle-airdrop/Cargo.toml | 2 +- contracts/cw20-staking/Cargo.toml | 2 +- contracts/cw20-staking/src/contract.rs | 2 +- contracts/cw20-staking/src/msg.rs | 2 +- contracts/cw20-staking/src/state.rs | 2 +- contracts/cw3-fixed-multisig/Cargo.toml | 2 +- contracts/cw3-fixed-multisig/src/contract.rs | 8 +-- contracts/cw3-fixed-multisig/src/error.rs | 2 +- .../src/integration_tests.rs | 2 +- contracts/cw3-fixed-multisig/src/msg.rs | 2 +- contracts/cw3-fixed-multisig/src/state.rs | 2 +- contracts/cw3-flex-multisig/Cargo.toml | 2 +- contracts/cw3-flex-multisig/src/contract.rs | 8 +-- contracts/cw3-flex-multisig/src/error.rs | 2 +- contracts/cw3-flex-multisig/src/msg.rs | 2 +- contracts/cw3-flex-multisig/src/state.rs | 2 +- contracts/cw4-group/Cargo.toml | 2 +- contracts/cw4-group/src/contract.rs | 2 +- contracts/cw4-stake/Cargo.toml | 2 +- contracts/cw4-stake/src/contract.rs | 4 +- contracts/cw4-stake/src/msg.rs | 2 +- contracts/cw4-stake/src/state.rs | 2 +- packages/controllers/Cargo.toml | 2 +- packages/controllers/src/claim.rs | 2 +- packages/cw1155/Cargo.toml | 2 +- packages/cw1155/src/event.rs | 2 +- packages/cw1155/src/lib.rs | 2 +- packages/cw1155/src/msg.rs | 2 +- packages/cw1155/src/query.rs | 2 +- packages/cw20/Cargo.toml | 2 +- packages/cw20/src/balance.rs | 2 +- packages/cw20/src/lib.rs | 2 +- packages/cw20/src/msg.rs | 2 +- packages/cw20/src/query.rs | 2 +- packages/cw3/Cargo.toml | 2 +- packages/cw3/examples/schema.rs | 2 +- packages/cw3/src/helpers.rs | 2 +- packages/cw3/src/msg.rs | 2 +- packages/cw3/src/query.rs | 2 +- packages/multi-test/Cargo.toml | 2 +- packages/multi-test/src/app.rs | 2 +- packages/multi-test/src/bank.rs | 2 +- packages/multi-test/src/executor.rs | 2 +- .../src/test_helpers/contracts/echo.rs | 2 +- packages/utils/Cargo.toml | 2 +- 65 files changed, 110 insertions(+), 110 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4e2824967..74175f326 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -245,10 +245,10 @@ version = "0.11.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", + "cw-utils", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -259,13 +259,13 @@ dependencies = [ "cosmwasm-std", "cosmwasm-storage", "cw-storage-plus", + "cw-utils", "derivative", "itertools", "prost", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -277,6 +277,18 @@ dependencies = [ "serde", ] +[[package]] +name = "cw-utils" +version = "0.11.0" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus", + "prost", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "cw1" version = "0.11.0" @@ -294,6 +306,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", + "cw-utils", "cw1", "cw1-whitelist", "cw2", @@ -301,7 +314,6 @@ dependencies = [ "semver", "serde", "thiserror", - "utils", ] [[package]] @@ -314,13 +326,13 @@ dependencies = [ "cosmwasm-std", "cw-multi-test", "cw-storage-plus", + "cw-utils", "cw1", "cw2", "derivative", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -333,13 +345,13 @@ dependencies = [ "cosmwasm-std", "cw-multi-test", "cw-storage-plus", + "cw-utils", "cw1", "cw2", "derivative", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -348,9 +360,9 @@ version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", + "cw-utils", "schemars", "serde", - "utils", ] [[package]] @@ -360,12 +372,12 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", + "cw-utils", "cw1155", "cw2", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -384,9 +396,9 @@ version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", + "cw-utils", "schemars", "serde", - "utils", ] [[package]] @@ -396,6 +408,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", + "cw-utils", "cw2", "cw20", "hex 0.3.2", @@ -403,7 +416,6 @@ dependencies = [ "serde", "sha2 0.8.2", "thiserror", - "utils", ] [[package]] @@ -413,12 +425,12 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", + "cw-utils", "cw2", "cw20", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -428,6 +440,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", + "cw-utils", "cw2", "cw20", "cw20-base", @@ -437,7 +450,6 @@ dependencies = [ "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -448,13 +460,13 @@ dependencies = [ "cosmwasm-std", "cw-multi-test", "cw-storage-plus", + "cw-utils", "cw2", "cw20", "cw20-base", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -464,12 +476,12 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", + "cw-utils", "cw2", "cw20", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -479,6 +491,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", + "cw-utils", "cw2", "cw20", "hex 0.4.3", @@ -487,7 +500,6 @@ dependencies = [ "serde_json", "sha2 0.9.8", "thiserror", - "utils", ] [[package]] @@ -498,13 +510,13 @@ dependencies = [ "cosmwasm-std", "cw-controllers", "cw-storage-plus", + "cw-utils", "cw2", "cw20", "cw20-base", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -513,9 +525,9 @@ version = "0.11.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", + "cw-utils", "schemars", "serde", - "utils", ] [[package]] @@ -526,6 +538,7 @@ dependencies = [ "cosmwasm-std", "cw-multi-test", "cw-storage-plus", + "cw-utils", "cw2", "cw20", "cw20-base", @@ -533,7 +546,6 @@ dependencies = [ "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -544,6 +556,7 @@ dependencies = [ "cosmwasm-std", "cw-multi-test", "cw-storage-plus", + "cw-utils", "cw2", "cw3", "cw3-fixed-multisig", @@ -552,7 +565,6 @@ dependencies = [ "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -574,12 +586,12 @@ dependencies = [ "cosmwasm-std", "cw-controllers", "cw-storage-plus", + "cw-utils", "cw2", "cw4", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -590,13 +602,13 @@ dependencies = [ "cosmwasm-std", "cw-controllers", "cw-storage-plus", + "cw-utils", "cw2", "cw20", "cw4", "schemars", "serde", "thiserror", - "utils", ] [[package]] @@ -1168,18 +1180,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" -[[package]] -name = "utils" -version = "0.11.0" -dependencies = [ - "cosmwasm-std", - "cw-storage-plus", - "prost", - "schemars", - "serde", - "thiserror", -] - [[package]] name = "version_check" version = "0.9.3" diff --git a/MIGRATING.md b/MIGRATING.md index 1229109f8..c8da916c3 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -16,7 +16,7 @@ index 1924b655..37af477d 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml -cw0 = { path = "../../packages/cw0", version = "0.10.3" } -+utils = { path = "../../packages/utils", version = "0.10.3" } ++cw-utils = { path = "../../packages/utils", version = "0.10.3" } ``` ```diff @@ -25,7 +25,7 @@ index b4852225..f20a65ec 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs -use cw0::Expiration; -+use utils::Expiration; ++use cw_utils::Expiration; ``` --- @@ -244,7 +244,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result, diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 3bfa738ef..5c487ff9c 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -19,7 +19,7 @@ library = [] test-utils = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw1 = { path = "../../packages/cw1", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.11.0", features = ["library"] } diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/contract.rs index fca7ee1a4..1d0f2bbb9 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs @@ -19,8 +19,8 @@ use cw1_whitelist::{ }; use cw2::{get_contract_version, set_contract_version}; use cw_storage_plus::Bound; +use cw_utils::Expiration; use semver::Version; -use utils::Expiration; use crate::error::ContractError; use crate::msg::{ @@ -477,7 +477,7 @@ mod tests { use cw1_whitelist::msg::AdminListResponse; use cw2::{get_contract_version, ContractVersion}; - use utils::NativeBalance; + use cw_utils::NativeBalance; use crate::state::Permissions; diff --git a/contracts/cw1-subkeys/src/error.rs b/contracts/cw1-subkeys/src/error.rs index f79605f28..acafc9376 100644 --- a/contracts/cw1-subkeys/src/error.rs +++ b/contracts/cw1-subkeys/src/error.rs @@ -1,6 +1,6 @@ use cosmwasm_std::StdError; +use cw_utils::Expiration; use thiserror::Error; -use utils::Expiration; #[derive(Error, Debug, PartialEq)] pub enum ContractError { diff --git a/contracts/cw1-subkeys/src/msg.rs b/contracts/cw1-subkeys/src/msg.rs index a7ddf89dd..3af6943ef 100644 --- a/contracts/cw1-subkeys/src/msg.rs +++ b/contracts/cw1-subkeys/src/msg.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use std::fmt; use cosmwasm_std::{Coin, CosmosMsg, Empty}; -use utils::{Expiration, NativeBalance}; +use cw_utils::{Expiration, NativeBalance}; use crate::state::Permissions; @@ -112,7 +112,7 @@ impl AllowanceInfo { /// Example: /// /// ``` - /// # use utils::{Expiration, NativeBalance}; + /// # use cw_utils::{Expiration, NativeBalance}; /// # use cw1_subkeys::msg::AllowanceInfo; /// # use cosmwasm_std::coin; /// diff --git a/contracts/cw1-subkeys/src/state.rs b/contracts/cw1-subkeys/src/state.rs index 007354c17..866e419eb 100644 --- a/contracts/cw1-subkeys/src/state.rs +++ b/contracts/cw1-subkeys/src/state.rs @@ -4,7 +4,7 @@ use std::fmt; use cosmwasm_std::Addr; use cw_storage_plus::Map; -use utils::{Expiration, NativeBalance}; +use cw_utils::{Expiration, NativeBalance}; // Permissions struct defines users message execution permissions. // Could have implemented permissions for each cosmos module(StakingPermissions, GovPermissions etc...) @@ -46,7 +46,7 @@ impl Allowance { /// Example: /// /// ``` - /// # use utils::{Expiration, NativeBalance}; + /// # use cw_utils::{Expiration, NativeBalance}; /// # use cw1_subkeys::state::Allowance; /// # use cosmwasm_std::coin; /// diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index 31d3ed5aa..d03d5d474 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -22,7 +22,7 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw1 = { path = "../../packages/cw1", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index 9ae2ddf08..4ca281d08 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -19,7 +19,7 @@ library = [] test-utils = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw1 = { path = "../../packages/cw1", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 35cd30461..16ccfc160 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -18,7 +18,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw1155 = { path = "../../packages/cw1155", version = "0.11.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } diff --git a/contracts/cw1155-base/src/contract.rs b/contracts/cw1155-base/src/contract.rs index e3195cff3..611d3e41c 100644 --- a/contracts/cw1155-base/src/contract.rs +++ b/contracts/cw1155-base/src/contract.rs @@ -11,7 +11,7 @@ use cw1155::{ IsApprovedForAllResponse, TokenId, TokenInfoResponse, TokensResponse, TransferEvent, }; use cw2::set_contract_version; -use utils::{maybe_addr, Event}; +use cw_utils::{maybe_addr, Event}; use crate::error::ContractError; use crate::msg::InstantiateMsg; diff --git a/contracts/cw20-atomic-swap/Cargo.toml b/contracts/cw20-atomic-swap/Cargo.toml index fd724cec8..3f9fc0797 100644 --- a/contracts/cw20-atomic-swap/Cargo.toml +++ b/contracts/cw20-atomic-swap/Cargo.toml @@ -15,7 +15,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw20 = { path = "../../packages/cw20", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index 40961b4ff..ae494f080 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -18,7 +18,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw20 = { path = "../../packages/cw20", version = "0.11.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } diff --git a/contracts/cw20-bonding/Cargo.toml b/contracts/cw20-bonding/Cargo.toml index e48160be3..fea0d5065 100644 --- a/contracts/cw20-bonding/Cargo.toml +++ b/contracts/cw20-bonding/Cargo.toml @@ -20,7 +20,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw20 = { path = "../../packages/cw20", version = "0.11.0" } cw20-base = { path = "../../contracts/cw20-base", version = "0.11.0", features = ["library"] } diff --git a/contracts/cw20-bonding/src/contract.rs b/contracts/cw20-bonding/src/contract.rs index 01a5b8b62..a3a33aed2 100644 --- a/contracts/cw20-bonding/src/contract.rs +++ b/contracts/cw20-bonding/src/contract.rs @@ -19,7 +19,7 @@ use crate::curves::DecimalPlaces; use crate::error::ContractError; use crate::msg::{CurveFn, CurveInfoResponse, ExecuteMsg, InstantiateMsg, QueryMsg}; use crate::state::{CurveState, CURVE_STATE, CURVE_TYPE}; -use utils::{must_pay, nonpayable}; +use cw_utils::{must_pay, nonpayable}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw20-bonding"; @@ -314,7 +314,7 @@ mod tests { use crate::msg::CurveType; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{coin, Decimal, OverflowError, OverflowOperation, StdError, SubMsg}; - use utils::PaymentError; + use cw_utils::PaymentError; const DENOM: &str = "satoshi"; const CREATOR: &str = "creator"; diff --git a/contracts/cw20-bonding/src/error.rs b/contracts/cw20-bonding/src/error.rs index dd2d577bf..aa6bcc9ab 100644 --- a/contracts/cw20-bonding/src/error.rs +++ b/contracts/cw20-bonding/src/error.rs @@ -1,6 +1,6 @@ use cosmwasm_std::StdError; +use cw_utils::PaymentError; use thiserror::Error; -use utils::PaymentError; #[derive(Error, Debug, PartialEq)] pub enum ContractError { diff --git a/contracts/cw20-escrow/Cargo.toml b/contracts/cw20-escrow/Cargo.toml index 2914a0b0f..a41fbc36a 100644 --- a/contracts/cw20-escrow/Cargo.toml +++ b/contracts/cw20-escrow/Cargo.toml @@ -18,7 +18,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw20 = { path = "../../packages/cw20", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 6cc4050a8..b268ea558 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -18,7 +18,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw20 = { path = "../../packages/cw20", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3", features = ["stargate"] } diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 132c08dd6..fc4ffb7e6 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -16,7 +16,7 @@ use crate::msg::{ TransferMsg, }; use crate::state::{Config, CHANNEL_INFO, CHANNEL_STATE, CONFIG}; -use utils::{nonpayable, one_coin}; +use cw_utils::{nonpayable, one_coin}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw20-ics20"; @@ -191,7 +191,7 @@ mod test { use cosmwasm_std::testing::{mock_env, mock_info}; use cosmwasm_std::{coin, coins, CosmosMsg, IbcMsg, StdError, Uint128}; - use utils::PaymentError; + use cw_utils::PaymentError; #[test] fn setup_and_query() { diff --git a/contracts/cw20-ics20/src/error.rs b/contracts/cw20-ics20/src/error.rs index 64082ef3c..c20a0b4d5 100644 --- a/contracts/cw20-ics20/src/error.rs +++ b/contracts/cw20-ics20/src/error.rs @@ -3,7 +3,7 @@ use std::string::FromUtf8Error; use thiserror::Error; use cosmwasm_std::StdError; -use utils::PaymentError; +use cw_utils::PaymentError; /// Never is a placeholder to ensure we don't return any errors #[derive(Error, Debug)] diff --git a/contracts/cw20-merkle-airdrop/Cargo.toml b/contracts/cw20-merkle-airdrop/Cargo.toml index 8db60cd38..ba108b805 100644 --- a/contracts/cw20-merkle-airdrop/Cargo.toml +++ b/contracts/cw20-merkle-airdrop/Cargo.toml @@ -19,7 +19,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw20 = { path = "../../packages/cw20", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-staking/Cargo.toml b/contracts/cw20-staking/Cargo.toml index 42c10175b..75d2c7123 100644 --- a/contracts/cw20-staking/Cargo.toml +++ b/contracts/cw20-staking/Cargo.toml @@ -20,7 +20,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw20 = { path = "../../packages/cw20", version = "0.11.0" } cw-controllers = { path = "../../packages/controllers", version = "0.11.0" } diff --git a/contracts/cw20-staking/src/contract.rs b/contracts/cw20-staking/src/contract.rs index 672162155..a64dc0174 100644 --- a/contracts/cw20-staking/src/contract.rs +++ b/contracts/cw20-staking/src/contract.rs @@ -439,7 +439,7 @@ mod tests { Validator, }; use cw_controllers::Claim; - use utils::{Duration, DAY, HOUR, WEEK}; + use cw_utils::{Duration, DAY, HOUR, WEEK}; fn sample_validator(addr: &str) -> Validator { Validator { diff --git a/contracts/cw20-staking/src/msg.rs b/contracts/cw20-staking/src/msg.rs index facf326ed..b9c22f11b 100644 --- a/contracts/cw20-staking/src/msg.rs +++ b/contracts/cw20-staking/src/msg.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{Binary, Coin, Decimal, Uint128}; use cw20::Expiration; pub use cw_controllers::ClaimsResponse; -use utils::Duration; +use cw_utils::Duration; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct InstantiateMsg { diff --git a/contracts/cw20-staking/src/state.rs b/contracts/cw20-staking/src/state.rs index 3e23fdca3..e179665fd 100644 --- a/contracts/cw20-staking/src/state.rs +++ b/contracts/cw20-staking/src/state.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{Addr, Decimal, Uint128}; use cw_controllers::Claims; use cw_storage_plus::Item; -use utils::Duration; +use cw_utils::Duration; pub const CLAIMS: Claims = Claims::new("claims"); diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index c2a5cf04e..445e8d66a 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -18,7 +18,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw3 = { path = "../../packages/cw3", version = "0.11.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index b8ce7f05f..394e9bc69 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -13,7 +13,7 @@ use cw3::{ VoterDetail, VoterListResponse, VoterResponse, }; use cw_storage_plus::Bound; -use utils::{Expiration, ThresholdResponse}; +use cw_utils::{Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; @@ -403,7 +403,7 @@ mod tests { use cosmwasm_std::{coin, from_binary, BankMsg, Decimal}; use cw2::{get_contract_version, ContractVersion}; - use utils::{Duration, Threshold}; + use cw_utils::{Duration, Threshold}; use crate::msg::Voter; @@ -516,7 +516,7 @@ mod tests { instantiate(deps.as_mut(), mock_env(), info.clone(), instantiate_msg).unwrap_err(); assert_eq!( err, - ContractError::Threshold(utils::ThresholdError::InvalidThreshold {}) + ContractError::Threshold(cw_utils::ThresholdError::InvalidThreshold {}) ); // Total weight less than required weight not allowed @@ -525,7 +525,7 @@ mod tests { setup_test_case(deps.as_mut(), info.clone(), threshold, max_voting_period).unwrap_err(); assert_eq!( err, - ContractError::Threshold(utils::ThresholdError::UnreachableWeight {}) + ContractError::Threshold(cw_utils::ThresholdError::UnreachableWeight {}) ); // All valid diff --git a/contracts/cw3-fixed-multisig/src/error.rs b/contracts/cw3-fixed-multisig/src/error.rs index 1b4dcebf3..ff0b523d6 100644 --- a/contracts/cw3-fixed-multisig/src/error.rs +++ b/contracts/cw3-fixed-multisig/src/error.rs @@ -1,5 +1,5 @@ use cosmwasm_std::StdError; -use utils::ThresholdError; +use cw_utils::ThresholdError; use thiserror::Error; diff --git a/contracts/cw3-fixed-multisig/src/integration_tests.rs b/contracts/cw3-fixed-multisig/src/integration_tests.rs index a0737a49b..d9caf9e41 100644 --- a/contracts/cw3-fixed-multisig/src/integration_tests.rs +++ b/contracts/cw3-fixed-multisig/src/integration_tests.rs @@ -5,7 +5,7 @@ use cw20::{BalanceResponse, MinterResponse}; use cw20_base::msg::QueryMsg; use cw3::Vote; use cw_multi_test::{App, Contract, ContractWrapper, Executor}; -use utils::{Duration, Threshold}; +use cw_utils::{Duration, Threshold}; use crate::contract::{execute, instantiate, query}; use crate::msg::{ExecuteMsg, InstantiateMsg, Voter}; diff --git a/contracts/cw3-fixed-multisig/src/msg.rs b/contracts/cw3-fixed-multisig/src/msg.rs index 3ea74f2b5..18ed4eedd 100644 --- a/contracts/cw3-fixed-multisig/src/msg.rs +++ b/contracts/cw3-fixed-multisig/src/msg.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{CosmosMsg, Empty}; use cw3::Vote; -use utils::{Duration, Expiration, Threshold}; +use cw_utils::{Duration, Expiration, Threshold}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct InstantiateMsg { diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index 22a7ae50e..92dbbe62f 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -5,7 +5,7 @@ use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Decimal, Empty, StdResult, Storag use cw3::{Status, Vote}; use cw_storage_plus::{Item, Map}; -use utils::{Duration, Expiration, Threshold}; +use cw_utils::{Duration, Expiration, Threshold}; // we multiply by this when calculating needed_votes in order to round up properly // Note: `10u128.pow(9)` fails as "u128::pow` is not yet stable as a const fn" diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 448f6e947..47b517f22 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -18,7 +18,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw3 = { path = "../../packages/cw3", version = "0.11.0" } cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.11.0", features = ["library"] } diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index dd8168c40..929975136 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -15,7 +15,7 @@ use cw3::{ use cw3_fixed_multisig::state::{next_id, Ballot, Proposal, Votes, BALLOTS, PROPOSALS}; use cw4::{Cw4Contract, MemberChangedHookMsg, MemberDiff}; use cw_storage_plus::Bound; -use utils::{maybe_addr, Expiration, ThresholdResponse}; +use cw_utils::{maybe_addr, Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; @@ -432,7 +432,7 @@ mod tests { use cw4::{Cw4ExecuteMsg, Member}; use cw4_group::helpers::Cw4GroupContract; use cw_multi_test::{next_block, App, AppBuilder, Contract, ContractWrapper, Executor}; - use utils::{Duration, Threshold}; + use cw_utils::{Duration, Threshold}; use super::*; @@ -626,7 +626,7 @@ mod tests { ) .unwrap_err(); assert_eq!( - ContractError::Threshold(utils::ThresholdError::InvalidThreshold {}), + ContractError::Threshold(cw_utils::ThresholdError::InvalidThreshold {}), err.downcast().unwrap() ); @@ -647,7 +647,7 @@ mod tests { ) .unwrap_err(); assert_eq!( - ContractError::Threshold(utils::ThresholdError::UnreachableWeight {}), + ContractError::Threshold(cw_utils::ThresholdError::UnreachableWeight {}), err.downcast().unwrap() ); diff --git a/contracts/cw3-flex-multisig/src/error.rs b/contracts/cw3-flex-multisig/src/error.rs index 4a56312bb..4936a8923 100644 --- a/contracts/cw3-flex-multisig/src/error.rs +++ b/contracts/cw3-flex-multisig/src/error.rs @@ -1,5 +1,5 @@ use cosmwasm_std::StdError; -use utils::ThresholdError; +use cw_utils::ThresholdError; use thiserror::Error; diff --git a/contracts/cw3-flex-multisig/src/msg.rs b/contracts/cw3-flex-multisig/src/msg.rs index 9b6fa67ef..8d72cd37b 100644 --- a/contracts/cw3-flex-multisig/src/msg.rs +++ b/contracts/cw3-flex-multisig/src/msg.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{CosmosMsg, Empty}; use cw3::Vote; use cw4::MemberChangedHookMsg; -use utils::{Duration, Expiration, Threshold}; +use cw_utils::{Duration, Expiration, Threshold}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct InstantiateMsg { diff --git a/contracts/cw3-flex-multisig/src/state.rs b/contracts/cw3-flex-multisig/src/state.rs index 987c57237..023662b8b 100644 --- a/contracts/cw3-flex-multisig/src/state.rs +++ b/contracts/cw3-flex-multisig/src/state.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use cw4::Cw4Contract; use cw_storage_plus::Item; -use utils::{Duration, Threshold}; +use cw_utils::{Duration, Threshold}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index cf599b1f6..1918a243e 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -26,7 +26,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw4 = { path = "../../packages/cw4", version = "0.11.0" } cw-controllers = { path = "../../packages/controllers", version = "0.11.0" } diff --git a/contracts/cw4-group/src/contract.rs b/contracts/cw4-group/src/contract.rs index e41e9d9f6..cc3ec20c2 100644 --- a/contracts/cw4-group/src/contract.rs +++ b/contracts/cw4-group/src/contract.rs @@ -10,7 +10,7 @@ use cw4::{ TotalWeightResponse, }; use cw_storage_plus::Bound; -use utils::maybe_addr; +use cw_utils::maybe_addr; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index 041677d03..1709658ee 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -26,7 +26,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw2 = { path = "../../packages/cw2", version = "0.11.0" } cw4 = { path = "../../packages/cw4", version = "0.11.0" } cw20 = { path = "../../packages/cw20", version = "0.11.0" } diff --git a/contracts/cw4-stake/src/contract.rs b/contracts/cw4-stake/src/contract.rs index 635a20080..e1d372083 100644 --- a/contracts/cw4-stake/src/contract.rs +++ b/contracts/cw4-stake/src/contract.rs @@ -12,7 +12,7 @@ use cw4::{ TotalWeightResponse, }; use cw_storage_plus::Bound; -use utils::{maybe_addr, NativeBalance}; +use cw_utils::{maybe_addr, NativeBalance}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, ReceiveMsg, StakedResponse}; @@ -364,7 +364,7 @@ mod tests { use cw20::Denom; use cw4::{member_key, TOTAL_KEY}; use cw_controllers::{AdminError, Claim, HookError}; - use utils::Duration; + use cw_utils::Duration; use crate::error::ContractError; diff --git a/contracts/cw4-stake/src/msg.rs b/contracts/cw4-stake/src/msg.rs index 6c5d76bb4..29e81f595 100644 --- a/contracts/cw4-stake/src/msg.rs +++ b/contracts/cw4-stake/src/msg.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use cw20::{Cw20ReceiveMsg, Denom}; pub use cw_controllers::ClaimsResponse; -use utils::Duration; +use cw_utils::Duration; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct InstantiateMsg { diff --git a/contracts/cw4-stake/src/state.rs b/contracts/cw4-stake/src/state.rs index 0a60a4a18..d8c69f98b 100644 --- a/contracts/cw4-stake/src/state.rs +++ b/contracts/cw4-stake/src/state.rs @@ -6,7 +6,7 @@ use cw20::Denom; use cw4::TOTAL_KEY; use cw_controllers::{Admin, Claims, Hooks}; use cw_storage_plus::{Item, Map, SnapshotMap, Strategy}; -use utils::Duration; +use cw_utils::Duration; pub const CLAIMS: Claims = Claims::new("claims"); diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index 783163a6e..df6e54b45 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -13,7 +13,7 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta3" } -utils = { path = "../utils", version = "0.11.0" } +cw-utils = { path = "../utils", version = "0.11.0" } cw-storage-plus = { path = "../storage-plus", version = "0.11.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/controllers/src/claim.rs b/packages/controllers/src/claim.rs index b4d1b502c..a6d6c3d25 100644 --- a/packages/controllers/src/claim.rs +++ b/packages/controllers/src/claim.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{Addr, BlockInfo, Deps, StdResult, Storage, Uint128}; use cw_storage_plus::Map; -use utils::Expiration; +use cw_utils::Expiration; // TODO: pull into utils? #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 9048f5217..632249d32 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw1155/src/event.rs b/packages/cw1155/src/event.rs index cfe58f378..2d7709fa8 100644 --- a/packages/cw1155/src/event.rs +++ b/packages/cw1155/src/event.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{attr, Response, Uint128}; -use utils::Event; +use cw_utils::Event; /// Tracks token transfer/mint/burn actions pub struct TransferEvent<'a> { diff --git a/packages/cw1155/src/lib.rs b/packages/cw1155/src/lib.rs index 13c67588d..dfea27c4f 100644 --- a/packages/cw1155/src/lib.rs +++ b/packages/cw1155/src/lib.rs @@ -1,4 +1,4 @@ -pub use utils::Expiration; +pub use cw_utils::Expiration; pub use crate::event::{ApproveAllEvent, MetadataEvent, TransferEvent}; pub use crate::msg::{Cw1155ExecuteMsg, TokenId}; diff --git a/packages/cw1155/src/msg.rs b/packages/cw1155/src/msg.rs index d22612b3c..ab087dd40 100644 --- a/packages/cw1155/src/msg.rs +++ b/packages/cw1155/src/msg.rs @@ -2,7 +2,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{Binary, Uint128}; -use utils::Expiration; +use cw_utils::Expiration; pub type TokenId = String; diff --git a/packages/cw1155/src/query.rs b/packages/cw1155/src/query.rs index 911e207b5..059d18899 100644 --- a/packages/cw1155/src/query.rs +++ b/packages/cw1155/src/query.rs @@ -2,7 +2,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::Uint128; -use utils::Expiration; +use cw_utils::Expiration; use crate::msg::TokenId; diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index 1ba7559ff..95df78df0 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/src/balance.rs b/packages/cw20/src/balance.rs index 17af539e9..e59c0b343 100644 --- a/packages/cw20/src/balance.rs +++ b/packages/cw20/src/balance.rs @@ -3,7 +3,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::fmt; -use utils::NativeBalance; +use cw_utils::NativeBalance; use crate::Cw20CoinVerified; diff --git a/packages/cw20/src/lib.rs b/packages/cw20/src/lib.rs index 125fc682c..f5a142b27 100644 --- a/packages/cw20/src/lib.rs +++ b/packages/cw20/src/lib.rs @@ -1,4 +1,4 @@ -pub use utils::Expiration; +pub use cw_utils::Expiration; pub use crate::balance::Balance; pub use crate::coin::{Cw20Coin, Cw20CoinVerified}; diff --git a/packages/cw20/src/msg.rs b/packages/cw20/src/msg.rs index 16df9e5b6..4a7518b54 100644 --- a/packages/cw20/src/msg.rs +++ b/packages/cw20/src/msg.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use crate::logo::Logo; use cosmwasm_std::{Binary, Uint128}; -use utils::Expiration; +use cw_utils::Expiration; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] diff --git a/packages/cw20/src/query.rs b/packages/cw20/src/query.rs index c697ef61f..747db132a 100644 --- a/packages/cw20/src/query.rs +++ b/packages/cw20/src/query.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{Addr, Binary, Uint128}; use crate::logo::LogoInfo; -use utils::Expiration; +use cw_utils::Expiration; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index 1031b591a..eddc95d4f 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw3/examples/schema.rs b/packages/cw3/examples/schema.rs index 53329e81e..39981fa0b 100644 --- a/packages/cw3/examples/schema.rs +++ b/packages/cw3/examples/schema.rs @@ -7,7 +7,7 @@ use cw3::{ Cw3ExecuteMsg, Cw3QueryMsg, ProposalListResponse, ProposalResponse, VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, }; -use utils::ThresholdResponse; +use cw_utils::ThresholdResponse; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/packages/cw3/src/helpers.rs b/packages/cw3/src/helpers.rs index ba095f3c5..3bc56d10b 100644 --- a/packages/cw3/src/helpers.rs +++ b/packages/cw3/src/helpers.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdResult, WasmMsg}; use crate::msg::{Cw3ExecuteMsg, Vote}; -use utils::Expiration; +use cw_utils::Expiration; /// Cw3Contract is a wrapper around Addr that provides a lot of helpers /// for working with this. diff --git a/packages/cw3/src/msg.rs b/packages/cw3/src/msg.rs index 1abe72740..0811690fb 100644 --- a/packages/cw3/src/msg.rs +++ b/packages/cw3/src/msg.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use std::fmt; use cosmwasm_std::{CosmosMsg, Empty}; -use utils::Expiration; +use cw_utils::Expiration; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] diff --git a/packages/cw3/src/query.rs b/packages/cw3/src/query.rs index ea28e918e..bde729e6c 100644 --- a/packages/cw3/src/query.rs +++ b/packages/cw3/src/query.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use std::fmt; use cosmwasm_std::{CosmosMsg, Empty}; -use utils::{Expiration, ThresholdResponse}; +use cw_utils::{Expiration, ThresholdResponse}; use crate::msg::Vote; diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index bf6c909ae..f29bd906e 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -18,7 +18,7 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0"} cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } cosmwasm-storage = { version = "1.0.0-beta3" } diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index 7af9792e2..b9e22c1a8 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -2441,7 +2441,7 @@ mod test { mod protobuf_wrapped_data { use super::*; use crate::test_helpers::contracts::echo::EXECUTE_REPLY_BASE_ID; - use utils::parse_instantiate_response_data; + use cw_utils::parse_instantiate_response_data; #[test] fn instantiate_wrapped_properly() { diff --git a/packages/multi-test/src/bank.rs b/packages/multi-test/src/bank.rs index f8585ac9c..33b540784 100644 --- a/packages/multi-test/src/bank.rs +++ b/packages/multi-test/src/bank.rs @@ -8,7 +8,7 @@ use cosmwasm_std::{ }; use cosmwasm_storage::{prefixed, prefixed_read}; use cw_storage_plus::Map; -use utils::NativeBalance; +use cw_utils::NativeBalance; use crate::app::CosmosRouter; use crate::executor::AppResponse; diff --git a/packages/multi-test/src/executor.rs b/packages/multi-test/src/executor.rs index 6e1e8678d..4d23082a0 100644 --- a/packages/multi-test/src/executor.rs +++ b/packages/multi-test/src/executor.rs @@ -4,9 +4,9 @@ use cosmwasm_std::{ to_binary, Addr, Attribute, BankMsg, Binary, Coin, CosmosMsg, Event, SubMsgExecutionResponse, WasmMsg, }; +use cw_utils::{parse_execute_response_data, parse_instantiate_response_data}; use schemars::JsonSchema; use serde::Serialize; -use utils::{parse_execute_response_data, parse_instantiate_response_data}; use anyhow::Result as AnyResult; diff --git a/packages/multi-test/src/test_helpers/contracts/echo.rs b/packages/multi-test/src/test_helpers/contracts/echo.rs index cfbd41465..71737d530 100644 --- a/packages/multi-test/src/test_helpers/contracts/echo.rs +++ b/packages/multi-test/src/test_helpers/contracts/echo.rs @@ -13,8 +13,8 @@ use crate::{test_helpers::EmptyMsg, Contract, ContractWrapper}; use schemars::JsonSchema; use std::fmt::Debug; +use cw_utils::{parse_execute_response_data, parse_instantiate_response_data}; use derivative::Derivative; -use utils::{parse_execute_response_data, parse_instantiate_response_data}; // Choosing a reply id less than ECHO_EXECUTE_BASE_ID indicates an Instantiate message reply by convention. // An Execute message reply otherwise. diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index c85f70302..7c920b592 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "utils" +name = "cw-utils" version = "0.11.0" authors = ["Ethan Frey "] edition = "2018" From 0c8cdca9b9fc6b8b70f7214d523adacc5f37ef10 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 22 Dec 2021 23:03:58 +0100 Subject: [PATCH 099/352] Fix linting issues --- contracts/cw1-whitelist-ng/src/contract.rs | 2 +- contracts/cw1-whitelist/src/contract.rs | 2 +- contracts/cw1155-base/src/contract.rs | 8 ++++---- contracts/cw20-atomic-swap/src/state.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/cw1-whitelist-ng/src/contract.rs b/contracts/cw1-whitelist-ng/src/contract.rs index d1b89c619..301b20c96 100644 --- a/contracts/cw1-whitelist-ng/src/contract.rs +++ b/contracts/cw1-whitelist-ng/src/contract.rs @@ -19,7 +19,7 @@ const CONTRACT_NAME: &str = "crates.io:cw1-whitelist"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); pub fn validate_admins(api: &dyn Api, admins: &[String]) -> StdResult> { - admins.iter().map(|addr| api.addr_validate(&addr)).collect() + admins.iter().map(|addr| api.addr_validate(addr)).collect() } impl Cw1WhitelistContract { diff --git a/contracts/cw1-whitelist/src/contract.rs b/contracts/cw1-whitelist/src/contract.rs index c786b53d6..c7c8784fb 100644 --- a/contracts/cw1-whitelist/src/contract.rs +++ b/contracts/cw1-whitelist/src/contract.rs @@ -36,7 +36,7 @@ pub fn instantiate( } pub fn map_validate(api: &dyn Api, admins: &[String]) -> StdResult> { - admins.iter().map(|addr| api.addr_validate(&addr)).collect() + admins.iter().map(|addr| api.addr_validate(addr)).collect() } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/cw1155-base/src/contract.rs b/contracts/cw1155-base/src/contract.rs index 611d3e41c..761b34094 100644 --- a/contracts/cw1155-base/src/contract.rs +++ b/contracts/cw1155-base/src/contract.rs @@ -133,7 +133,7 @@ fn check_can_approve(deps: Deps, env: &Env, owner: &Addr, operator: &Addr) -> St return Ok(true); } // operator can approve - let op = APPROVES.may_load(deps.storage, (&owner, &operator))?; + let op = APPROVES.may_load(deps.storage, (owner, operator))?; Ok(match op { Some(ex) => !ex.is_expired(&env.block), None => false, @@ -325,13 +325,13 @@ pub fn execute_batch_mint( let mut rsp = Response::default(); for (token_id, amount) in batch.iter() { - let event = execute_transfer_inner(&mut deps, None, Some(&to_addr), &token_id, *amount)?; + let event = execute_transfer_inner(&mut deps, None, Some(&to_addr), token_id, *amount)?; event.add_attributes(&mut rsp); // insert if not exist - if !TOKENS.has(deps.storage, &token_id) { + if !TOKENS.has(deps.storage, token_id) { // we must save some valid data here - TOKENS.save(deps.storage, &token_id, &String::new())?; + TOKENS.save(deps.storage, token_id, &String::new())?; } } diff --git a/contracts/cw20-atomic-swap/src/state.rs b/contracts/cw20-atomic-swap/src/state.rs index 0a1202630..de231bd74 100644 --- a/contracts/cw20-atomic-swap/src/state.rs +++ b/contracts/cw20-atomic-swap/src/state.rs @@ -19,7 +19,7 @@ pub struct AtomicSwap { impl AtomicSwap { pub fn is_expired(&self, block: &BlockInfo) -> bool { - self.expires.is_expired(&block) + self.expires.is_expired(block) } } From c662f2253e46eda21a3b1f3b3013d981951a7adc Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 23 Dec 2021 09:52:02 +0100 Subject: [PATCH 100/352] Fix cw-utils README entry --- MIGRATING.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index c8da916c3..a84f80008 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -8,7 +8,7 @@ This guide lists API changes between *cw-plus* major releases. - Rename cw0 to utils [\#471](https://github.com/CosmWasm/cw-plus/issues/471) / Cw0 rename [\#508](https://github.com/CosmWasm/cw-plus/pull/508) -The `cw0` package was renamed to `utils`. The required changes are straightforward: +The `cw0` package was renamed to `cw-utils`. The required changes are straightforward: ```diff diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml diff --git a/README.md b/README.md index 6e088d295..6f5ff52d3 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ | cw-controllers | [![cw-controllers on crates.io](https://img.shields.io/crates/v/cw-controllers.svg)](https://crates.io/crates/cw-controllers) | [![Docs](https://docs.rs/cw-controllers/badge.svg)](https://docs.rs/cw-controllers) | | cw-multi-test | [![cw-multi-test on crates.io](https://img.shields.io/crates/v/cw-multi-test.svg)](https://crates.io/crates/cw-multi-test) | [![Docs](https://docs.rs/cw-multi-test/badge.svg)](https://docs.rs/cw-multi-test) | | cw-storage-plus | [![cw-storage-plus on crates.io](https://img.shields.io/crates/v/cw-storage-plus.svg)](https://crates.io/crates/cw-storage-plus) | [![Docs](https://docs.rs/cw-storage-plus/badge.svg)](https://docs.rs/cw-storage-plus) | -| utils | [![utils on crates.io](https://img.shields.io/crates/v/utils.svg)](https://crates.io/crates/utils) | [![Docs](https://docs.rs/utils/badge.svg)](https://docs.rs/utils) | +| cw-utils | [![cw-utils on crates.io](https://img.shields.io/crates/v/cw-utils.svg)](https://crates.io/crates/cw-utils) | [![Docs](https://docs.rs/cw-utils/badge.svg)](https://docs.rs/cw-utils) | | Contracts | Download | Docs | | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------| From 919cd5b1e08327af420b34ebf53c8e181286dfd9 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 23 Dec 2021 11:26:41 +0100 Subject: [PATCH 101/352] Adjust order of publishing to handle new deps --- scripts/publish.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index 74b2c98f4..ff3f1719b 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -8,9 +8,12 @@ STORAGE_PACKAGES="storage-plus" BASE_PACKAGES="utils" ALL_PACKAGES="controllers cw1 cw2 cw3 cw4 cw20 cw1155 multi-test" +# This is imported by cw3-fixed-multisig, which is imported by cw3-flex-multisig +# need to make a separate category to remove race conditions +CW20_BASE="cw20-base" # these are imported by other contracts -BASE_CONTRACTS="cw1-whitelist cw4-group cw20-base" -ALL_CONTRACTS="cw1-subkeys cw3-fixed-multisig cw3-flex-multisig cw4-stake cw20-atomic-swap cw20-bonding cw20-escrow cw20-ics20 cw20-staking cw1155-base" +BASE_CONTRACTS="cw1-whitelist cw4-group cw3-fixed-multisig " +ALL_CONTRACTS="cw1-subkeys cw3-flex-multisig cw4-stake cw20-atomic-swap cw20-bonding cw20-escrow cw20-ics20 cw20-staking cw1155-base" SLEEP_TIME=30 @@ -46,10 +49,23 @@ for pack in $ALL_PACKAGES; do ) done + # wait for these to be processed on crates.io echo "Waiting for publishing all packages" sleep $SLEEP_TIME +for cont in CW20_BASE; do + ( + cd "contracts/$cont" + echo "Publishing $cont" + cargo publish + ) +done + +# wait for these to be processed on crates.io +echo "Waiting for publishing cw20 base" +sleep $SLEEP_TIME + for cont in $BASE_CONTRACTS; do ( cd "contracts/$cont" @@ -59,7 +75,7 @@ for cont in $BASE_CONTRACTS; do done # wait for these to be processed on crates.io -echo "Waiting for publishing base packages" +echo "Waiting for publishing base contracts" sleep $SLEEP_TIME for cont in $ALL_CONTRACTS; do From fb94db8c740e4458f9ccf3fd2d43afce6cb54f07 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 23 Dec 2021 10:04:48 +0100 Subject: [PATCH 102/352] Change breaking changes migration order --- MIGRATING.md | 92 ++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index a84f80008..fa9df0a16 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -6,6 +6,52 @@ This guide lists API changes between *cw-plus* major releases. ### Breaking Issues / PRs +- Incorrect I32Key Index Ordering [\#489](https://github.com/CosmWasm/cw-plus/issues/489) / + Signed int keys order [\#582](https://github.com/CosmWasm/cw-plus/pull/582) + +As part of range iterators revamping, we fixed the order of signed integer keys. You shouldn't change anything in your +code base for this, but if you were using signed keys and relying on their ordering, that has now changed for the better. +Take into account also that **the internal representation of signed integer keys has changed**. So, if you +have data stored under signed integer keys you would need to **migrate it**, or recreate it under the new representation. + +As part of this, a couple helpers for handling int keys serialization and deserialization were introduced: +- `from_cw_bytes` Integer (signed and unsigned) values deserialization. +- `to_cw_bytes` - Integer (signed and unsigned) values serialization. + +You shouldn't need these, except when manually handling raw integer keys serialization / deserialization. + +Migration code example: +```rust +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + let version = get_contract_version(deps.storage)?; + if version.contract != CONTRACT_NAME { + return Err(ContractError::CannotMigrate { + previous_contract: version.contract, + }); + } + // Original map + signed_int_map: Map = Map::new("signed_int_map"); + // New map + signed_int_map_new: Map = Map::new("signed_int_map-v2"); + + signed_int_map + .range_raw(deps.storage, None, None, Order::Ascending) + .map(|(k, v)| { + let signed = i8::from_be_bytes(k); + signed_int_map_new.save(deps.storage, signed, v); + }) + .collect()?; + + // Code to remove the old map keys + ... + + Ok(Response::default()) +} +``` + +--- + - Rename cw0 to utils [\#471](https://github.com/CosmWasm/cw-plus/issues/471) / Cw0 rename [\#508](https://github.com/CosmWasm/cw-plus/pull/508) The `cw0` package was renamed to `cw-utils`. The required changes are straightforward: @@ -193,52 +239,6 @@ index 022a4504..c7a3bb9d 100644 --- -- Incorrect I32Key Index Ordering [\#489](https://github.com/CosmWasm/cw-plus/issues/489) / -Signed int keys order [\#582](https://github.com/CosmWasm/cw-plus/pull/582) - -As part of range iterators revamping, we fixed the order of signed integer keys. You shouldn't change anything in your -code base for this, but if you were using signed keys and relying on their ordering, that has now changed for the better. -Take into account also that **the internal representation of signed integer keys has changed**. So, if you -have data stored under signed integer keys you would need to **migrate it**, or recreate it under the new representation. - -As part of this, a couple helpers for handling int keys serialization and deserialization were introduced: - - `from_cw_bytes` Integer (signed and unsigned) values deserialization. - - `to_cw_bytes` - Integer (signed and unsigned) values serialization. - -You shouldn't need these, except when manually handling raw integer keys serialization / deserialization. - -Migration code example: -```rust -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { - let version = get_contract_version(deps.storage)?; - if version.contract != CONTRACT_NAME { - return Err(ContractError::CannotMigrate { - previous_contract: version.contract, - }); - } - // Original map - signed_int_map: Map = Map::new("signed_int_map"); - // New map - signed_int_map_new: Map = Map::new("signed_int_map-v2"); - - signed_int_map - .range_raw(deps.storage, None, None, Order::Ascending) - .map(|(k, v)| { - let signed = i8::from_be_bytes(k); - signed_int_map_new.save(deps.storage, signed, v); - }) - .collect()?; - - // Code to remove the old map keys - ... - - Ok(Response::default()) -} -``` - ---- - - `cw3-fixed-multisig` requires threshold during instantiation instead of `required_weight` parameter `Threshold` type was moved to `packages/utils` along with surrounding implementations like `ThresholdResponse` etc. From 35a987e84017727042b2ff4a1c6f97d9d882ca26 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 23 Dec 2021 10:51:55 +0100 Subject: [PATCH 103/352] Add old IntKey types to allow migration --- packages/storage-plus/src/de_old.rs | 106 ++++++++++++++++++++++++++ packages/storage-plus/src/keys_old.rs | 88 +++++++++++++++++++++ packages/storage-plus/src/lib.rs | 2 + 3 files changed, 196 insertions(+) create mode 100644 packages/storage-plus/src/de_old.rs create mode 100644 packages/storage-plus/src/keys_old.rs diff --git a/packages/storage-plus/src/de_old.rs b/packages/storage-plus/src/de_old.rs new file mode 100644 index 000000000..e8c5f529d --- /dev/null +++ b/packages/storage-plus/src/de_old.rs @@ -0,0 +1,106 @@ +use std::array::TryFromSliceError; +use std::convert::TryInto; + +use cosmwasm_std::{StdError, StdResult}; + +use crate::de::KeyDeserialize; +use crate::keys_old::IntKeyOld; + +macro_rules! intkey_old_de { + (for $($t:ty),+) => { + $(impl KeyDeserialize for IntKeyOld<$t> { + type Output = $t; + + #[inline(always)] + fn from_vec(value: Vec) -> StdResult { + Ok(<$t>::from_be_bytes(value.as_slice().try_into() + .map_err(|err: TryFromSliceError| StdError::generic_err(err.to_string()))?)) + } + })* + } +} + +intkey_old_de!(for i8, u8, i16, u16, i32, u32, i64, u64, i128, u128); + +#[cfg(test)] +mod test { + use super::*; + use crate::keys_old::IntKeyOld; + + #[test] + fn deserialize_integer_old_works() { + assert_eq!(>::from_slice(&[1]).unwrap(), 1u8); + assert_eq!(>::from_slice(&[127]).unwrap(), 127i8); + assert_eq!(>::from_slice(&[128]).unwrap(), -128i8); + + assert_eq!(>::from_slice(&[1, 0]).unwrap(), 256u16); + assert_eq!(>::from_slice(&[128, 0]).unwrap(), -32768i16); + assert_eq!(>::from_slice(&[127, 255]).unwrap(), 32767i16); + + assert_eq!( + >::from_slice(&[1, 0, 0, 0]).unwrap(), + 16777216u32 + ); + assert_eq!( + >::from_slice(&[128, 0, 0, 0]).unwrap(), + -2147483648i32 + ); + assert_eq!( + >::from_slice(&[127, 255, 255, 255]).unwrap(), + 2147483647i32 + ); + + assert_eq!( + >::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0]).unwrap(), + 72057594037927936u64 + ); + assert_eq!( + >::from_slice(&[128, 0, 0, 0, 0, 0, 0, 0]).unwrap(), + -9223372036854775808i64 + ); + assert_eq!( + >::from_slice(&[127, 255, 255, 255, 255, 255, 255, 255]).unwrap(), + 9223372036854775807i64 + ); + + assert_eq!( + >::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + .unwrap(), + 1329227995784915872903807060280344576u128 + ); + assert_eq!( + >::from_slice(&[128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + .unwrap(), + -170141183460469231731687303715884105728i128 + ); + assert_eq!( + >::from_slice(&[ + 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 + ]) + .unwrap(), + 170141183460469231731687303715884105727i128 + ); + assert_eq!( + >::from_slice(&[ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 + ]) + .unwrap(), + -1i128, + ); + } + + #[test] + fn deserialize_broken_integer_old_errs() { + // One byte less fails + assert!(matches!( + >::from_slice(&[1]).err(), + Some(StdError::GenericErr { .. }) + )); + + // More bytes fails too + assert!(matches!( + >::from_slice(&[1, 2]).err(), + Some(StdError::GenericErr { .. }) + )); + } +} diff --git a/packages/storage-plus/src/keys_old.rs b/packages/storage-plus/src/keys_old.rs new file mode 100644 index 000000000..0726f068d --- /dev/null +++ b/packages/storage-plus/src/keys_old.rs @@ -0,0 +1,88 @@ +use crate::de::KeyDeserialize; +use crate::keys::Key; +use crate::{Endian, Prefixer, PrimaryKey}; +use std::marker::PhantomData; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct IntKeyOld { + pub wrapped: Vec, + pub data: PhantomData, +} + +impl IntKeyOld { + pub fn new(val: T) -> Self { + IntKeyOld { + wrapped: val.to_be_bytes().into(), + data: PhantomData, + } + } +} + +impl From for IntKeyOld { + fn from(val: T) -> Self { + IntKeyOld::new(val) + } +} + +impl From> for IntKeyOld { + fn from(wrap: Vec) -> Self { + IntKeyOld { + wrapped: wrap, + data: PhantomData, + } + } +} + +impl From> for Vec { + fn from(k: IntKeyOld) -> Vec { + k.wrapped + } +} + +// this auto-implements PrimaryKey for all the IntKeyOld types +impl<'a, T: Endian + Clone> PrimaryKey<'a> for IntKeyOld +where + IntKeyOld: KeyDeserialize, +{ + type Prefix = (); + type SubPrefix = (); + type Suffix = Self; + type SuperSuffix = Self; + + fn key(&self) -> Vec { + self.wrapped.key() + } +} + +// this auto-implements Prefixer for all the IntKey types +impl<'a, T: Endian> Prefixer<'a> for IntKeyOld { + fn prefix(&self) -> Vec { + self.wrapped.prefix() + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn u64key_old_works() { + let k: IntKeyOld = 134u64.into(); + let path = k.key(); + assert_eq!(1, path.len()); + assert_eq!(134u64.to_be_bytes(), path[0].as_ref()); + } + + #[test] + fn i32key_old_works() { + let k: IntKeyOld = 4242i32.into(); + let path = k.key(); + assert_eq!(1, path.len()); + assert_eq!(4242i32.to_be_bytes(), path[0].as_ref()); + + // let k: IntKeyOld = -4242i32.into(); + // let path = k.key(); + // assert_eq!(1, path.len()); + // assert_eq!((-4242i32).to_be_bytes(), path[0].as_ref()); + } +} diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 77665e2f7..7fa68106f 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -1,4 +1,5 @@ mod de; +mod de_old; mod endian; mod helpers; mod indexed_map; @@ -8,6 +9,7 @@ mod int_key; mod item; mod iter_helpers; mod keys; +mod keys_old; mod map; mod path; mod prefix; From f6564ca3ce843d04d098fb6b1cd7609b3e660dbe Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 23 Dec 2021 11:24:34 +0100 Subject: [PATCH 104/352] Add signed int key `Map` migration test / example --- packages/storage-plus/src/map.rs | 74 ++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 5bb9e91e5..a04015465 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -255,6 +255,7 @@ mod test { use cosmwasm_std::{Order, StdResult}; use crate::int_key::CwIntKey; + use crate::keys_old::IntKeyOld; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] struct Data { @@ -266,6 +267,8 @@ mod test { #[cfg(feature = "iterator")] const PEOPLE_ID: Map = Map::new("people_id"); #[cfg(feature = "iterator")] + const SIGNED_ID_OLD: Map, Data> = Map::new("signed_id"); + #[cfg(feature = "iterator")] const SIGNED_ID: Map = Map::new("signed_id"); const ALLOWANCE: Map<(&[u8], &[u8]), u64> = Map::new("allow"); @@ -635,6 +638,77 @@ mod test { assert_eq!(all, vec![(50, data3)]); } + #[test] + #[cfg(feature = "iterator")] + fn range_signed_integer_key_migration() { + let mut store = MockStorage::new(); + + // save and load three keys with the old format + let data = Data { + name: "John".to_string(), + age: 32, + }; + SIGNED_ID_OLD + .save(&mut store, IntKeyOld::::from(-1234), &data) + .unwrap(); + + let data2 = Data { + name: "Jim".to_string(), + age: 44, + }; + SIGNED_ID_OLD + .save(&mut store, IntKeyOld::::from(-56), &data2) + .unwrap(); + + let data3 = Data { + name: "Jules".to_string(), + age: 55, + }; + SIGNED_ID_OLD + .save(&mut store, IntKeyOld::::from(50), &data3) + .unwrap(); + + // obtain all current keys + let current = SIGNED_ID_OLD + .range(&store, None, None, Order::Ascending) + .collect::>>() + .unwrap(); + // confirm wrong current order + assert_eq!( + current, + vec![ + (50, data3.clone()), + (-1234, data.clone()), + (-56, data2.clone()) + ] + ); + + // remove old entries + for (k, _) in current.iter() { + SIGNED_ID_OLD.remove(&mut store, IntKeyOld::::from(*k)); + } + + // confirm map is empty + assert!(SIGNED_ID_OLD + .range(&store, None, None, Order::Ascending) + .collect::>>() + .unwrap() + .is_empty()); + + // save in new format + for (k, v) in current.iter() { + SIGNED_ID.save(&mut store, *k, v).unwrap(); + } + + // obtain new keys + let new = SIGNED_ID + .range(&store, None, None, Order::Ascending) + .collect::>>() + .unwrap(); + // confirm new order is right + assert_eq!(new, vec![(-1234, data), (-56, data2), (50, data3)]); + } + #[test] #[cfg(feature = "iterator")] fn range_raw_composite_key() { From cfcefd03f7ea14eed49dcf458314ef6585b6d3de Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 23 Dec 2021 12:23:13 +0100 Subject: [PATCH 105/352] Publish `IntKeyOld` --- packages/storage-plus/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 7fa68106f..841700f51 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -34,6 +34,7 @@ pub use keys::{I128Key, I16Key, I32Key, I64Key, I8Key}; pub use int_key::CwIntKey; #[allow(deprecated)] pub use keys::{Prefixer, PrimaryKey, U128Key, U16Key, U32Key, U64Key, U8Key}; +pub use keys_old::IntKeyOld; pub use map::Map; pub use path::Path; #[cfg(feature = "iterator")] From db3856205cb9616e5ff857955a6f2fc88379068b Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 23 Dec 2021 12:23:45 +0100 Subject: [PATCH 106/352] Update MIGRATING.md signed int keys migration code --- MIGRATING.md | 81 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index fa9df0a16..b625219fe 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -23,30 +23,65 @@ You shouldn't need these, except when manually handling raw integer keys seriali Migration code example: ```rust #[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { - let version = get_contract_version(deps.storage)?; - if version.contract != CONTRACT_NAME { - return Err(ContractError::CannotMigrate { - previous_contract: version.contract, - }); - } +pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result { + let version: Version = CONTRACT_VERSION.parse()?; + let storage_version: Version = get_contract_version(deps.storage)?.version.parse()?; + + if storage_version < version { + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + + // Do the migration // Original map - signed_int_map: Map = Map::new("signed_int_map"); - // New map - signed_int_map_new: Map = Map::new("signed_int_map-v2"); - - signed_int_map - .range_raw(deps.storage, None, None, Order::Ascending) - .map(|(k, v)| { - let signed = i8::from_be_bytes(k); - signed_int_map_new.save(deps.storage, signed, v); - }) - .collect()?; - - // Code to remove the old map keys - ... - - Ok(Response::default()) + let signed_int_map: Map, String> = Map::new("signed_int_map"); + + // New map (using a different namespace for safety. It could be the same with enough care) + let signed_int_map_new: Map = Map::new("signed_int_map-v2"); + + // Obtain all current keys (this will need to be paginated if there are many entries, + // i.e. i32 or i64 instead of i8). + // This may be gas intensive + let current = signed_int_map + .range(deps.storage, None, None, Order::Ascending) + .collect::>>()?; + + // Store length for quality control (adjust if paginated) + let current_count = current.len(); + + // Remove the old map keys + for (k, _) in current.iter() { + signed_int_map.remove(deps.storage, IntKeyOld::::from(*k)); + } + + // Save in new format + for (k, v) in current.iter() { + signed_int_map_new.save(deps.storage, *k, v)?; + } + + // Confirm old map is empty + if signed_int_map + .keys_raw(deps.storage, None, None, Order::Ascending) + .next() + .is_some() + { + return Err(StdError::generic_err("Original still not empty!").into()); + } + + // Obtain new keys, and confirm their amount. + // May be gas intensive. + let new_count = signed_int_map_new + .keys_raw(deps.storage, None, None, Order::Ascending) + .count(); + + if current_count != new_count { + return Err(StdError::generic_err(format!( + "Current ({}) and new ({}) counts differ!", + current_count, new_count + )) + .into()); + } + } + + Ok(Response::new()) } ``` From 036beb1b26c6221c35e14635a0eba9e777b49009 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 23 Dec 2021 12:32:48 +0100 Subject: [PATCH 107/352] Add negative integer int key check --- packages/storage-plus/src/keys_old.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/storage-plus/src/keys_old.rs b/packages/storage-plus/src/keys_old.rs index 0726f068d..d864153e2 100644 --- a/packages/storage-plus/src/keys_old.rs +++ b/packages/storage-plus/src/keys_old.rs @@ -80,9 +80,9 @@ mod test { assert_eq!(1, path.len()); assert_eq!(4242i32.to_be_bytes(), path[0].as_ref()); - // let k: IntKeyOld = -4242i32.into(); - // let path = k.key(); - // assert_eq!(1, path.len()); - // assert_eq!((-4242i32).to_be_bytes(), path[0].as_ref()); + let k: IntKeyOld = IntKeyOld::::from(-4242i32); + let path = k.key(); + assert_eq!(1, path.len()); + assert_eq!((-4242i32).to_be_bytes(), path[0].as_ref()); } } From 330c14bcb66407ed1eeb2f82da84a6732f0a0cb3 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 23 Dec 2021 14:13:50 +0100 Subject: [PATCH 108/352] Improve migration code examples --- MIGRATING.md | 6 +++--- packages/storage-plus/src/map.rs | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index b625219fe..ea5b67c8d 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -49,12 +49,12 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result::from(*k)); + signed_int_map.remove(deps.storage, (*k).into()); } // Save in new format - for (k, v) in current.iter() { - signed_int_map_new.save(deps.storage, *k, v)?; + for (k, v) in current.into_iter() { + signed_int_map_new.save(deps.storage, k, &v)?; } // Confirm old map is empty diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index a04015465..94d78bdcd 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -685,19 +685,18 @@ mod test { // remove old entries for (k, _) in current.iter() { - SIGNED_ID_OLD.remove(&mut store, IntKeyOld::::from(*k)); + SIGNED_ID_OLD.remove(&mut store, (*k).into()); } // confirm map is empty assert!(SIGNED_ID_OLD .range(&store, None, None, Order::Ascending) - .collect::>>() - .unwrap() - .is_empty()); + .next() + .is_none()); // save in new format - for (k, v) in current.iter() { - SIGNED_ID.save(&mut store, *k, v).unwrap(); + for (k, v) in current.into_iter() { + SIGNED_ID.save(&mut store, k, &v).unwrap(); } // obtain new keys From 5101d722a1f03305403bb8ce8202f9370f308b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20K=C3=BCl=C3=A7e?= Date: Fri, 24 Dec 2021 17:27:49 +0300 Subject: [PATCH 109/352] Add scheduled util --- packages/utils/src/lib.rs | 1 + packages/utils/src/scheduled.rs | 63 +++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 packages/utils/src/scheduled.rs diff --git a/packages/utils/src/lib.rs b/packages/utils/src/lib.rs index c39b1005e..28ce11734 100644 --- a/packages/utils/src/lib.rs +++ b/packages/utils/src/lib.rs @@ -4,6 +4,7 @@ mod expiration; mod pagination; mod parse_reply; mod payment; +mod scheduled; mod threshold; pub use pagination::{ diff --git a/packages/utils/src/scheduled.rs b/packages/utils/src/scheduled.rs new file mode 100644 index 000000000..5e6d5617b --- /dev/null +++ b/packages/utils/src/scheduled.rs @@ -0,0 +1,63 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use crate::Duration; +use cosmwasm_std::{BlockInfo, StdError, StdResult, Timestamp}; +use std::cmp::Ordering; +use std::fmt; +use std::ops::Add; + +#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +/// Scheduled represents a point in time when an event happens. +/// It can compare with a BlockInfo and will return is_triggered() == true +/// once the condition is hit (and for every block in the future) +pub enum Scheduled { + /// AtHeight will schedule when `env.block.height` >= height + AtHeight(u64), + /// AtTime will schedule when `env.block.time` >= time + AtTime(Timestamp), +} + +impl fmt::Display for Scheduled { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Scheduled::AtHeight(height) => write!(f, "scheduled height: {}", height), + Scheduled::AtTime(time) => write!(f, "scheduled time: {}", time), + } + } +} + +impl Scheduled { + pub fn is_triggered(&self, block: &BlockInfo) -> bool { + match self { + Scheduled::AtHeight(height) => block.height >= *height, + Scheduled::AtTime(time) => block.time >= *time, + } + } +} + +impl Add for Scheduled { + type Output = StdResult; + + fn add(self, duration: Duration) -> StdResult { + match (self, duration) { + (Scheduled::AtTime(t), Duration::Time(delta)) => { + Ok(Scheduled::AtTime(t.plus_seconds(delta))) + } + (Scheduled::AtHeight(h), Duration::Height(delta)) => Ok(Scheduled::AtHeight(h + delta)), + _ => Err(StdError::generic_err("Cannot add height and time")), + } + } +} + +impl PartialOrd for Scheduled { + fn partial_cmp(&self, other: &Scheduled) -> Option { + match (self, other) { + // compare if both height or both time + (Scheduled::AtHeight(h1), Scheduled::AtHeight(h2)) => Some(h1.cmp(h2)), + (Scheduled::AtTime(t1), Scheduled::AtTime(t2)) => Some(t1.cmp(t2)), + _ => None, + } + } +} From 56ee692ba3280847f62d85d607cf7ef32101ba66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20K=C3=BCl=C3=A7e?= Date: Fri, 24 Dec 2021 17:37:12 +0300 Subject: [PATCH 110/352] Linter happy --- packages/utils/src/lib.rs | 1 + packages/utils/src/scheduled.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/utils/src/lib.rs b/packages/utils/src/lib.rs index 28ce11734..4687606d9 100644 --- a/packages/utils/src/lib.rs +++ b/packages/utils/src/lib.rs @@ -21,3 +21,4 @@ pub use threshold::{Threshold, ThresholdError, ThresholdResponse}; pub use crate::balance::NativeBalance; pub use crate::event::Event; pub use crate::expiration::{Duration, Expiration, DAY, HOUR, WEEK}; +pub use crate::scheduled::Scheduled; diff --git a/packages/utils/src/scheduled.rs b/packages/utils/src/scheduled.rs index 5e6d5617b..81a4c049e 100644 --- a/packages/utils/src/scheduled.rs +++ b/packages/utils/src/scheduled.rs @@ -29,6 +29,7 @@ impl fmt::Display for Scheduled { } impl Scheduled { + #[allow(dead_code)] pub fn is_triggered(&self, block: &BlockInfo) -> bool { match self { Scheduled::AtHeight(height) => block.height >= *height, From 1dd531d66c7164c73c2373ab402facd57b382679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20K=C3=BCl=C3=A7e?= Date: Sun, 26 Dec 2021 19:08:27 +0300 Subject: [PATCH 111/352] cw-storage-plus: Expose keys::Key --- packages/storage-plus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 841700f51..ad6eb0fae 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -33,7 +33,7 @@ pub use keys::{I128Key, I16Key, I32Key, I64Key, I8Key}; // TODO: Remove along with `IntKey` pub use int_key::CwIntKey; #[allow(deprecated)] -pub use keys::{Prefixer, PrimaryKey, U128Key, U16Key, U32Key, U64Key, U8Key}; +pub use keys::{Prefixer, PrimaryKey, U128Key, U16Key, U32Key, U64Key, U8Key, Key}; pub use keys_old::IntKeyOld; pub use map::Map; pub use path::Path; From 37af252f3f19088d36b1295486d618c7ad81fc5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20K=C3=BCl=C3=A7e?= Date: Sun, 26 Dec 2021 19:09:31 +0300 Subject: [PATCH 112/352] Fmt --- packages/storage-plus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index ad6eb0fae..e054879cf 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -33,7 +33,7 @@ pub use keys::{I128Key, I16Key, I32Key, I64Key, I8Key}; // TODO: Remove along with `IntKey` pub use int_key::CwIntKey; #[allow(deprecated)] -pub use keys::{Prefixer, PrimaryKey, U128Key, U16Key, U32Key, U64Key, U8Key, Key}; +pub use keys::{Key, Prefixer, PrimaryKey, U128Key, U16Key, U32Key, U64Key, U8Key}; pub use keys_old::IntKeyOld; pub use map::Map; pub use path::Path; From 0c1237c2e112a7b50de1d72bf38bb48a01dbc8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20K=C3=BCl=C3=A7e?= Date: Tue, 28 Dec 2021 13:06:18 +0300 Subject: [PATCH 113/352] Test addition and compare --- packages/utils/src/scheduled.rs | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/packages/utils/src/scheduled.rs b/packages/utils/src/scheduled.rs index 81a4c049e..6b7f26227 100644 --- a/packages/utils/src/scheduled.rs +++ b/packages/utils/src/scheduled.rs @@ -62,3 +62,59 @@ impl PartialOrd for Scheduled { } } } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn compare_schedules() { + // matching pairs + assert!(Scheduled::AtHeight(5) < Scheduled::AtHeight(10)); + assert!(Scheduled::AtHeight(8) > Scheduled::AtHeight(7)); + assert!( + Scheduled::AtTime(Timestamp::from_seconds(555)) + < Scheduled::AtTime(Timestamp::from_seconds(777)) + ); + assert!( + Scheduled::AtTime(Timestamp::from_seconds(86)) + < Scheduled::AtTime(Timestamp::from_seconds(100)) + ); + + // what happens for the uncomparables?? all compares are false + assert_eq!( + None, + Scheduled::AtTime(Timestamp::from_seconds(1000)) + .partial_cmp(&Scheduled::AtHeight(230)) + ); + assert_eq!( + Scheduled::AtTime(Timestamp::from_seconds(1000)) + .partial_cmp(&Scheduled::AtHeight(230)), + None + ); + assert_eq!( + Scheduled::AtTime(Timestamp::from_seconds(1000)) + .partial_cmp(&Scheduled::AtHeight(230)), + None + ); + assert!(!(Scheduled::AtTime(Timestamp::from_seconds(1000)) == Scheduled::AtHeight(230))); + } + + #[test] + fn schedule_addition() { + // height + let end = Scheduled::AtHeight(12345) + Duration::Height(400); + assert_eq!(end.unwrap(), Scheduled::AtHeight(12745)); + + // time + let end = Scheduled::AtTime(Timestamp::from_seconds(55544433)) + Duration::Time(40300); + assert_eq!( + end.unwrap(), + Scheduled::AtTime(Timestamp::from_seconds(55584733)) + ); + + // mismatched + let end = Scheduled::AtHeight(12345) + Duration::Time(1500); + end.unwrap_err(); + } +} From 37a2fe2b90193d13b4d4d07e176cbcc94a857336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20K=C3=BCl=C3=A7e?= Date: Tue, 28 Dec 2021 13:25:43 +0300 Subject: [PATCH 114/352] Fmt --- packages/utils/src/scheduled.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/utils/src/scheduled.rs b/packages/utils/src/scheduled.rs index 6b7f26227..c8c6ca4bb 100644 --- a/packages/utils/src/scheduled.rs +++ b/packages/utils/src/scheduled.rs @@ -84,17 +84,14 @@ mod test { // what happens for the uncomparables?? all compares are false assert_eq!( None, - Scheduled::AtTime(Timestamp::from_seconds(1000)) - .partial_cmp(&Scheduled::AtHeight(230)) + Scheduled::AtTime(Timestamp::from_seconds(1000)).partial_cmp(&Scheduled::AtHeight(230)) ); assert_eq!( - Scheduled::AtTime(Timestamp::from_seconds(1000)) - .partial_cmp(&Scheduled::AtHeight(230)), + Scheduled::AtTime(Timestamp::from_seconds(1000)).partial_cmp(&Scheduled::AtHeight(230)), None ); assert_eq!( - Scheduled::AtTime(Timestamp::from_seconds(1000)) - .partial_cmp(&Scheduled::AtHeight(230)), + Scheduled::AtTime(Timestamp::from_seconds(1000)).partial_cmp(&Scheduled::AtHeight(230)), None ); assert!(!(Scheduled::AtTime(Timestamp::from_seconds(1000)) == Scheduled::AtHeight(230))); From 57aa23a6315e1be5d5efd6e6a7031a9987c910d2 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 28 Dec 2021 17:40:21 +0100 Subject: [PATCH 115/352] Assert non-empty send/burn/mint in multitest bank module --- packages/multi-test/src/bank.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/multi-test/src/bank.rs b/packages/multi-test/src/bank.rs index 33b540784..30b047737 100644 --- a/packages/multi-test/src/bank.rs +++ b/packages/multi-test/src/bank.rs @@ -84,6 +84,7 @@ impl BankKeeper { to_address: Addr, amount: Vec, ) -> AnyResult<()> { + let amount = self.normalize_amount(amount)?; let b = self.get_balance(bank_storage, &to_address)?; let b = NativeBalance(b) + NativeBalance(amount); self.set_balance(bank_storage, &to_address, b.into_vec()) @@ -95,10 +96,21 @@ impl BankKeeper { from_address: Addr, amount: Vec, ) -> AnyResult<()> { + let amount = self.normalize_amount(amount)?; let a = self.get_balance(bank_storage, &from_address)?; let a = (NativeBalance(a) - amount)?; self.set_balance(bank_storage, &from_address, a.into_vec()) } + + /// Filters out all 0 value coins and returns an error if the resulting Vec is empty + fn normalize_amount(&self, amount: Vec) -> AnyResult> { + let res: Vec<_> = amount.into_iter().filter(|x| !x.amount.is_zero()).collect(); + if res.is_empty() { + bail!("Cannot transfer empty coins amount") + } else { + Ok(res) + } + } } fn coins_to_string(coins: &[Coin]) -> String { From 9c4c2745c5b96959e90ccfb0d5997b42aa420d59 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 28 Dec 2021 17:48:21 +0100 Subject: [PATCH 116/352] Test 0 values return errors --- packages/multi-test/src/bank.rs | 75 +++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/packages/multi-test/src/bank.rs b/packages/multi-test/src/bank.rs index 30b047737..17cea14fa 100644 --- a/packages/multi-test/src/bank.rs +++ b/packages/multi-test/src/bank.rs @@ -395,4 +395,79 @@ mod test { .unwrap_err(); assert!(matches!(err.downcast().unwrap(), StdError::Overflow { .. })); } + + #[test] + fn fail_on_zero_values() { + let api = MockApi::default(); + let mut store = MockStorage::new(); + let block = mock_env().block; + let router = MockRouter::default(); + + let owner = Addr::unchecked("owner"); + let rcpt = Addr::unchecked("recipient"); + let init_funds = vec![coin(5000, "atom"), coin(100, "eth")]; + + // set money + let bank = BankKeeper::new(); + bank.init_balance(&mut store, &owner, init_funds).unwrap(); + + // can send normal amounts + let msg = BankMsg::Send { + to_address: rcpt.to_string(), + amount: coins(100, "atom"), + }; + bank.execute(&api, &mut store, &router, &block, owner.clone(), msg) + .unwrap(); + + // fails send on no coins + let msg = BankMsg::Send { + to_address: rcpt.to_string(), + amount: vec![], + }; + bank.execute(&api, &mut store, &router, &block, owner.clone(), msg) + .unwrap_err(); + + // fails send on 0 coins + let msg = BankMsg::Send { + to_address: rcpt.to_string(), + amount: coins(0, "atom"), + }; + bank.execute(&api, &mut store, &router, &block, owner.clone(), msg) + .unwrap_err(); + + // fails burn on no coins + let msg = BankMsg::Burn { amount: vec![] }; + bank.execute(&api, &mut store, &router, &block, owner.clone(), msg) + .unwrap_err(); + + // fails burn on 0 coins + let msg = BankMsg::Burn { + amount: coins(0, "atom"), + }; + bank.execute(&api, &mut store, &router, &block, owner, msg) + .unwrap_err(); + + // can mint via sudo + let msg = BankSudo::Mint { + to_address: rcpt.to_string(), + amount: coins(4321, "atom"), + }; + bank.sudo(&api, &mut store, &router, &block, msg).unwrap(); + + // mint fails with 0 tokens + let msg = BankSudo::Mint { + to_address: rcpt.to_string(), + amount: coins(0, "atom"), + }; + bank.sudo(&api, &mut store, &router, &block, msg) + .unwrap_err(); + + // mint fails with no tokens + let msg = BankSudo::Mint { + to_address: rcpt.to_string(), + amount: vec![], + }; + bank.sudo(&api, &mut store, &router, &block, msg) + .unwrap_err(); + } } From 62653b83043b945175a7f9b7b7cba63d4f2374c9 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 28 Dec 2021 17:51:29 +0100 Subject: [PATCH 117/352] Set version: 0.11.1 --- Cargo.lock | 48 ++++++++++++------------ contracts/cw1-subkeys/Cargo.toml | 14 +++---- contracts/cw1-whitelist-ng/Cargo.toml | 14 +++---- contracts/cw1-whitelist/Cargo.toml | 12 +++--- contracts/cw1155-base/Cargo.toml | 10 ++--- contracts/cw20-atomic-swap/Cargo.toml | 10 ++--- contracts/cw20-base/Cargo.toml | 10 ++--- contracts/cw20-bonding/Cargo.toml | 12 +++--- contracts/cw20-escrow/Cargo.toml | 14 +++---- contracts/cw20-ics20/Cargo.toml | 10 ++--- contracts/cw20-merkle-airdrop/Cargo.toml | 8 ++-- contracts/cw20-staking/Cargo.toml | 14 +++---- contracts/cw3-fixed-multisig/Cargo.toml | 16 ++++---- contracts/cw3-flex-multisig/Cargo.toml | 18 ++++----- contracts/cw4-group/Cargo.toml | 12 +++--- contracts/cw4-stake/Cargo.toml | 14 +++---- packages/controllers/Cargo.toml | 6 +-- packages/cw1/Cargo.toml | 2 +- packages/cw1155/Cargo.toml | 4 +- packages/cw2/Cargo.toml | 4 +- packages/cw20/Cargo.toml | 4 +- packages/cw3/Cargo.toml | 4 +- packages/cw4/Cargo.toml | 4 +- packages/multi-test/Cargo.toml | 6 +-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 4 +- 26 files changed, 138 insertions(+), 138 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 74175f326..cf9ab4438 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -241,7 +241,7 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -253,7 +253,7 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.11.0" +version = "0.11.1" dependencies = [ "anyhow", "cosmwasm-std", @@ -270,7 +270,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-std", "schemars", @@ -279,7 +279,7 @@ dependencies = [ [[package]] name = "cw-utils" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "cw1" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cw1-subkeys" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -318,7 +318,7 @@ dependencies = [ [[package]] name = "cw1-whitelist" -version = "0.11.0" +version = "0.11.1" dependencies = [ "anyhow", "assert_matches", @@ -337,7 +337,7 @@ dependencies = [ [[package]] name = "cw1-whitelist-ng" -version = "0.11.0" +version = "0.11.1" dependencies = [ "anyhow", "assert_matches", @@ -356,7 +356,7 @@ dependencies = [ [[package]] name = "cw1155" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -367,7 +367,7 @@ dependencies = [ [[package]] name = "cw1155-base" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "cw2" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -392,7 +392,7 @@ dependencies = [ [[package]] name = "cw20" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -403,7 +403,7 @@ dependencies = [ [[package]] name = "cw20-atomic-swap" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -420,7 +420,7 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -435,7 +435,7 @@ dependencies = [ [[package]] name = "cw20-bonding" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -454,7 +454,7 @@ dependencies = [ [[package]] name = "cw20-escrow" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -471,7 +471,7 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -504,7 +504,7 @@ dependencies = [ [[package]] name = "cw20-staking" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -521,7 +521,7 @@ dependencies = [ [[package]] name = "cw3" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -532,7 +532,7 @@ dependencies = [ [[package]] name = "cw3-fixed-multisig" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -550,7 +550,7 @@ dependencies = [ [[package]] name = "cw3-flex-multisig" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -569,7 +569,7 @@ dependencies = [ [[package]] name = "cw4" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -580,7 +580,7 @@ dependencies = [ [[package]] name = "cw4-group" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -596,7 +596,7 @@ dependencies = [ [[package]] name = "cw4-stake" -version = "0.11.0" +version = "0.11.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 5c487ff9c..7869846bc 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-subkeys" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Implement subkeys for authorizing native tokens as a cw1 proxy contract" @@ -19,12 +19,12 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw1 = { path = "../../packages/cw1", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.11.0", features = ["library"] } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw1 = { path = "../../packages/cw1", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.11.1", features = ["library"] } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.23" @@ -32,4 +32,4 @@ semver = "1" [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.11.0", features = ["library", "test-utils"] } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.11.1", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index d03d5d474..bf65ba592 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist-ng" -version = "0.11.0" +version = "0.11.1" authors = ["Bartłomiej Kuras "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -22,20 +22,20 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw1 = { path = "../../packages/cw1", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw1 = { path = "../../packages/cw1", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0", optional = true } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1", optional = true } anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index 4ca281d08..bc60dbb54 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw1 = { path = "../../packages/cw1", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw1 = { path = "../../packages/cw1", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -32,5 +32,5 @@ thiserror = { version = "1.0.23" } anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 16ccfc160..9890e29c6 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155-base" -version = "0.11.0" +version = "0.11.1" authors = ["Huang Yi "] edition = "2018" description = "Basic implementation of a CosmWasm-1155 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw1155 = { path = "../../packages/cw1155", version = "0.11.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw1155 = { path = "../../packages/cw1155", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-atomic-swap/Cargo.toml b/contracts/cw20-atomic-swap/Cargo.toml index 3f9fc0797..da1745131 100644 --- a/contracts/cw20-atomic-swap/Cargo.toml +++ b/contracts/cw20-atomic-swap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-atomic-swap" -version = "0.11.0" +version = "0.11.1" authors = ["Mauro Lacy "] edition = "2018" description = "Implementation of Atomic Swaps" @@ -15,11 +15,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw20 = { path = "../../packages/cw20", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw20 = { path = "../../packages/cw20", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index ae494f080..070e6c918 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-base" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation of a CosmWasm-20 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw20 = { path = "../../packages/cw20", version = "0.11.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw20 = { path = "../../packages/cw20", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-bonding/Cargo.toml b/contracts/cw20-bonding/Cargo.toml index fea0d5065..2c4508a70 100644 --- a/contracts/cw20-bonding/Cargo.toml +++ b/contracts/cw20-bonding/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-bonding" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Implement basic bonding curve to issue cw20 tokens" @@ -20,11 +20,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw20 = { path = "../../packages/cw20", version = "0.11.0" } -cw20-base = { path = "../../contracts/cw20-base", version = "0.11.0", features = ["library"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw20 = { path = "../../packages/cw20", version = "0.11.1" } +cw20-base = { path = "../../contracts/cw20-base", version = "0.11.1", features = ["library"] } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3", default-features = false, features = ["staking"] } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-escrow/Cargo.toml b/contracts/cw20-escrow/Cargo.toml index a41fbc36a..1f5f93afa 100644 --- a/contracts/cw20-escrow/Cargo.toml +++ b/contracts/cw20-escrow/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-escrow" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an escrow that accepts CosmWasm-20 tokens as well as native tokens" @@ -18,16 +18,16 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw20 = { path = "../../packages/cw20", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw20 = { path = "../../packages/cw20", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0" } -cw20-base = { path = "../cw20-base", version = "0.11.0", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1" } +cw20-base = { path = "../cw20-base", version = "0.11.1", features = ["library"] } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index b268ea558..61875dcdd 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain" @@ -18,11 +18,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw20 = { path = "../../packages/cw20", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw20 = { path = "../../packages/cw20", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3", features = ["stargate"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw20-merkle-airdrop/Cargo.toml b/contracts/cw20-merkle-airdrop/Cargo.toml index ba108b805..fa64e4f28 100644 --- a/contracts/cw20-merkle-airdrop/Cargo.toml +++ b/contracts/cw20-merkle-airdrop/Cargo.toml @@ -19,11 +19,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw20 = { path = "../../packages/cw20", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw20 = { path = "../../packages/cw20", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw20-staking/Cargo.toml b/contracts/cw20-staking/Cargo.toml index 75d2c7123..0275d354b 100644 --- a/contracts/cw20-staking/Cargo.toml +++ b/contracts/cw20-staking/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-staking" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Implement simple staking derivatives as a cw20 token" @@ -20,13 +20,13 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw20 = { path = "../../packages/cw20", version = "0.11.0" } -cw-controllers = { path = "../../packages/controllers", version = "0.11.0" } -cw20-base = { path = "../../contracts/cw20-base", version = "0.11.0", features = ["library"] } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw20 = { path = "../../packages/cw20", version = "0.11.1" } +cw-controllers = { path = "../../packages/controllers", version = "0.11.1" } +cw20-base = { path = "../../contracts/cw20-base", version = "0.11.1", features = ["library"] } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index 445e8d66a..bc2649280 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-fixed-multisig" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with an fixed group multisig" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw3 = { path = "../../packages/cw3", version = "0.11.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw3 = { path = "../../packages/cw3", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -29,6 +29,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw20 = { path = "../../packages/cw20", version = "0.11.0" } -cw20-base = { path = "../cw20-base", version = "0.11.0", features = ["library"] } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0" } +cw20 = { path = "../../packages/cw20", version = "0.11.1" } +cw20-base = { path = "../cw20-base", version = "0.11.1", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 47b517f22..1fc778bd9 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-flex-multisig" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with multiple voting patterns and dynamic groups" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw3 = { path = "../../packages/cw3", version = "0.11.0" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.11.0", features = ["library"] } -cw4 = { path = "../../packages/cw4", version = "0.11.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw3 = { path = "../../packages/cw3", version = "0.11.1" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.11.1", features = ["library"] } +cw4 = { path = "../../packages/cw4", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw4-group = { path = "../cw4-group", version = "0.11.0" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.0" } +cw4-group = { path = "../cw4-group", version = "0.11.1" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index 1918a243e..8f6859053 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-group" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Simple cw4 implementation of group membership controlled by admin " @@ -26,11 +26,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw4 = { path = "../../packages/cw4", version = "0.11.0" } -cw-controllers = { path = "../../packages/controllers", version = "0.11.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw4 = { path = "../../packages/cw4", version = "0.11.1" } +cw-controllers = { path = "../../packages/controllers", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index 1709658ee..c36847346 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-stake" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "CW4 implementation of group based on staked tokens" @@ -26,12 +26,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw2 = { path = "../../packages/cw2", version = "0.11.0" } -cw4 = { path = "../../packages/cw4", version = "0.11.0" } -cw20 = { path = "../../packages/cw20", version = "0.11.0" } -cw-controllers = { path = "../../packages/controllers", version = "0.11.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw4 = { path = "../../packages/cw4", version = "0.11.1" } +cw20 = { path = "../../packages/cw20", version = "0.11.1" } +cw-controllers = { path = "../../packages/controllers", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index df6e54b45..b2fe7dabd 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-controllers" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Common controllers we can reuse in many contracts" @@ -13,8 +13,8 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta3" } -cw-utils = { path = "../utils", version = "0.11.0" } -cw-storage-plus = { path = "../storage-plus", version = "0.11.0" } +cw-utils = { path = "../utils", version = "0.11.1" } +cw-storage-plus = { path = "../storage-plus", version = "0.11.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index 01cdea229..85f4a0a55 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-1 interface" diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 632249d32..4f9ded91b 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155" -version = "0.11.0" +version = "0.11.1" authors = ["Huang Yi "] edition = "2018" description = "Definition and types for the CosmWasm-1155 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 3d3e6bb71..649eb14c9 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw2" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-2 interface" @@ -11,6 +11,6 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta3", default-features = false } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index 95df78df0..6675eeca5 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-20 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index eddc95d4f..3f6426ff2 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-3 Interface: On-Chain MultiSig/Voting contracts" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } +cw-utils = { path = "../../packages/utils", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index bd428f71a..b87cfbdd6 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-4 Interface: Groups Members" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-storage-plus = { path = "../storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../storage-plus", version = "0.11.1" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index f29bd906e..f19d84b0d 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-multi-test" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Test helpers for multi-contract interactions" @@ -18,8 +18,8 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0"} +cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1"} cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } cosmwasm-storage = { version = "1.0.0-beta3" } itertools = "0.10.1" diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 30f622807..9eefb2040 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-storage-plus" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Enhanced/experimental storage engines" diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index 7c920b592..ffc88f5a3 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-utils" -version = "0.11.0" +version = "0.11.1" authors = ["Ethan Frey "] edition = "2018" description = "Common helpers for other cw specs" @@ -18,5 +18,5 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } [dev-dependencies] -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } prost = "0.9" From 41f23ccded2f76e660cefdfff05f5c281732d4a4 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 28 Dec 2021 18:07:58 +0100 Subject: [PATCH 118/352] Update CHANGELOG --- CHANGELOG.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f04f2e5..a835fe6b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,33 @@ # Changelog +# Changelog + ## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.11.0...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.11.1...HEAD) + +## [v0.11.1](https://github.com/CosmWasm/cw-plus/tree/v0.11.1) (2021-12-28) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.11.0...v0.11.1) + +**Closed issues:** + +- multitest returns error on BankMsg with 0 tokens [\#610](https://github.com/CosmWasm/cw-plus/issues/610) +- Add signed int keys migration example [\#602](https://github.com/CosmWasm/cw-plus/issues/602) +- Issue running wasm compilation out-of-the-box [\#545](https://github.com/CosmWasm/cw-plus/issues/545) + +**Merged pull requests:** + +- Assert non-empty send/burn/mint in multitest bank module [\#611](https://github.com/CosmWasm/cw-plus/pull/611) ([ethanfrey](https://github.com/ethanfrey)) +- cw-storage-plus: Expose keys::Key [\#609](https://github.com/CosmWasm/cw-plus/pull/609) ([orkunkl](https://github.com/orkunkl)) +- Implement Expired variant, Scheduled [\#606](https://github.com/CosmWasm/cw-plus/pull/606) ([orkunkl](https://github.com/orkunkl)) +- Signed int keys migrate example [\#604](https://github.com/CosmWasm/cw-plus/pull/604) ([maurolacy](https://github.com/maurolacy)) +- Adjust order of publishing to handle new deps [\#603](https://github.com/CosmWasm/cw-plus/pull/603) ([ethanfrey](https://github.com/ethanfrey)) +- Fix cw-utils README entry [\#601](https://github.com/CosmWasm/cw-plus/pull/601) ([maurolacy](https://github.com/maurolacy)) +- Rename utils to cw-utils [\#598](https://github.com/CosmWasm/cw-plus/pull/598) ([ethanfrey](https://github.com/ethanfrey)) +- Mention latest workspace optimizer version in README [\#595](https://github.com/CosmWasm/cw-plus/pull/595) ([ueco-jb](https://github.com/ueco-jb)) -## [v0.11.0](https://github.com/CosmWasm/cw-plus/tree/v0.11.0) (2021-11-22) +## [v0.11.0](https://github.com/CosmWasm/cw-plus/tree/v0.11.0) (2021-12-22) [Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.10.3...v0.11.0) From f45f3b31b0274bfcc73fc3195e21591186c03e53 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 28 Dec 2021 18:35:47 +0100 Subject: [PATCH 119/352] Fix minor typo in publish.sh --- scripts/publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index ff3f1719b..811890132 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -54,7 +54,7 @@ done echo "Waiting for publishing all packages" sleep $SLEEP_TIME -for cont in CW20_BASE; do +for cont in $CW20_BASE; do ( cd "contracts/$cont" echo "Publishing $cont" From cec7a97d33c63645de01cbab1470ce0bd8c0528c Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 28 Dec 2021 18:40:20 +0100 Subject: [PATCH 120/352] Remove references to cw-tokens contracts in publish, README --- README.md | 10 ++++------ scripts/publish.sh | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6f5ff52d3..152d92557 100644 --- a/README.md +++ b/README.md @@ -26,17 +26,15 @@ | cw3-flex-multisig | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw3_flex_multisig.wasm) | [![Docs](https://docs.rs/cw3-flex-multisig/badge.svg)](https://docs.rs/cw3-flex-multisig) | | cw4-group | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw4_group.wasm) | [![Docs](https://docs.rs/cw4-group/badge.svg)](https://docs.rs/cw4-group) | | cw4-stake | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw4_stake.wasm) | [![Docs](https://docs.rs/cw4-stake/badge.svg)](https://docs.rs/cw4-stake) | -| cw20-atomic-swap | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_atomic_swap.wasm) | [![Docs](https://docs.rs/cw20-atomic-swap/badge.svg)](https://docs.rs/cw20-atomic-swap) | | cw20-base | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_base.wasm) | [![Docs](https://docs.rs/cw20-base/badge.svg)](https://docs.rs/cw20-base) | -| cw20-bonding | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_bonding.wasm) | [![Docs](https://docs.rs/cw20-bonding/badge.svg)](https://docs.rs/cw20-bonding) | -| cw20-escrow | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_escrow.wasm) | [![Docs](https://docs.rs/cw20-escrow/badge.svg)](https://docs.rs/cw20-escrow) | | cw20-ics20 | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_ics20.wasm) | [![Docs](https://docs.rs/cw20-ics20/badge.svg)](https://docs.rs/cw20-ics20) | -| cw20-staking | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_staking.wasm) | [![Docs](https://docs.rs/cw20-staking/badge.svg)](https://docs.rs/cw20-staking) | -| cw20-merkle-airdrop | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_merkle_airdrop.wasm) | [![Docs](https://docs.rs/cw20-merkle-airdrop/badge.svg)](https://docs.rs/cw20-merkle-airdrop) | | cw1155-base | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw1155_base.wasm) | [![Docs](https://docs.rs/cw1155-base/badge.svg)](https://docs.rs/cw1155-base) | -Note that `cw721` and `cw721-base` have moved to the new [`cw-nfts` repo](https://github.com/CosmWasm/cw-nfts) +Note: `cw721` and `cw721-base` have moved to the new [`cw-nfts` repo](https://github.com/CosmWasm/cw-nfts) +and can be followed there. + +Note: most of the `cw20-*` contracts besides `cw20-base` have moved to the new [`cw-tokens` repo](https://github.com/CosmWasm/cw-tokens) and can be followed there. This is a collection of specification and contracts designed for diff --git a/scripts/publish.sh b/scripts/publish.sh index 811890132..8c4bee118 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -13,7 +13,7 @@ ALL_PACKAGES="controllers cw1 cw2 cw3 cw4 cw20 cw1155 multi-test" CW20_BASE="cw20-base" # these are imported by other contracts BASE_CONTRACTS="cw1-whitelist cw4-group cw3-fixed-multisig " -ALL_CONTRACTS="cw1-subkeys cw3-flex-multisig cw4-stake cw20-atomic-swap cw20-bonding cw20-escrow cw20-ics20 cw20-staking cw1155-base" +ALL_CONTRACTS="cw1-subkeys cw3-flex-multisig cw4-stake cw20-ics20 cw1155-base" SLEEP_TIME=30 From 3401ae7e172d6d44d5842bb38270bb3f8ba4620b Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 28 Dec 2021 18:42:06 +0100 Subject: [PATCH 121/352] Remove cw-tokens contracts from CI and Cargo.toml --- .circleci/config.yml | 143 ------------------------------------------- Cargo.toml | 20 ------ 2 files changed, 163 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7bdf9d52e..b1ac2aa51 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,13 +10,8 @@ workflows: - contract_cw3_flex_multisig - contract_cw4_group - contract_cw4_stake - - contract_cw20_atomic_swap - contract_cw20_base - - contract_cw20_bonding - - contract_cw20_escrow - contract_cw20_ics20 - - contract_cw20_staking - - contract_cw20_merkle_airdrop - contract_cw1155_base - package_controllers - package_utils @@ -127,36 +122,6 @@ jobs: - target key: cargocache-cw1-whitelist-ng-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - contract_cw20_atomic_swap: - docker: - - image: rust:1.53.0 - working_directory: ~/project/contracts/cw20-atomic-swap - steps: - - checkout: - path: ~/project - - run: - name: Version information - command: rustc --version; cargo --version; rustup --version - - restore_cache: - keys: - - cargocache-cw20-atomic-swap-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - - run: - name: Add wasm32 target - command: rustup target add wasm32-unknown-unknown - - run: - name: Unit Tests - environment: - RUST_BACKTRACE: 1 - command: cargo unit-test --locked - - run: - name: Build and run schema generator - command: cargo schema --locked - - save_cache: - paths: - - /usr/local/cargo/registry - - target - key: cargocache-cw20-atomic-swap-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - contract_cw3_fixed_multisig: docker: - image: rust:1.53.0 @@ -292,60 +257,6 @@ jobs: - target key: cargocache-cw20-base-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - contract_cw20_bonding: - docker: - - image: rust:1.53.0 - working_directory: ~/project/contracts/cw20-bonding - steps: - - checkout: - path: ~/project - - run: - name: Version information - command: rustc --version; cargo --version; rustup --version - - restore_cache: - keys: - - cargocache-cw20-bonding-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - - run: - name: Unit Tests - environment: - RUST_BACKTRACE: 1 - command: cargo unit-test --locked - - run: - name: Build and run schema generator - command: cargo schema --locked - - save_cache: - paths: - - /usr/local/cargo/registry - - target - key: cargocache-cw20-bonding-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - - contract_cw20_escrow: - docker: - - image: rust:1.53.0 - working_directory: ~/project/contracts/cw20-escrow - steps: - - checkout: - path: ~/project - - run: - name: Version information - command: rustc --version; cargo --version; rustup --version - - restore_cache: - keys: - - cargocache-cw20-escrow-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - - run: - name: Unit Tests - environment: - RUST_BACKTRACE: 1 - command: cargo unit-test --locked - - run: - name: Build and run schema generator - command: cargo schema --locked - - save_cache: - paths: - - /usr/local/cargo/registry - - target - key: cargocache-cw20-escrow-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - contract_cw20_ics20: docker: - image: rust:1.53.0 @@ -373,60 +284,6 @@ jobs: - target key: cargocache-cw20-ics20-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - contract_cw20_staking: - docker: - - image: rust:1.53.0 - working_directory: ~/project/contracts/cw20-staking - steps: - - checkout: - path: ~/project - - run: - name: Version information - command: rustc --version; cargo --version; rustup --version - - restore_cache: - keys: - - cargocache-cw20-staking-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - - run: - name: Unit Tests - environment: - RUST_BACKTRACE: 1 - command: cargo unit-test --locked - - run: - name: Build and run schema generator - command: cargo schema --locked - - save_cache: - paths: - - /usr/local/cargo/registry - - target - key: cargocache-cw20-staking-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - - contract_cw20_merkle_airdrop: - docker: - - image: rust:1.53.0 - working_directory: ~/project/contracts/cw20-merkle-airdrop - steps: - - checkout: - path: ~/project - - run: - name: Version information - command: rustc --version; cargo --version; rustup --version - - restore_cache: - keys: - - cargocache-cw20-merkle-airdrop-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - - run: - name: Unit Tests - environment: - RUST_BACKTRACE: 1 - command: cargo unit-test --locked - - run: - name: Build and run schema generator - command: cargo schema --locked - - save_cache: - paths: - - /usr/local/cargo/registry - - target - key: cargocache-cw20-merkle-airdrop-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} - contract_cw1155_base: docker: - image: rust:1.53.0 diff --git a/Cargo.toml b/Cargo.toml index 05682fd76..6cd7a4468 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,34 +25,14 @@ incremental = false codegen-units = 1 incremental = false -[profile.release.package.cw20-atomic-swap] -codegen-units = 1 -incremental = false - [profile.release.package.cw20-base] codegen-units = 1 incremental = false -[profile.release.package.cw20-bonding] -codegen-units = 1 -incremental = false - -[profile.release.package.cw20-escrow] -codegen-units = 1 -incremental = false - [profile.release.package.cw20-ics20] codegen-units = 1 incremental = false -[profile.release.package.cw20-merkle-airdrop] -codegen-units = 1 -incremental = false - -[profile.release.package.cw20-staking] -codegen-units = 1 -incremental = false - [profile.release.package.cw1155-base] codegen-units = 1 incremental = false From c066498db73162ca8ae47e610d181c1ac5bba4a7 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 28 Dec 2021 18:42:50 +0100 Subject: [PATCH 122/352] Remove contract code that moved to cw-tokens --- contracts/cw20-atomic-swap/.cargo/config | 6 - contracts/cw20-atomic-swap/Cargo.toml | 30 - contracts/cw20-atomic-swap/NOTICE | 14 - contracts/cw20-atomic-swap/README.md | 48 - contracts/cw20-atomic-swap/examples/schema.rs | 23 - contracts/cw20-atomic-swap/src/contract.rs | 745 ----- contracts/cw20-atomic-swap/src/error.rs | 32 - contracts/cw20-atomic-swap/src/lib.rs | 6 - contracts/cw20-atomic-swap/src/msg.rs | 96 - contracts/cw20-atomic-swap/src/state.rs | 78 - contracts/cw20-bonding/.cargo/config | 6 - contracts/cw20-bonding/Cargo.toml | 37 - contracts/cw20-bonding/NOTICE | 14 - contracts/cw20-bonding/README.md | 72 - contracts/cw20-bonding/examples/schema.rs | 22 - contracts/cw20-bonding/src/contract.rs | 636 ---- contracts/cw20-bonding/src/curves.rs | 357 --- contracts/cw20-bonding/src/error.rs | 18 - contracts/cw20-bonding/src/lib.rs | 7 - contracts/cw20-bonding/src/msg.rs | 145 - contracts/cw20-bonding/src/state.rs | 38 - contracts/cw20-escrow/.cargo/config | 6 - contracts/cw20-escrow/Cargo.toml | 33 - contracts/cw20-escrow/NOTICE | 14 - contracts/cw20-escrow/README.md | 46 - contracts/cw20-escrow/examples/schema.rs | 22 - contracts/cw20-escrow/src/contract.rs | 603 ---- contracts/cw20-escrow/src/error.rs | 23 - contracts/cw20-escrow/src/integration_test.rs | 151 - contracts/cw20-escrow/src/lib.rs | 7 - contracts/cw20-escrow/src/msg.rs | 123 - contracts/cw20-escrow/src/state.rs | 145 - contracts/cw20-merkle-airdrop/.cargo/config | 6 - contracts/cw20-merkle-airdrop/Cargo.toml | 35 - contracts/cw20-merkle-airdrop/NOTICE | 16 - contracts/cw20-merkle-airdrop/README.md | 105 - .../cw20-merkle-airdrop/examples/schema.rs | 23 - .../cw20-merkle-airdrop/helpers/.eslintignore | 1 - .../cw20-merkle-airdrop/helpers/.eslintrc | 6 - .../cw20-merkle-airdrop/helpers/.gitignore | 8 - .../cw20-merkle-airdrop/helpers/README.md | 47 - contracts/cw20-merkle-airdrop/helpers/bin/run | 5 - .../cw20-merkle-airdrop/helpers/bin/run.cmd | 3 - .../cw20-merkle-airdrop/helpers/package.json | 60 - .../helpers/src/airdrop.ts | 44 - .../helpers/src/commands/generateProofs.ts | 48 - .../helpers/src/commands/generateRoot.ts | 37 - .../helpers/src/commands/verifyProofs.ts | 55 - .../cw20-merkle-airdrop/helpers/src/index.ts | 1 - .../cw20-merkle-airdrop/helpers/tsconfig.json | 33 - .../cw20-merkle-airdrop/helpers/yarn.lock | 2767 ----------------- contracts/cw20-merkle-airdrop/src/contract.rs | 548 ---- contracts/cw20-merkle-airdrop/src/error.rs | 30 - contracts/cw20-merkle-airdrop/src/lib.rs | 6 - contracts/cw20-merkle-airdrop/src/msg.rs | 68 - contracts/cw20-merkle-airdrop/src/state.rs | 24 - .../testdata/airdrop_stage_1_list.json | 9 - .../testdata/airdrop_stage_1_test_data.json | 10 - .../testdata/airdrop_stage_2_list.json | 13 - .../testdata/airdrop_stage_2_test_data.json | 11 - contracts/cw20-staking/.cargo/config | 6 - contracts/cw20-staking/Cargo.toml | 35 - contracts/cw20-staking/NOTICE | 14 - contracts/cw20-staking/README.md | 25 - contracts/cw20-staking/examples/schema.rs | 23 - contracts/cw20-staking/src/contract.rs | 965 ------ contracts/cw20-staking/src/error.rs | 69 - contracts/cw20-staking/src/lib.rs | 6 - contracts/cw20-staking/src/msg.rs | 130 - contracts/cw20-staking/src/state.rs | 43 - 70 files changed, 8938 deletions(-) delete mode 100644 contracts/cw20-atomic-swap/.cargo/config delete mode 100644 contracts/cw20-atomic-swap/Cargo.toml delete mode 100644 contracts/cw20-atomic-swap/NOTICE delete mode 100644 contracts/cw20-atomic-swap/README.md delete mode 100644 contracts/cw20-atomic-swap/examples/schema.rs delete mode 100644 contracts/cw20-atomic-swap/src/contract.rs delete mode 100644 contracts/cw20-atomic-swap/src/error.rs delete mode 100644 contracts/cw20-atomic-swap/src/lib.rs delete mode 100644 contracts/cw20-atomic-swap/src/msg.rs delete mode 100644 contracts/cw20-atomic-swap/src/state.rs delete mode 100644 contracts/cw20-bonding/.cargo/config delete mode 100644 contracts/cw20-bonding/Cargo.toml delete mode 100644 contracts/cw20-bonding/NOTICE delete mode 100644 contracts/cw20-bonding/README.md delete mode 100644 contracts/cw20-bonding/examples/schema.rs delete mode 100644 contracts/cw20-bonding/src/contract.rs delete mode 100644 contracts/cw20-bonding/src/curves.rs delete mode 100644 contracts/cw20-bonding/src/error.rs delete mode 100644 contracts/cw20-bonding/src/lib.rs delete mode 100644 contracts/cw20-bonding/src/msg.rs delete mode 100644 contracts/cw20-bonding/src/state.rs delete mode 100644 contracts/cw20-escrow/.cargo/config delete mode 100644 contracts/cw20-escrow/Cargo.toml delete mode 100644 contracts/cw20-escrow/NOTICE delete mode 100644 contracts/cw20-escrow/README.md delete mode 100644 contracts/cw20-escrow/examples/schema.rs delete mode 100644 contracts/cw20-escrow/src/contract.rs delete mode 100644 contracts/cw20-escrow/src/error.rs delete mode 100644 contracts/cw20-escrow/src/integration_test.rs delete mode 100644 contracts/cw20-escrow/src/lib.rs delete mode 100644 contracts/cw20-escrow/src/msg.rs delete mode 100644 contracts/cw20-escrow/src/state.rs delete mode 100644 contracts/cw20-merkle-airdrop/.cargo/config delete mode 100644 contracts/cw20-merkle-airdrop/Cargo.toml delete mode 100644 contracts/cw20-merkle-airdrop/NOTICE delete mode 100644 contracts/cw20-merkle-airdrop/README.md delete mode 100644 contracts/cw20-merkle-airdrop/examples/schema.rs delete mode 100644 contracts/cw20-merkle-airdrop/helpers/.eslintignore delete mode 100644 contracts/cw20-merkle-airdrop/helpers/.eslintrc delete mode 100644 contracts/cw20-merkle-airdrop/helpers/.gitignore delete mode 100644 contracts/cw20-merkle-airdrop/helpers/README.md delete mode 100755 contracts/cw20-merkle-airdrop/helpers/bin/run delete mode 100644 contracts/cw20-merkle-airdrop/helpers/bin/run.cmd delete mode 100644 contracts/cw20-merkle-airdrop/helpers/package.json delete mode 100644 contracts/cw20-merkle-airdrop/helpers/src/airdrop.ts delete mode 100644 contracts/cw20-merkle-airdrop/helpers/src/commands/generateProofs.ts delete mode 100644 contracts/cw20-merkle-airdrop/helpers/src/commands/generateRoot.ts delete mode 100644 contracts/cw20-merkle-airdrop/helpers/src/commands/verifyProofs.ts delete mode 100644 contracts/cw20-merkle-airdrop/helpers/src/index.ts delete mode 100644 contracts/cw20-merkle-airdrop/helpers/tsconfig.json delete mode 100644 contracts/cw20-merkle-airdrop/helpers/yarn.lock delete mode 100644 contracts/cw20-merkle-airdrop/src/contract.rs delete mode 100644 contracts/cw20-merkle-airdrop/src/error.rs delete mode 100644 contracts/cw20-merkle-airdrop/src/lib.rs delete mode 100644 contracts/cw20-merkle-airdrop/src/msg.rs delete mode 100644 contracts/cw20-merkle-airdrop/src/state.rs delete mode 100644 contracts/cw20-merkle-airdrop/testdata/airdrop_stage_1_list.json delete mode 100644 contracts/cw20-merkle-airdrop/testdata/airdrop_stage_1_test_data.json delete mode 100644 contracts/cw20-merkle-airdrop/testdata/airdrop_stage_2_list.json delete mode 100644 contracts/cw20-merkle-airdrop/testdata/airdrop_stage_2_test_data.json delete mode 100644 contracts/cw20-staking/.cargo/config delete mode 100644 contracts/cw20-staking/Cargo.toml delete mode 100644 contracts/cw20-staking/NOTICE delete mode 100644 contracts/cw20-staking/README.md delete mode 100644 contracts/cw20-staking/examples/schema.rs delete mode 100644 contracts/cw20-staking/src/contract.rs delete mode 100644 contracts/cw20-staking/src/error.rs delete mode 100644 contracts/cw20-staking/src/lib.rs delete mode 100644 contracts/cw20-staking/src/msg.rs delete mode 100644 contracts/cw20-staking/src/state.rs diff --git a/contracts/cw20-atomic-swap/.cargo/config b/contracts/cw20-atomic-swap/.cargo/config deleted file mode 100644 index 8d4bc738b..000000000 --- a/contracts/cw20-atomic-swap/.cargo/config +++ /dev/null @@ -1,6 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib" -integration-test = "test --test integration" -schema = "run --example schema" diff --git a/contracts/cw20-atomic-swap/Cargo.toml b/contracts/cw20-atomic-swap/Cargo.toml deleted file mode 100644 index da1745131..000000000 --- a/contracts/cw20-atomic-swap/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "cw20-atomic-swap" -version = "0.11.1" -authors = ["Mauro Lacy "] -edition = "2018" -description = "Implementation of Atomic Swaps" -license = "Apache-2.0" - -[lib] -crate-type = ["cdylib", "rlib"] - -[features] -backtraces = ["cosmwasm-std/backtraces"] -# use library feature to disable all instantiate/execute/query exports -library = [] - -[dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw20 = { path = "../../packages/cw20", version = "0.11.1" } -cosmwasm-std = { version = "1.0.0-beta3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } -schemars = "0.8.1" -serde = { version = "1.0.103", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.23" } -hex = "0.3.1" -sha2 = "0.8.0" - -[dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-atomic-swap/NOTICE b/contracts/cw20-atomic-swap/NOTICE deleted file mode 100644 index c18423056..000000000 --- a/contracts/cw20-atomic-swap/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -Atomic-Swap: A CosmWasm atomic swap contract that handles native tokens -Copyright (C) 2020 Confio OÜ - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/contracts/cw20-atomic-swap/README.md b/contracts/cw20-atomic-swap/README.md deleted file mode 100644 index 3bfa5cb16..000000000 --- a/contracts/cw20-atomic-swap/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# Atomic Swaps - -This is a contract that allows users to execute atomic swaps. -It implements one side of an atomic swap. The other side can be realized -by an equivalent contract in the same blockchain or, typically, on a different blockchain. - -Each side of an atomic swap has a sender, a recipient, a hash, -and a timeout. It also has a unique id (for future calls to reference it). -The hash is a sha256-encoded 32-bytes long phrase. -The timeout can be either time-based (seconds since midnight, January 1, 1970), -or block height based. - -The basic function is, the sender chooses a 32-bytes long phrase as preimage, hashes it, -and then uses the hash to create a swap with funds. -Before the timeout, anybody that knows the preimage may decide to release the funds -to the original recipient. -After the timeout (and if no release has been executed), anyone can refund -the locked tokens to the original sender. -On the other side of the swap the process is similar, with sender and recipient exchanged. -The hash must be the same, so the first sender can claim the funds, revealing the preimage -and triggering the swap. - -See the [IOV atomic swap spec](https://github.com/iov-one/iov-core/blob/master/docs/atomic-swap-protocol-v1.md) -for details. - -## Token types - -Currently native tokens are supported; an upcoming version will support CW20 tokens. - -## Running this contract - -You will need Rust 1.44.1+ with `wasm32-unknown-unknown` target installed. - -You can run unit tests on this via: - -`cargo test` - -Once you are happy with the content, you can compile it to wasm via: - -``` -RUSTFLAGS='-C link-arg=-s' cargo wasm -cp ../../target/wasm32-unknown-unknown/release/cw20_atomic_swap.wasm . -ls -l cw20_atomic_swap.wasm -sha256sum cw20_atomic_swap.wasm -``` - -Or for a production-ready (optimized) build, run a build command in the -the repository root: https://github.com/CosmWasm/cw-plus#compiling. diff --git a/contracts/cw20-atomic-swap/examples/schema.rs b/contracts/cw20-atomic-swap/examples/schema.rs deleted file mode 100644 index f89e1bc25..000000000 --- a/contracts/cw20-atomic-swap/examples/schema.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw20_atomic_swap::msg::DetailsResponse; -use cw20_atomic_swap::msg::ExecuteMsg; -use cw20_atomic_swap::msg::InstantiateMsg; -use cw20_atomic_swap::msg::ListResponse; -use cw20_atomic_swap::msg::QueryMsg; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); - export_schema(&schema_for!(ListResponse), &out_dir); - export_schema(&schema_for!(DetailsResponse), &out_dir); -} diff --git a/contracts/cw20-atomic-swap/src/contract.rs b/contracts/cw20-atomic-swap/src/contract.rs deleted file mode 100644 index 6b24fa102..000000000 --- a/contracts/cw20-atomic-swap/src/contract.rs +++ /dev/null @@ -1,745 +0,0 @@ -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; -use cosmwasm_std::{ - from_binary, to_binary, Addr, BankMsg, Binary, Deps, DepsMut, Env, MessageInfo, Response, - StdResult, SubMsg, WasmMsg, -}; -use sha2::{Digest, Sha256}; - -use cw2::set_contract_version; -use cw20::{Balance, Cw20Coin, Cw20CoinVerified, Cw20ExecuteMsg, Cw20ReceiveMsg}; - -use crate::error::ContractError; -use crate::msg::{ - is_valid_name, BalanceHuman, CreateMsg, DetailsResponse, ExecuteMsg, InstantiateMsg, - ListResponse, QueryMsg, ReceiveMsg, -}; -use crate::state::{all_swap_ids, AtomicSwap, SWAPS}; -use cw_storage_plus::Bound; - -// Version info, for migration info -const CONTRACT_NAME: &str = "crates.io:cw20-atomic-swap"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn instantiate( - deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: InstantiateMsg, -) -> StdResult { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - // No setup - Ok(Response::default()) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> Result { - match msg { - ExecuteMsg::Create(msg) => { - let sent_funds = info.funds.clone(); - execute_create(deps, env, info, msg, Balance::from(sent_funds)) - } - ExecuteMsg::Release { id, preimage } => execute_release(deps, env, id, preimage), - ExecuteMsg::Refund { id } => execute_refund(deps, env, id), - ExecuteMsg::Receive(msg) => execute_receive(deps, env, info, msg), - } -} - -pub fn execute_receive( - deps: DepsMut, - env: Env, - info: MessageInfo, - wrapper: Cw20ReceiveMsg, -) -> Result { - let msg: ReceiveMsg = from_binary(&wrapper.msg)?; - let token = Cw20CoinVerified { - address: info.sender, - amount: wrapper.amount, - }; - // we need to update the info... so the original sender is the one authorizing with these tokens - let orig_info = MessageInfo { - sender: deps.api.addr_validate(&wrapper.sender)?, - funds: info.funds, - }; - match msg { - ReceiveMsg::Create(create) => { - execute_create(deps, env, orig_info, create, Balance::Cw20(token)) - } - } -} - -pub fn execute_create( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: CreateMsg, - balance: Balance, -) -> Result { - if !is_valid_name(&msg.id) { - return Err(ContractError::InvalidId {}); - } - - // this ignores 0 value coins, must have one or more with positive balance - if balance.is_empty() { - return Err(ContractError::EmptyBalance {}); - } - - // Ensure this is 32 bytes hex-encoded, and decode - let hash = parse_hex_32(&msg.hash)?; - - if msg.expires.is_expired(&env.block) { - return Err(ContractError::Expired {}); - } - - let recipient = deps.api.addr_validate(&msg.recipient)?; - - let swap = AtomicSwap { - hash: Binary(hash), - recipient, - source: info.sender, - expires: msg.expires, - balance, - }; - - // Try to store it, fail if the id already exists (unmodifiable swaps) - SWAPS.update(deps.storage, &msg.id, |existing| match existing { - None => Ok(swap), - Some(_) => Err(ContractError::AlreadyExists {}), - })?; - - let res = Response::new() - .add_attribute("action", "create") - .add_attribute("id", msg.id) - .add_attribute("hash", msg.hash) - .add_attribute("recipient", msg.recipient); - Ok(res) -} - -pub fn execute_release( - deps: DepsMut, - env: Env, - id: String, - preimage: String, -) -> Result { - let swap = SWAPS.load(deps.storage, &id)?; - if swap.is_expired(&env.block) { - return Err(ContractError::Expired {}); - } - - let hash = Sha256::digest(&parse_hex_32(&preimage)?); - if hash.as_slice() != swap.hash.as_slice() { - return Err(ContractError::InvalidPreimage {}); - } - - // Delete the swap - SWAPS.remove(deps.storage, &id); - - // Send all tokens out - let msgs = send_tokens(&swap.recipient, swap.balance)?; - Ok(Response::new() - .add_submessages(msgs) - .add_attribute("action", "release") - .add_attribute("id", id) - .add_attribute("preimage", preimage) - .add_attribute("to", swap.recipient.to_string())) -} - -pub fn execute_refund(deps: DepsMut, env: Env, id: String) -> Result { - let swap = SWAPS.load(deps.storage, &id)?; - // Anyone can try to refund, as long as the contract is expired - if !swap.is_expired(&env.block) { - return Err(ContractError::NotExpired {}); - } - - // We delete the swap - SWAPS.remove(deps.storage, &id); - - let msgs = send_tokens(&swap.source, swap.balance)?; - Ok(Response::new() - .add_submessages(msgs) - .add_attribute("action", "refund") - .add_attribute("id", id) - .add_attribute("to", swap.source.to_string())) -} - -fn parse_hex_32(data: &str) -> Result, ContractError> { - match hex::decode(data) { - Ok(bin) => { - if bin.len() == 32 { - Ok(bin) - } else { - Err(ContractError::InvalidHash(bin.len() * 2)) - } - } - Err(e) => Err(ContractError::ParseError(e.to_string())), - } -} - -fn send_tokens(to: &Addr, amount: Balance) -> StdResult> { - if amount.is_empty() { - Ok(vec![]) - } else { - match amount { - Balance::Native(coins) => { - let msg = BankMsg::Send { - to_address: to.into(), - amount: coins.into_vec(), - }; - Ok(vec![SubMsg::new(msg)]) - } - Balance::Cw20(coin) => { - let msg = Cw20ExecuteMsg::Transfer { - recipient: to.into(), - amount: coin.amount, - }; - let exec = WasmMsg::Execute { - contract_addr: coin.address.into(), - msg: to_binary(&msg)?, - funds: vec![], - }; - Ok(vec![SubMsg::new(exec)]) - } - } - } -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::List { start_after, limit } => to_binary(&query_list(deps, start_after, limit)?), - QueryMsg::Details { id } => to_binary(&query_details(deps, id)?), - } -} - -fn query_details(deps: Deps, id: String) -> StdResult { - let swap = SWAPS.load(deps.storage, &id)?; - - // Convert balance to human balance - let balance_human = match swap.balance { - Balance::Native(coins) => BalanceHuman::Native(coins.into_vec()), - Balance::Cw20(coin) => BalanceHuman::Cw20(Cw20Coin { - address: coin.address.into(), - amount: coin.amount, - }), - }; - - let details = DetailsResponse { - id, - hash: hex::encode(swap.hash.as_slice()), - recipient: swap.recipient.into(), - source: swap.source.into(), - expires: swap.expires, - balance: balance_human, - }; - Ok(details) -} - -// Settings for pagination -const MAX_LIMIT: u32 = 30; -const DEFAULT_LIMIT: u32 = 10; - -fn query_list( - deps: Deps, - start_after: Option, - limit: Option, -) -> StdResult { - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(|s| Bound::exclusive(s.as_bytes())); - - Ok(ListResponse { - swaps: all_swap_ids(deps.storage, start, limit)?, - }) -} - -#[cfg(test)] -mod tests { - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{coins, from_binary, StdError, Timestamp, Uint128}; - - use cw20::Expiration; - - use super::*; - - fn preimage() -> String { - hex::encode(b"This is a string, 32 bytes long.") - } - - fn custom_preimage(int: u16) -> String { - hex::encode(format!("This is a custom string: {:>7}", int)) - } - - fn real_hash() -> String { - hex::encode(&Sha256::digest(&hex::decode(preimage()).unwrap())) - } - - fn custom_hash(int: u16) -> String { - hex::encode(&Sha256::digest(&hex::decode(custom_preimage(int)).unwrap())) - } - - fn mock_env_height(height: u64) -> Env { - let mut env = mock_env(); - env.block.height = height; - env - } - - #[test] - fn test_instantiate() { - let mut deps = mock_dependencies(); - - // Instantiate an empty contract - let instantiate_msg = InstantiateMsg {}; - let info = mock_info("anyone", &[]); - let res = instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); - assert_eq!(0, res.messages.len()); - } - - #[test] - fn test_create() { - let mut deps = mock_dependencies(); - - let info = mock_info("anyone", &[]); - instantiate(deps.as_mut(), mock_env(), info, InstantiateMsg {}).unwrap(); - - let sender = String::from("sender0001"); - let balance = coins(100, "tokens"); - - // Cannot create, invalid ids - let info = mock_info(&sender, &balance); - for id in &["sh", "atomic_swap_id_too_long"] { - let create = CreateMsg { - id: id.to_string(), - hash: real_hash(), - recipient: String::from("rcpt0001"), - expires: Expiration::AtHeight(123456), - }; - let err = execute( - deps.as_mut(), - mock_env(), - info.clone(), - ExecuteMsg::Create(create.clone()), - ) - .unwrap_err(); - assert_eq!(err, ContractError::InvalidId {}); - } - - // Cannot create, no funds - let info = mock_info(&sender, &[]); - let create = CreateMsg { - id: "swap0001".to_string(), - hash: real_hash(), - recipient: "rcpt0001".into(), - expires: Expiration::AtHeight(123456), - }; - let err = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Create(create)).unwrap_err(); - assert_eq!(err, ContractError::EmptyBalance {}); - - // Cannot create, expired - let info = mock_info(&sender, &balance); - let create = CreateMsg { - id: "swap0001".to_string(), - hash: real_hash(), - recipient: "rcpt0001".into(), - expires: Expiration::AtTime(Timestamp::from_seconds(1)), - }; - let err = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Create(create)).unwrap_err(); - assert_eq!(err, ContractError::Expired {}); - - // Cannot create, invalid hash - let info = mock_info(&sender, &balance); - let create = CreateMsg { - id: "swap0001".to_string(), - hash: "bu115h17".to_string(), - recipient: "rcpt0001".into(), - expires: Expiration::AtHeight(123456), - }; - let err = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Create(create)).unwrap_err(); - assert_eq!( - err, - ContractError::ParseError("Invalid character \'u\' at position 1".into()) - ); - - // Can create, all valid - let info = mock_info(&sender, &balance); - let create = CreateMsg { - id: "swap0001".to_string(), - hash: real_hash(), - recipient: "rcpt0001".into(), - expires: Expiration::AtHeight(123456), - }; - let res = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Create(create)).unwrap(); - assert_eq!(0, res.messages.len()); - assert_eq!(("action", "create"), res.attributes[0]); - - // Cannot re-create (modify), already existing - let new_balance = coins(1, "tokens"); - let info = mock_info(&sender, &new_balance); - let create = CreateMsg { - id: "swap0001".to_string(), - hash: real_hash(), - recipient: "rcpt0001".into(), - expires: Expiration::AtHeight(123456), - }; - let err = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Create(create)).unwrap_err(); - assert_eq!(err, ContractError::AlreadyExists {}); - } - - #[test] - fn test_release() { - let mut deps = mock_dependencies(); - - let info = mock_info("anyone", &[]); - instantiate(deps.as_mut(), mock_env(), info, InstantiateMsg {}).unwrap(); - - let sender = String::from("sender0001"); - let balance = coins(1000, "tokens"); - - let info = mock_info(&sender, &balance); - let create = CreateMsg { - id: "swap0001".to_string(), - hash: real_hash(), - recipient: "rcpt0001".into(), - expires: Expiration::AtHeight(123456), - }; - execute( - deps.as_mut(), - mock_env(), - info, - ExecuteMsg::Create(create.clone()), - ) - .unwrap(); - - // Anyone can attempt release - let info = mock_info("somebody", &[]); - - // Cannot release, wrong id - let release = ExecuteMsg::Release { - id: "swap0002".to_string(), - preimage: preimage(), - }; - let err = execute(deps.as_mut(), mock_env(), info.clone(), release).unwrap_err(); - assert!(matches!(err, ContractError::Std(StdError::NotFound { .. }))); - - // Cannot release, invalid hash - let release = ExecuteMsg::Release { - id: "swap0001".to_string(), - preimage: "bu115h17".to_string(), - }; - let err = execute(deps.as_mut(), mock_env(), info.clone(), release).unwrap_err(); - assert_eq!( - err, - ContractError::ParseError("Invalid character \'u\' at position 1".to_string()) - ); - - // Cannot release, wrong hash - let release = ExecuteMsg::Release { - id: "swap0001".to_string(), - preimage: hex::encode(b"This is 32 bytes, but incorrect."), - }; - let err = execute(deps.as_mut(), mock_env(), info, release).unwrap_err(); - assert!(matches!(err, ContractError::InvalidPreimage {})); - - // Cannot release, expired - let env = mock_env_height(123457); - let info = mock_info("somebody", &[]); - let release = ExecuteMsg::Release { - id: "swap0001".to_string(), - preimage: preimage(), - }; - let err = execute(deps.as_mut(), env, info, release).unwrap_err(); - assert!(matches!(err, ContractError::Expired)); - - // Can release, valid id, valid hash, and not expired - let info = mock_info("somebody", &[]); - let release = ExecuteMsg::Release { - id: "swap0001".to_string(), - preimage: preimage(), - }; - let res = execute(deps.as_mut(), mock_env(), info.clone(), release.clone()).unwrap(); - assert_eq!(("action", "release"), res.attributes[0]); - assert_eq!(1, res.messages.len()); - assert_eq!( - res.messages[0], - SubMsg::new(BankMsg::Send { - to_address: create.recipient, - amount: balance, - }) - ); - - // Cannot release again - let err = execute(deps.as_mut(), mock_env(), info, release).unwrap_err(); - assert!(matches!(err, ContractError::Std(StdError::NotFound { .. }))); - } - - #[test] - fn test_refund() { - let mut deps = mock_dependencies(); - - let info = mock_info("anyone", &[]); - instantiate(deps.as_mut(), mock_env(), info, InstantiateMsg {}).unwrap(); - - let sender = String::from("sender0001"); - let balance = coins(1000, "tokens"); - - let info = mock_info(&sender, &balance); - let create = CreateMsg { - id: "swap0001".to_string(), - hash: real_hash(), - recipient: "rcpt0001".into(), - expires: Expiration::AtHeight(123456), - }; - execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Create(create)).unwrap(); - - // Anyone can attempt refund - let info = mock_info("somebody", &[]); - - // Cannot refund, wrong id - let refund = ExecuteMsg::Refund { - id: "swap0002".to_string(), - }; - let err = execute(deps.as_mut(), mock_env(), info.clone(), refund).unwrap_err(); - assert!(matches!(err, ContractError::Std(StdError::NotFound { .. }))); - - // Cannot refund, not expired yet - let refund = ExecuteMsg::Refund { - id: "swap0001".to_string(), - }; - let err = execute(deps.as_mut(), mock_env(), info, refund).unwrap_err(); - assert!(matches!(err, ContractError::NotExpired { .. })); - - // Anyone can refund, if already expired - let env = mock_env_height(123457); - let info = mock_info("somebody", &[]); - let refund = ExecuteMsg::Refund { - id: "swap0001".to_string(), - }; - let res = execute(deps.as_mut(), env.clone(), info.clone(), refund.clone()).unwrap(); - assert_eq!(("action", "refund"), res.attributes[0]); - assert_eq!(1, res.messages.len()); - assert_eq!( - res.messages[0], - SubMsg::new(BankMsg::Send { - to_address: sender, - amount: balance, - }) - ); - - // Cannot refund again - let err = execute(deps.as_mut(), env, info, refund).unwrap_err(); - assert!(matches!(err, ContractError::Std(StdError::NotFound { .. }))); - } - - #[test] - fn test_query() { - let mut deps = mock_dependencies(); - - let info = mock_info("anyone", &[]); - instantiate(deps.as_mut(), mock_env(), info, InstantiateMsg {}).unwrap(); - - let sender1 = String::from("sender0001"); - let sender2 = String::from("sender0002"); - // Same balance for simplicity - let balance = coins(1000, "tokens"); - - // Create a couple swaps (same hash for simplicity) - let info = mock_info(&sender1, &balance); - let create1 = CreateMsg { - id: "swap0001".to_string(), - hash: custom_hash(1), - recipient: "rcpt0001".into(), - expires: Expiration::AtHeight(123456), - }; - execute( - deps.as_mut(), - mock_env(), - info, - ExecuteMsg::Create(create1.clone()), - ) - .unwrap(); - - let info = mock_info(&sender2, &balance); - let create2 = CreateMsg { - id: "swap0002".to_string(), - hash: custom_hash(2), - recipient: "rcpt0002".into(), - expires: Expiration::AtTime(Timestamp::from_seconds(2_000_000_000)), - }; - execute( - deps.as_mut(), - mock_env(), - info, - ExecuteMsg::Create(create2.clone()), - ) - .unwrap(); - - // Get the list of ids - let query_msg = QueryMsg::List { - start_after: None, - limit: None, - }; - let ids: ListResponse = - from_binary(&query(deps.as_ref(), mock_env(), query_msg).unwrap()).unwrap(); - assert_eq!(2, ids.swaps.len()); - assert_eq!(vec!["swap0001", "swap0002"], ids.swaps); - - // Get the details for the first swap id - let query_msg = QueryMsg::Details { - id: ids.swaps[0].clone(), - }; - let res: DetailsResponse = - from_binary(&query(deps.as_ref(), mock_env(), query_msg).unwrap()).unwrap(); - assert_eq!( - res, - DetailsResponse { - id: create1.id, - hash: create1.hash, - recipient: create1.recipient, - source: sender1, - expires: create1.expires, - balance: BalanceHuman::Native(balance.clone()), - } - ); - - // Get the details for the second swap id - let query_msg = QueryMsg::Details { - id: ids.swaps[1].clone(), - }; - let res: DetailsResponse = - from_binary(&query(deps.as_ref(), mock_env(), query_msg).unwrap()).unwrap(); - assert_eq!( - res, - DetailsResponse { - id: create2.id, - hash: create2.hash, - recipient: create2.recipient, - source: sender2, - expires: create2.expires, - balance: BalanceHuman::Native(balance), - } - ); - } - - #[test] - fn test_native_cw20_swap() { - let mut deps = mock_dependencies(); - - // Create the contract - let info = mock_info("anyone", &[]); - let res = instantiate(deps.as_mut(), mock_env(), info, InstantiateMsg {}).unwrap(); - assert_eq!(0, res.messages.len()); - - // Native side (offer) - let native_sender = String::from("A_on_X"); - let native_rcpt = String::from("B_on_X"); - let native_coins = coins(1000, "tokens_native"); - - // Create the Native swap offer - let native_swap_id = "native_swap".to_string(); - let create = CreateMsg { - id: native_swap_id.clone(), - hash: real_hash(), - recipient: native_rcpt.clone(), - expires: Expiration::AtHeight(123456), - }; - let info = mock_info(&native_sender, &native_coins); - let res = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Create(create)).unwrap(); - assert_eq!(0, res.messages.len()); - assert_eq!(("action", "create"), res.attributes[0]); - - // Cw20 side (counter offer (1:1000)) - let cw20_sender = String::from("B_on_Y"); - let cw20_rcpt = String::from("A_on_Y"); - let cw20_coin = Cw20Coin { - address: String::from("my_cw20_token"), - amount: Uint128::new(1), - }; - - // Create the Cw20 side swap counter offer - let cw20_swap_id = "cw20_swap".to_string(); - let create = CreateMsg { - id: cw20_swap_id.clone(), - hash: real_hash(), - recipient: cw20_rcpt.clone(), - expires: Expiration::AtHeight(123000), - }; - let receive = Cw20ReceiveMsg { - sender: cw20_sender, - amount: cw20_coin.amount, - msg: to_binary(&ExecuteMsg::Create(create)).unwrap(), - }; - let token_contract = cw20_coin.address; - let info = mock_info(&token_contract, &[]); - let res = execute( - deps.as_mut(), - mock_env(), - info, - ExecuteMsg::Receive(receive), - ) - .unwrap(); - assert_eq!(0, res.messages.len()); - assert_eq!(("action", "create"), res.attributes[0]); - - // Somebody (typically, A) releases the swap side on the Cw20 (Y) blockchain, - // using her knowledge of the preimage - let info = mock_info("somebody", &[]); - let res = execute( - deps.as_mut(), - mock_env(), - info, - ExecuteMsg::Release { - id: cw20_swap_id.clone(), - preimage: preimage(), - }, - ) - .unwrap(); - assert_eq!(1, res.messages.len()); - assert_eq!(("action", "release"), res.attributes[0]); - assert_eq!(("id", cw20_swap_id), res.attributes[1]); - - // Verify the resulting Cw20 transfer message - let send_msg = Cw20ExecuteMsg::Transfer { - recipient: cw20_rcpt, - amount: cw20_coin.amount, - }; - assert_eq!( - res.messages[0], - SubMsg::new(WasmMsg::Execute { - contract_addr: token_contract, - msg: to_binary(&send_msg).unwrap(), - funds: vec![], - }) - ); - - // Now somebody (typically, B) releases the original offer on the Native (X) blockchain, - // using the (now public) preimage - let info = mock_info("other_somebody", &[]); - - // First, let's obtain the preimage from the logs of the release() transaction on Y - let preimage_attr = &res.attributes[2]; - assert_eq!("preimage", preimage_attr.key); - let preimage = preimage_attr.value.clone(); - - let release = ExecuteMsg::Release { - id: native_swap_id.clone(), - preimage, - }; - let res = execute(deps.as_mut(), mock_env(), info, release).unwrap(); - assert_eq!(1, res.messages.len()); - assert_eq!(("action", "release"), res.attributes[0]); - assert_eq!(("id", native_swap_id), res.attributes[1]); - - // Verify the resulting Native send message - assert_eq!( - res.messages[0], - SubMsg::new(BankMsg::Send { - to_address: native_rcpt, - amount: native_coins, - }) - ); - } -} diff --git a/contracts/cw20-atomic-swap/src/error.rs b/contracts/cw20-atomic-swap/src/error.rs deleted file mode 100644 index 29d725666..000000000 --- a/contracts/cw20-atomic-swap/src/error.rs +++ /dev/null @@ -1,32 +0,0 @@ -use cosmwasm_std::StdError; -use thiserror::Error; - -#[derive(Error, Debug, PartialEq)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("Hash parse error: {0}")] - ParseError(String), - - #[error("Invalid atomic swap id")] - InvalidId {}, - - #[error("Invalid preimage")] - InvalidPreimage {}, - - #[error("Invalid hash ({0} chars): must be 64 characters")] - InvalidHash(usize), - - #[error("Send some coins to create an atomic swap")] - EmptyBalance {}, - - #[error("Atomic swap not yet expired")] - NotExpired, - - #[error("Expired atomic swap")] - Expired, - - #[error("Atomic swap already exists")] - AlreadyExists, -} diff --git a/contracts/cw20-atomic-swap/src/lib.rs b/contracts/cw20-atomic-swap/src/lib.rs deleted file mode 100644 index dfedc9dc6..000000000 --- a/contracts/cw20-atomic-swap/src/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod contract; -mod error; -pub mod msg; -pub mod state; - -pub use crate::error::ContractError; diff --git a/contracts/cw20-atomic-swap/src/msg.rs b/contracts/cw20-atomic-swap/src/msg.rs deleted file mode 100644 index ed1f583b0..000000000 --- a/contracts/cw20-atomic-swap/src/msg.rs +++ /dev/null @@ -1,96 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::Coin; -use cw20::{Cw20Coin, Cw20ReceiveMsg, Expiration}; - -#[derive(Serialize, Deserialize, JsonSchema)] -pub struct InstantiateMsg {} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg { - Create(CreateMsg), - /// Release sends all tokens to the recipient. - Release { - id: String, - /// This is the preimage, must be exactly 32 bytes in hex (64 chars) - /// to release: sha256(from_hex(preimage)) == from_hex(hash) - preimage: String, - }, - /// Refund returns all remaining tokens to the original sender, - Refund { - id: String, - }, - /// This accepts a properly-encoded ReceiveMsg from a cw20 contract - Receive(Cw20ReceiveMsg), -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ReceiveMsg { - Create(CreateMsg), -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct CreateMsg { - /// id is a human-readable name for the swap to use later. - /// 3-20 bytes of utf-8 text - pub id: String, - /// This is hex-encoded sha-256 hash of the preimage (must be 32*2 = 64 chars) - pub hash: String, - /// If approved, funds go to the recipient - pub recipient: String, - /// You can set expiration at time or at block height the contract is valid at. - /// After the contract is expired, it can be returned to the original funder. - pub expires: Expiration, -} - -pub fn is_valid_name(name: &str) -> bool { - let bytes = name.as_bytes(); - if bytes.len() < 3 || bytes.len() > 20 { - return false; - } - true -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum QueryMsg { - /// Show all open swaps. Return type is ListResponse. - List { - start_after: Option, - limit: Option, - }, - /// Returns the details of the named swap, error if not created. - /// Return type: DetailsResponse. - Details { id: String }, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct ListResponse { - /// List all open swap ids - pub swaps: Vec, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct DetailsResponse { - /// Id of this swap - pub id: String, - /// This is hex-encoded sha-256 hash of the preimage (must be 32*2 = 64 chars) - pub hash: String, - /// If released, funds go to the recipient - pub recipient: String, - /// If refunded, funds go to the source - pub source: String, - /// Once a swap is expired, it can be returned to the original source (via "refund"). - pub expires: Expiration, - /// Balance in native tokens or cw20 token, with human-readable address - pub balance: BalanceHuman, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub enum BalanceHuman { - Native(Vec), - Cw20(Cw20Coin), -} diff --git a/contracts/cw20-atomic-swap/src/state.rs b/contracts/cw20-atomic-swap/src/state.rs deleted file mode 100644 index de231bd74..000000000 --- a/contracts/cw20-atomic-swap/src/state.rs +++ /dev/null @@ -1,78 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::{Addr, Binary, BlockInfo, Order, StdResult, Storage}; -use cw_storage_plus::{Bound, Map}; - -use cw20::{Balance, Expiration}; - -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct AtomicSwap { - /// This is the sha-256 hash of the preimage - pub hash: Binary, - pub recipient: Addr, - pub source: Addr, - pub expires: Expiration, - /// Balance in native tokens, or cw20 token - pub balance: Balance, -} - -impl AtomicSwap { - pub fn is_expired(&self, block: &BlockInfo) -> bool { - self.expires.is_expired(block) - } -} - -pub const SWAPS: Map<&str, AtomicSwap> = Map::new("atomic_swap"); - -/// This returns the list of ids for all active swaps -pub fn all_swap_ids( - storage: &dyn Storage, - start: Option, - limit: usize, -) -> StdResult> { - SWAPS - .keys(storage, start, None, Order::Ascending) - .take(limit) - .collect() -} - -#[cfg(test)] -mod tests { - use super::*; - - use cosmwasm_std::testing::MockStorage; - use cosmwasm_std::Binary; - - #[test] - fn test_no_swap_ids() { - let storage = MockStorage::new(); - let ids = all_swap_ids(&storage, None, 10).unwrap(); - assert_eq!(0, ids.len()); - } - - fn dummy_swap() -> AtomicSwap { - AtomicSwap { - recipient: Addr::unchecked("recip"), - source: Addr::unchecked("source"), - expires: Default::default(), - hash: Binary("hash".into()), - balance: Default::default(), - } - } - - #[test] - fn test_all_swap_ids() { - let mut storage = MockStorage::new(); - SWAPS.save(&mut storage, "lazy", &dummy_swap()).unwrap(); - SWAPS.save(&mut storage, "assign", &dummy_swap()).unwrap(); - SWAPS.save(&mut storage, "zen", &dummy_swap()).unwrap(); - - let ids = all_swap_ids(&storage, None, 10).unwrap(); - assert_eq!(3, ids.len()); - assert_eq!( - vec!["assign".to_string(), "lazy".to_string(), "zen".to_string()], - ids - ) - } -} diff --git a/contracts/cw20-bonding/.cargo/config b/contracts/cw20-bonding/.cargo/config deleted file mode 100644 index 8d4bc738b..000000000 --- a/contracts/cw20-bonding/.cargo/config +++ /dev/null @@ -1,6 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib" -integration-test = "test --test integration" -schema = "run --example schema" diff --git a/contracts/cw20-bonding/Cargo.toml b/contracts/cw20-bonding/Cargo.toml deleted file mode 100644 index 2c4508a70..000000000 --- a/contracts/cw20-bonding/Cargo.toml +++ /dev/null @@ -1,37 +0,0 @@ -[package] -name = "cw20-bonding" -version = "0.11.1" -authors = ["Ethan Frey "] -edition = "2018" -description = "Implement basic bonding curve to issue cw20 tokens" -license = "Apache-2.0" -repository = "https://github.com/CosmWasm/cw-plus" -homepage = "https://cosmwasm.com" -documentation = "https://docs.cosmwasm.com" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["cdylib", "rlib"] - -[features] -backtraces = ["cosmwasm-std/backtraces"] -# use library feature to disable all instantiate/execute/query exports -library = [] - -[dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw20 = { path = "../../packages/cw20", version = "0.11.1" } -cw20-base = { path = "../../contracts/cw20-base", version = "0.11.1", features = ["library"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } -cosmwasm-std = { version = "1.0.0-beta3", default-features = false, features = ["staking"] } -schemars = "0.8.1" -serde = { version = "1.0.103", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.23" } -rust_decimal = { version = "1.14.3" } -integer-sqrt = { version = "0.1.5" } -integer-cbrt = { version = "0.1.2" } - -[dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-bonding/NOTICE b/contracts/cw20-bonding/NOTICE deleted file mode 100644 index a3cf0c354..000000000 --- a/contracts/cw20-bonding/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -CW20-Bonding: Bonding Curve to release CW20 token -Copyright 2020 Ethan Frey - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/contracts/cw20-bonding/README.md b/contracts/cw20-bonding/README.md deleted file mode 100644 index c16ba96bb..000000000 --- a/contracts/cw20-bonding/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# CW20 Bonding curve - -This builds on the [Basic CW20 interface](../../packages/cw20/README.md) -as implemented in [`cw20-base`](../cw20-base/README.md). - -This serves three purposes: - -* A usable and extensible contract for arbitrary bonding curves -* A demonstration of how to extend `cw20-base` to add extra functionality -* A demonstration of the [Receiver interface]([Basic CW20 interface](../../packages/cw20/README.md#receiver)) - -## Design - -There are two variants - accepting native tokens and accepting cw20 tokens -as the *reserve* token (this is the token that is input to the bonding curve). - -Minting: When the input is sent to the contract (either via `ExecuteMsg::Buy{}` -with native tokens, or via `ExecuteMsg::Receive{}` with cw20 tokens), -those tokens remain on the contract and it issues it's own token to the -sender's account (known as *supply* token). - -Burning: We override the burn function to not only burn the requested tokens, -but also release a proper number of the input tokens to the account that burnt -the custom token - -Curves: `handle` specifies a bonding function, which is sent to parameterize -`handle_fn` (which does all the work). The curve is set when compiling -the contract. In fact many contracts can just wrap `cw20-bonding` and -specify the custom curve parameter. - -Read more about [bonding curve math here](https://yos.io/2018/11/10/bonding-curves/) - -Note: the first version only accepts native tokens as the - -### Math - -Given a price curve `f(x)` = price of the `x`th token, we want to figure out -how to buy into and sell from the bonding curve. In fact we can look at -the total supply issued. let `F(x)` be the integral of `f(x)`. We have issued -`x` tokens for `F(x)` sent to the contract. Or, in reverse, if we send -`x` tokens to the contract, it will mint `F^-1(x)` tokens. - -From this we can create some formulas. Assume we currently have issued `S` -tokens in exchange for `N = F(S)` input tokens. If someone sends us `x` tokens, -how much will we issue? - -`F^-1(N+x) - F^-1(N)` = `F^-1(N+x) - S` - -And if we sell `x` tokens, how much we will get out: - -`F(S) - F(S-x)` = `N - F(S-x)` - -Just one calculation each side. To be safe, make sure to round down and -always check against `F(S)` when using `F^-1(S)` to estimate how much -should be issued. This will also safely give us how many tokens to return. - -There is built in support for safely [raising i128 to an integer power](https://doc.rust-lang.org/std/primitive.i128.html#method.checked_pow). -There is also a crate to [provide nth-root of for all integers](https://docs.rs/num-integer/0.1.43/num_integer/trait.Roots.html). -With these two, we can handle most math except for logs/exponents. - -Compare this to [writing it all in solidity](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7b7ff729b82ea73ea168e495d9c94cb901ae95ce/contracts/math/Power.sol) - -Examples: - -Price Constant: `f(x) = k` and `F(x) = kx` and `F^-1(x) = x/k` - -Price Linear: `f(x) = kx` and `F(x) = kx^2/2` and `F^-1(x) = (2x/k)^(0.5)` - -Price Square Root: `f(x) = x^0.5` and `F(x) = x^1.5/1.5` and `F^-1(x) = (1.5*x)^(2/3)` - -We will only implement these curves to start with, and leave it to others to import this with more complex curves, -such as logarithms. \ No newline at end of file diff --git a/contracts/cw20-bonding/examples/schema.rs b/contracts/cw20-bonding/examples/schema.rs deleted file mode 100644 index dcc0805bc..000000000 --- a/contracts/cw20-bonding/examples/schema.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw20::{AllowanceResponse, BalanceResponse, TokenInfoResponse}; -use cw20_bonding::msg::{CurveInfoResponse, ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); - export_schema(&schema_for!(AllowanceResponse), &out_dir); - export_schema(&schema_for!(BalanceResponse), &out_dir); - export_schema(&schema_for!(CurveInfoResponse), &out_dir); - export_schema(&schema_for!(TokenInfoResponse), &out_dir); -} diff --git a/contracts/cw20-bonding/src/contract.rs b/contracts/cw20-bonding/src/contract.rs deleted file mode 100644 index a3a33aed2..000000000 --- a/contracts/cw20-bonding/src/contract.rs +++ /dev/null @@ -1,636 +0,0 @@ -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; -use cosmwasm_std::{ - attr, coins, to_binary, Addr, BankMsg, Binary, Deps, DepsMut, Env, MessageInfo, Response, - StdError, StdResult, Uint128, -}; - -use cw2::set_contract_version; -use cw20_base::allowances::{ - deduct_allowance, execute_decrease_allowance, execute_increase_allowance, execute_send_from, - execute_transfer_from, query_allowance, -}; -use cw20_base::contract::{ - execute_burn, execute_mint, execute_send, execute_transfer, query_balance, query_token_info, -}; -use cw20_base::state::{MinterData, TokenInfo, TOKEN_INFO}; - -use crate::curves::DecimalPlaces; -use crate::error::ContractError; -use crate::msg::{CurveFn, CurveInfoResponse, ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{CurveState, CURVE_STATE, CURVE_TYPE}; -use cw_utils::{must_pay, nonpayable}; - -// version info for migration info -const CONTRACT_NAME: &str = "crates.io:cw20-bonding"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn instantiate( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: InstantiateMsg, -) -> Result { - nonpayable(&info)?; - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - - // store token info using cw20-base format - let data = TokenInfo { - name: msg.name, - symbol: msg.symbol, - decimals: msg.decimals, - total_supply: Uint128::zero(), - // set self as minter, so we can properly execute mint and burn - mint: Some(MinterData { - minter: env.contract.address, - cap: None, - }), - }; - TOKEN_INFO.save(deps.storage, &data)?; - - let places = DecimalPlaces::new(msg.decimals, msg.reserve_decimals); - let supply = CurveState::new(msg.reserve_denom, places); - CURVE_STATE.save(deps.storage, &supply)?; - - CURVE_TYPE.save(deps.storage, &msg.curve_type)?; - - Ok(Response::default()) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> Result { - // default implementation stores curve info as enum, you can do something else in a derived - // contract and just pass in your custom curve to do_execute - let curve_type = CURVE_TYPE.load(deps.storage)?; - let curve_fn = curve_type.to_curve_fn(); - do_execute(deps, env, info, msg, curve_fn) -} - -/// We pull out logic here, so we can import this from another contract and set a different Curve. -/// This contacts sets a curve with an enum in InstantiateMsg and stored in state, but you may want -/// to use custom math not included - make this easily reusable -pub fn do_execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: ExecuteMsg, - curve_fn: CurveFn, -) -> Result { - match msg { - ExecuteMsg::Buy {} => execute_buy(deps, env, info, curve_fn), - - // we override these from cw20 - ExecuteMsg::Burn { amount } => Ok(execute_sell(deps, env, info, curve_fn, amount)?), - ExecuteMsg::BurnFrom { owner, amount } => { - Ok(execute_sell_from(deps, env, info, curve_fn, owner, amount)?) - } - - // these all come from cw20-base to implement the cw20 standard - ExecuteMsg::Transfer { recipient, amount } => { - Ok(execute_transfer(deps, env, info, recipient, amount)?) - } - ExecuteMsg::Send { - contract, - amount, - msg, - } => Ok(execute_send(deps, env, info, contract, amount, msg)?), - ExecuteMsg::IncreaseAllowance { - spender, - amount, - expires, - } => Ok(execute_increase_allowance( - deps, env, info, spender, amount, expires, - )?), - ExecuteMsg::DecreaseAllowance { - spender, - amount, - expires, - } => Ok(execute_decrease_allowance( - deps, env, info, spender, amount, expires, - )?), - ExecuteMsg::TransferFrom { - owner, - recipient, - amount, - } => Ok(execute_transfer_from( - deps, env, info, owner, recipient, amount, - )?), - ExecuteMsg::SendFrom { - owner, - contract, - amount, - msg, - } => Ok(execute_send_from( - deps, env, info, owner, contract, amount, msg, - )?), - } -} - -pub fn execute_buy( - deps: DepsMut, - env: Env, - info: MessageInfo, - curve_fn: CurveFn, -) -> Result { - let mut state = CURVE_STATE.load(deps.storage)?; - - let payment = must_pay(&info, &state.reserve_denom)?; - - // calculate how many tokens can be purchased with this and mint them - let curve = curve_fn(state.decimals); - state.reserve += payment; - let new_supply = curve.supply(state.reserve); - let minted = new_supply - .checked_sub(state.supply) - .map_err(StdError::overflow)?; - state.supply = new_supply; - CURVE_STATE.save(deps.storage, &state)?; - - // call into cw20-base to mint the token, call as self as no one else is allowed - let sub_info = MessageInfo { - sender: env.contract.address.clone(), - funds: vec![], - }; - execute_mint(deps, env, sub_info, info.sender.to_string(), minted)?; - - // bond them to the validator - let res = Response::new() - .add_attribute("action", "buy") - .add_attribute("from", info.sender) - .add_attribute("reserve", payment) - .add_attribute("supply", minted); - Ok(res) -} - -pub fn execute_sell( - deps: DepsMut, - env: Env, - info: MessageInfo, - curve_fn: CurveFn, - amount: Uint128, -) -> Result { - nonpayable(&info)?; - let receiver = info.sender.clone(); - // do all the work - let mut res = do_sell(deps, env, info, curve_fn, receiver, amount)?; - - // add our custom attributes - res.attributes.push(attr("action", "burn")); - Ok(res) -} - -pub fn execute_sell_from( - deps: DepsMut, - env: Env, - info: MessageInfo, - curve_fn: CurveFn, - owner: String, - amount: Uint128, -) -> Result { - nonpayable(&info)?; - let owner_addr = deps.api.addr_validate(&owner)?; - let spender_addr = info.sender.clone(); - - // deduct allowance before doing anything else have enough allowance - deduct_allowance(deps.storage, &owner_addr, &spender_addr, &env.block, amount)?; - - // do all the work in do_sell - let receiver_addr = info.sender; - let owner_info = MessageInfo { - sender: owner_addr, - funds: info.funds, - }; - let mut res = do_sell( - deps, - env, - owner_info, - curve_fn, - receiver_addr.clone(), - amount, - )?; - - // add our custom attributes - res.attributes.push(attr("action", "burn_from")); - res.attributes.push(attr("by", receiver_addr)); - Ok(res) -} - -fn do_sell( - mut deps: DepsMut, - env: Env, - // info.sender is the one burning tokens - info: MessageInfo, - curve_fn: CurveFn, - // receiver is the one who gains (same for execute_sell, diff for execute_sell_from) - receiver: Addr, - amount: Uint128, -) -> Result { - // burn from the caller, this ensures there are tokens to cover this - execute_burn(deps.branch(), env, info.clone(), amount)?; - - // calculate how many tokens can be purchased with this and mint them - let mut state = CURVE_STATE.load(deps.storage)?; - let curve = curve_fn(state.decimals); - state.supply = state - .supply - .checked_sub(amount) - .map_err(StdError::overflow)?; - let new_reserve = curve.reserve(state.supply); - let released = state - .reserve - .checked_sub(new_reserve) - .map_err(StdError::overflow)?; - state.reserve = new_reserve; - CURVE_STATE.save(deps.storage, &state)?; - - // now send the tokens to the sender (TODO: for sell_from we do something else, right???) - let msg = BankMsg::Send { - to_address: receiver.to_string(), - amount: coins(released.u128(), state.reserve_denom), - }; - let res = Response::new() - .add_message(msg) - .add_attribute("from", info.sender) - .add_attribute("supply", amount) - .add_attribute("reserve", released); - Ok(res) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { - // default implementation stores curve info as enum, you can do something else in a derived - // contract and just pass in your custom curve to do_execute - let curve_type = CURVE_TYPE.load(deps.storage)?; - let curve_fn = curve_type.to_curve_fn(); - do_query(deps, env, msg, curve_fn) -} - -/// We pull out logic here, so we can import this from another contract and set a different Curve. -/// This contacts sets a curve with an enum in InstantitateMsg and stored in state, but you may want -/// to use custom math not included - make this easily reusable -pub fn do_query(deps: Deps, _env: Env, msg: QueryMsg, curve_fn: CurveFn) -> StdResult { - match msg { - // custom queries - QueryMsg::CurveInfo {} => to_binary(&query_curve_info(deps, curve_fn)?), - // inherited from cw20-base - QueryMsg::TokenInfo {} => to_binary(&query_token_info(deps)?), - QueryMsg::Balance { address } => to_binary(&query_balance(deps, address)?), - QueryMsg::Allowance { owner, spender } => { - to_binary(&query_allowance(deps, owner, spender)?) - } - } -} - -pub fn query_curve_info(deps: Deps, curve_fn: CurveFn) -> StdResult { - let CurveState { - reserve, - supply, - reserve_denom, - decimals, - } = CURVE_STATE.load(deps.storage)?; - - // This we can get from the local digits stored in instantiate - let curve = curve_fn(decimals); - let spot_price = curve.spot_price(supply); - - Ok(CurveInfoResponse { - reserve, - supply, - spot_price, - reserve_denom, - }) -} - -// this is poor mans "skip" flag -#[cfg(test)] -mod tests { - use super::*; - use crate::msg::CurveType; - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{coin, Decimal, OverflowError, OverflowOperation, StdError, SubMsg}; - use cw_utils::PaymentError; - - const DENOM: &str = "satoshi"; - const CREATOR: &str = "creator"; - const INVESTOR: &str = "investor"; - const BUYER: &str = "buyer"; - - fn default_instantiate( - decimals: u8, - reserve_decimals: u8, - curve_type: CurveType, - ) -> InstantiateMsg { - InstantiateMsg { - name: "Bonded".to_string(), - symbol: "EPOXY".to_string(), - decimals, - reserve_denom: DENOM.to_string(), - reserve_decimals, - curve_type, - } - } - - fn get_balance>(deps: Deps, addr: U) -> Uint128 { - query_balance(deps, addr.into()).unwrap().balance - } - - fn setup_test(deps: DepsMut, decimals: u8, reserve_decimals: u8, curve_type: CurveType) { - // this matches `linear_curve` test case from curves.rs - let creator = String::from(CREATOR); - let msg = default_instantiate(decimals, reserve_decimals, curve_type); - let info = mock_info(&creator, &[]); - - // make sure we can instantiate with this - let res = instantiate(deps, mock_env(), info, msg).unwrap(); - assert_eq!(0, res.messages.len()); - } - - #[test] - fn proper_instantiation() { - let mut deps = mock_dependencies(); - - // this matches `linear_curve` test case from curves.rs - let creator = String::from("creator"); - let curve_type = CurveType::SquareRoot { - slope: Uint128::new(1), - scale: 1, - }; - let msg = default_instantiate(2, 8, curve_type.clone()); - let info = mock_info(&creator, &[]); - - // make sure we can instantiate with this - let res = instantiate(deps.as_mut(), mock_env(), info, msg.clone()).unwrap(); - assert_eq!(0, res.messages.len()); - - // token info is proper - let token = query_token_info(deps.as_ref()).unwrap(); - assert_eq!(&token.name, &msg.name); - assert_eq!(&token.symbol, &msg.symbol); - assert_eq!(token.decimals, 2); - assert_eq!(token.total_supply, Uint128::zero()); - - // curve state is sensible - let state = query_curve_info(deps.as_ref(), curve_type.to_curve_fn()).unwrap(); - assert_eq!(state.reserve, Uint128::zero()); - assert_eq!(state.supply, Uint128::zero()); - assert_eq!(state.reserve_denom.as_str(), DENOM); - // spot price 0 as supply is 0 - assert_eq!(state.spot_price, Decimal::zero()); - - // curve type is stored properly - let curve = CURVE_TYPE.load(&deps.storage).unwrap(); - assert_eq!(curve_type, curve); - - // no balance - assert_eq!(get_balance(deps.as_ref(), &creator), Uint128::zero()); - } - - #[test] - fn buy_issues_tokens() { - let mut deps = mock_dependencies(); - let curve_type = CurveType::Linear { - slope: Uint128::new(1), - scale: 1, - }; - setup_test(deps.as_mut(), 2, 8, curve_type.clone()); - - // succeeds with proper token (5 BTC = 5*10^8 satoshi) - let info = mock_info(INVESTOR, &coins(500_000_000, DENOM)); - let buy = ExecuteMsg::Buy {}; - execute(deps.as_mut(), mock_env(), info, buy.clone()).unwrap(); - - // bob got 1000 EPOXY (10.00) - assert_eq!(get_balance(deps.as_ref(), INVESTOR), Uint128::new(1000)); - assert_eq!(get_balance(deps.as_ref(), BUYER), Uint128::zero()); - - // send them all to buyer - let info = mock_info(INVESTOR, &[]); - let send = ExecuteMsg::Transfer { - recipient: BUYER.into(), - amount: Uint128::new(1000), - }; - execute(deps.as_mut(), mock_env(), info, send).unwrap(); - - // ensure balances updated - assert_eq!(get_balance(deps.as_ref(), INVESTOR), Uint128::zero()); - assert_eq!(get_balance(deps.as_ref(), BUYER), Uint128::new(1000)); - - // second stake needs more to get next 1000 EPOXY - let info = mock_info(INVESTOR, &coins(1_500_000_000, DENOM)); - execute(deps.as_mut(), mock_env(), info, buy).unwrap(); - - // ensure balances updated - assert_eq!(get_balance(deps.as_ref(), INVESTOR), Uint128::new(1000)); - assert_eq!(get_balance(deps.as_ref(), BUYER), Uint128::new(1000)); - - // check curve info updated - let curve = query_curve_info(deps.as_ref(), curve_type.to_curve_fn()).unwrap(); - assert_eq!(curve.reserve, Uint128::new(2_000_000_000)); - assert_eq!(curve.supply, Uint128::new(2000)); - assert_eq!(curve.spot_price, Decimal::percent(200)); - - // check token info updated - let token = query_token_info(deps.as_ref()).unwrap(); - assert_eq!(token.decimals, 2); - assert_eq!(token.total_supply, Uint128::new(2000)); - } - - #[test] - fn bonding_fails_with_wrong_denom() { - let mut deps = mock_dependencies(); - let curve_type = CurveType::Linear { - slope: Uint128::new(1), - scale: 1, - }; - setup_test(deps.as_mut(), 2, 8, curve_type); - - // fails when no tokens sent - let info = mock_info(INVESTOR, &[]); - let buy = ExecuteMsg::Buy {}; - let err = execute(deps.as_mut(), mock_env(), info, buy.clone()).unwrap_err(); - assert_eq!(err, PaymentError::NoFunds {}.into()); - - // fails when wrong tokens sent - let info = mock_info(INVESTOR, &coins(1234567, "wei")); - let err = execute(deps.as_mut(), mock_env(), info, buy.clone()).unwrap_err(); - assert_eq!(err, PaymentError::MissingDenom(DENOM.into()).into()); - - // fails when too many tokens sent - let info = mock_info(INVESTOR, &[coin(3400022, DENOM), coin(1234567, "wei")]); - let err = execute(deps.as_mut(), mock_env(), info, buy).unwrap_err(); - assert_eq!(err, PaymentError::MultipleDenoms {}.into()); - } - - #[test] - fn burning_sends_reserve() { - let mut deps = mock_dependencies(); - let curve_type = CurveType::Linear { - slope: Uint128::new(1), - scale: 1, - }; - setup_test(deps.as_mut(), 2, 8, curve_type.clone()); - - // succeeds with proper token (20 BTC = 20*10^8 satoshi) - let info = mock_info(INVESTOR, &coins(2_000_000_000, DENOM)); - let buy = ExecuteMsg::Buy {}; - execute(deps.as_mut(), mock_env(), info, buy).unwrap(); - - // bob got 2000 EPOXY (20.00) - assert_eq!(get_balance(deps.as_ref(), INVESTOR), Uint128::new(2000)); - - // cannot burn too much - let info = mock_info(INVESTOR, &[]); - let burn = ExecuteMsg::Burn { - amount: Uint128::new(3000), - }; - let err = execute(deps.as_mut(), mock_env(), info, burn).unwrap_err(); - assert_eq!( - err, - ContractError::Base(cw20_base::ContractError::Std(StdError::overflow( - OverflowError::new(OverflowOperation::Sub, 2000, 3000) - ))) - ); - - // burn 1000 EPOXY to get back 15BTC (*10^8) - let info = mock_info(INVESTOR, &[]); - let burn = ExecuteMsg::Burn { - amount: Uint128::new(1000), - }; - let res = execute(deps.as_mut(), mock_env(), info, burn).unwrap(); - - // balance is lower - assert_eq!(get_balance(deps.as_ref(), INVESTOR), Uint128::new(1000)); - - // ensure we got our money back - assert_eq!(1, res.messages.len()); - assert_eq!( - &res.messages[0], - &SubMsg::new(BankMsg::Send { - to_address: INVESTOR.into(), - amount: coins(1_500_000_000, DENOM), - }) - ); - - // check curve info updated - let curve = query_curve_info(deps.as_ref(), curve_type.to_curve_fn()).unwrap(); - assert_eq!(curve.reserve, Uint128::new(500_000_000)); - assert_eq!(curve.supply, Uint128::new(1000)); - assert_eq!(curve.spot_price, Decimal::percent(100)); - - // check token info updated - let token = query_token_info(deps.as_ref()).unwrap(); - assert_eq!(token.decimals, 2); - assert_eq!(token.total_supply, Uint128::new(1000)); - } - - #[test] - fn cw20_imports_work() { - let mut deps = mock_dependencies(); - let curve_type = CurveType::Constant { - value: Uint128::new(15), - scale: 1, - }; - setup_test(deps.as_mut(), 9, 6, curve_type); - - let alice: &str = "alice"; - let bob: &str = "bobby"; - let carl: &str = "carl"; - - // spend 45_000 uatom for 30_000_000 EPOXY - let info = mock_info(bob, &coins(45_000, DENOM)); - let buy = ExecuteMsg::Buy {}; - execute(deps.as_mut(), mock_env(), info, buy).unwrap(); - - // check balances - assert_eq!(get_balance(deps.as_ref(), bob), Uint128::new(30_000_000)); - assert_eq!(get_balance(deps.as_ref(), carl), Uint128::zero()); - - // send coins to carl - let bob_info = mock_info(bob, &[]); - let transfer = ExecuteMsg::Transfer { - recipient: carl.into(), - amount: Uint128::new(2_000_000), - }; - execute(deps.as_mut(), mock_env(), bob_info.clone(), transfer).unwrap(); - assert_eq!(get_balance(deps.as_ref(), bob), Uint128::new(28_000_000)); - assert_eq!(get_balance(deps.as_ref(), carl), Uint128::new(2_000_000)); - - // allow alice - let allow = ExecuteMsg::IncreaseAllowance { - spender: alice.into(), - amount: Uint128::new(35_000_000), - expires: None, - }; - execute(deps.as_mut(), mock_env(), bob_info, allow).unwrap(); - assert_eq!(get_balance(deps.as_ref(), bob), Uint128::new(28_000_000)); - assert_eq!(get_balance(deps.as_ref(), alice), Uint128::zero()); - assert_eq!( - query_allowance(deps.as_ref(), bob.into(), alice.into()) - .unwrap() - .allowance, - Uint128::new(35_000_000) - ); - - // alice takes some for herself - let self_pay = ExecuteMsg::TransferFrom { - owner: bob.into(), - recipient: alice.into(), - amount: Uint128::new(25_000_000), - }; - let alice_info = mock_info(alice, &[]); - execute(deps.as_mut(), mock_env(), alice_info, self_pay).unwrap(); - assert_eq!(get_balance(deps.as_ref(), bob), Uint128::new(3_000_000)); - assert_eq!(get_balance(deps.as_ref(), alice), Uint128::new(25_000_000)); - assert_eq!(get_balance(deps.as_ref(), carl), Uint128::new(2_000_000)); - assert_eq!( - query_allowance(deps.as_ref(), bob.into(), alice.into()) - .unwrap() - .allowance, - Uint128::new(10_000_000) - ); - - // test burn from works properly (burn tested in burning_sends_reserve) - // cannot burn more than they have - - let info = mock_info(alice, &[]); - let burn_from = ExecuteMsg::BurnFrom { - owner: bob.into(), - amount: Uint128::new(3_300_000), - }; - let err = execute(deps.as_mut(), mock_env(), info, burn_from).unwrap_err(); - assert_eq!( - err, - ContractError::Base(cw20_base::ContractError::Std(StdError::overflow( - OverflowError::new(OverflowOperation::Sub, 3000000, 3300000) - ))) - ); - - // burn 1_000_000 EPOXY to get back 1_500 DENOM (constant curve) - let info = mock_info(alice, &[]); - let burn_from = ExecuteMsg::BurnFrom { - owner: bob.into(), - amount: Uint128::new(1_000_000), - }; - let res = execute(deps.as_mut(), mock_env(), info, burn_from).unwrap(); - - // bob balance is lower, not alice - assert_eq!(get_balance(deps.as_ref(), alice), Uint128::new(25_000_000)); - assert_eq!(get_balance(deps.as_ref(), bob), Uint128::new(2_000_000)); - - // ensure alice got our money back - assert_eq!(1, res.messages.len()); - assert_eq!( - &res.messages[0], - &SubMsg::new(BankMsg::Send { - to_address: alice.into(), - amount: coins(1_500, DENOM), - }) - ); - } -} diff --git a/contracts/cw20-bonding/src/curves.rs b/contracts/cw20-bonding/src/curves.rs deleted file mode 100644 index b4617ab99..000000000 --- a/contracts/cw20-bonding/src/curves.rs +++ /dev/null @@ -1,357 +0,0 @@ -use integer_cbrt::IntegerCubeRoot; -use integer_sqrt::IntegerSquareRoot; -use rust_decimal::prelude::ToPrimitive; -use rust_decimal::Decimal; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use std::str::FromStr; - -use cosmwasm_std::{Decimal as StdDecimal, Uint128}; - -/// This defines the curves we are using. -/// -/// I am struggling on what type to use for the math. Tokens are often stored as Uint128, -/// but they may have 6 or 9 digits. When using constant or linear functions, this doesn't matter -/// much, but for non-linear functions a lot more. Also, supply and reserve most likely have different -/// decimals... either we leave it for the callers to normalize and accept a `Decimal` input, -/// or we pass in `Uint128` as well as the decimal places for supply and reserve. -/// -/// After working the first route and realizing that `Decimal` is not all that great to work with -/// when you want to do more complex math than add and multiply `Uint128`, I decided to go the second -/// route. That made the signatures quite complex and my final idea was to pass in `supply_decimal` -/// and `reserve_decimal` in the curve constructors. -pub trait Curve { - /// Returns the spot price given the supply. - /// `f(x)` from the README - fn spot_price(&self, supply: Uint128) -> StdDecimal; - - /// Returns the total price paid up to purchase supply tokens (integral) - /// `F(x)` from the README - fn reserve(&self, supply: Uint128) -> Uint128; - - /// Inverse of reserve. Returns how many tokens would be issued - /// with a total paid amount of reserve. - /// `F^-1(x)` from the README - fn supply(&self, reserve: Uint128) -> Uint128; -} - -/// decimal returns an object = num * 10 ^ -scale -/// We use this function in contract.rs rather than call the crate constructor -/// itself, in case we want to swap out the implementation, we can do it only in this file. -pub fn decimal>(num: T, scale: u32) -> Decimal { - Decimal::from_i128_with_scale(num.into() as i128, scale) -} - -/// StdDecimal stores as a u128 with 18 decimal points of precision -fn decimal_to_std(x: Decimal) -> StdDecimal { - // this seems straight-forward (if inefficient), converting via string representation - // TODO: execute errors better? Result? - StdDecimal::from_str(&x.to_string()).unwrap() - - // // maybe a better approach doing math, not sure about rounding - // - // // try to preserve decimal points, max 9 - // let digits = min(x.scale(), 9); - // let multiplier = 10u128.pow(digits); - // - // // we multiply up before we round off to u128, - // // let StdDecimal do its best to keep these decimal places - // let nominator = (x * decimal(multiplier, 0)).to_u128().unwrap(); - // StdDecimal::from_ratio(nominator, multiplier) -} - -/// spot price is always a constant value -pub struct Constant { - pub value: Decimal, - pub normalize: DecimalPlaces, -} - -impl Constant { - pub fn new(value: Decimal, normalize: DecimalPlaces) -> Self { - Self { value, normalize } - } -} - -impl Curve for Constant { - // we need to normalize value with the reserve decimal places - // (eg 0.1 value would return 100_000 if reserve was uatom) - fn spot_price(&self, _supply: Uint128) -> StdDecimal { - // f(x) = self.value - decimal_to_std(self.value) - } - - /// Returns total number of reserve tokens needed to purchase a given number of supply tokens. - /// Note that both need to be normalized. - fn reserve(&self, supply: Uint128) -> Uint128 { - // f(x) = supply * self.value - let reserve = self.normalize.from_supply(supply) * self.value; - self.normalize.to_reserve(reserve) - } - - fn supply(&self, reserve: Uint128) -> Uint128 { - // f(x) = reserve / self.value - let supply = self.normalize.from_reserve(reserve) / self.value; - self.normalize.to_supply(supply) - } -} - -/// spot_price is slope * supply -pub struct Linear { - pub slope: Decimal, - pub normalize: DecimalPlaces, -} - -impl Linear { - pub fn new(slope: Decimal, normalize: DecimalPlaces) -> Self { - Self { slope, normalize } - } -} - -impl Curve for Linear { - fn spot_price(&self, supply: Uint128) -> StdDecimal { - // f(x) = supply * self.value - let out = self.normalize.from_supply(supply) * self.slope; - decimal_to_std(out) - } - - fn reserve(&self, supply: Uint128) -> Uint128 { - // f(x) = self.slope * supply * supply / 2 - let normalized = self.normalize.from_supply(supply); - let square = normalized * normalized; - // Note: multiplying by 0.5 is much faster than dividing by 2 - let reserve = square * self.slope * Decimal::new(5, 1); - self.normalize.to_reserve(reserve) - } - - fn supply(&self, reserve: Uint128) -> Uint128 { - // f(x) = (2 * reserve / self.slope) ^ 0.5 - // note: use addition here to optimize 2* operation - let square = self.normalize.from_reserve(reserve + reserve) / self.slope; - let supply = square_root(square); - self.normalize.to_supply(supply) - } -} - -/// spot_price is slope * (supply)^0.5 -pub struct SquareRoot { - pub slope: Decimal, - pub normalize: DecimalPlaces, -} - -impl SquareRoot { - pub fn new(slope: Decimal, normalize: DecimalPlaces) -> Self { - Self { slope, normalize } - } -} - -impl Curve for SquareRoot { - fn spot_price(&self, supply: Uint128) -> StdDecimal { - // f(x) = self.slope * supply^0.5 - let square = self.normalize.from_supply(supply); - let root = square_root(square); - decimal_to_std(root * self.slope) - } - - fn reserve(&self, supply: Uint128) -> Uint128 { - // f(x) = self.slope * supply * supply^0.5 / 1.5 - let normalized = self.normalize.from_supply(supply); - let root = square_root(normalized); - let reserve = self.slope * normalized * root / Decimal::new(15, 1); - self.normalize.to_reserve(reserve) - } - - fn supply(&self, reserve: Uint128) -> Uint128 { - // f(x) = (1.5 * reserve / self.slope) ^ (2/3) - let base = self.normalize.from_reserve(reserve) * Decimal::new(15, 1) / self.slope; - let squared = base * base; - let supply = cube_root(squared); - self.normalize.to_supply(supply) - } -} - -// we multiply by 10^18, turn to int, take square root, then divide by 10^9 as we convert back to decimal -fn square_root(square: Decimal) -> Decimal { - // must be even - // TODO: this can overflow easily at 18... what is a good value? - const EXTRA_DIGITS: u32 = 12; - let multiplier = 10u128.saturating_pow(EXTRA_DIGITS); - - // multiply by 10^18 and turn to u128 - let extended = square * decimal(multiplier, 0); - let extended = extended.floor().to_u128().unwrap(); - - // take square root, and build a decimal again - let root = extended.integer_sqrt(); - decimal(root, EXTRA_DIGITS / 2) -} - -// we multiply by 10^9, turn to int, take cube root, then divide by 10^3 as we convert back to decimal -fn cube_root(cube: Decimal) -> Decimal { - // must be multiple of 3 - // TODO: what is a good value? - const EXTRA_DIGITS: u32 = 9; - let multiplier = 10u128.saturating_pow(EXTRA_DIGITS); - - // multiply out and turn to u128 - let extended = cube * decimal(multiplier, 0); - let extended = extended.floor().to_u128().unwrap(); - - // take cube root, and build a decimal again - let root = extended.integer_cbrt(); - decimal(root, EXTRA_DIGITS / 3) -} - -/// DecimalPlaces should be passed into curve constructors -#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, JsonSchema, Default)] -pub struct DecimalPlaces { - /// Number of decimal places for the supply token (this is what was passed in cw20-base instantiate - pub supply: u32, - /// Number of decimal places for the reserve token (eg. 6 for uatom, 9 for nstep, 18 for wei) - pub reserve: u32, -} - -impl DecimalPlaces { - pub fn new(supply: u8, reserve: u8) -> Self { - DecimalPlaces { - supply: supply as u32, - reserve: reserve as u32, - } - } - - pub fn to_reserve(self, reserve: Decimal) -> Uint128 { - let factor = decimal(10u128.pow(self.reserve), 0); - let out = reserve * factor; - // TODO: execute overflow better? Result? - out.floor().to_u128().unwrap().into() - } - - pub fn to_supply(self, supply: Decimal) -> Uint128 { - let factor = decimal(10u128.pow(self.supply), 0); - let out = supply * factor; - // TODO: execute overflow better? Result? - out.floor().to_u128().unwrap().into() - } - - pub fn from_supply(&self, supply: Uint128) -> Decimal { - decimal(supply, self.supply) - } - - pub fn from_reserve(&self, reserve: Uint128) -> Decimal { - decimal(reserve, self.reserve) - } -} - -#[cfg(test)] -mod tests { - use super::*; - // TODO: test DecimalPlaces return proper decimals - - #[test] - fn constant_curve() { - // supply is nstep (9), reserve is uatom (6) - let normalize = DecimalPlaces::new(9, 6); - let curve = Constant::new(decimal(15u128, 1), normalize); - - // do some sanity checks.... - // spot price is always 1.5 ATOM - assert_eq!( - StdDecimal::percent(150), - curve.spot_price(Uint128::new(123)) - ); - - // if we have 30 STEP, we should have 45 ATOM - let reserve = curve.reserve(Uint128::new(30_000_000_000)); - assert_eq!(Uint128::new(45_000_000), reserve); - - // if we have 36 ATOM, we should have 24 STEP - let supply = curve.supply(Uint128::new(36_000_000)); - assert_eq!(Uint128::new(24_000_000_000), supply); - } - - #[test] - fn linear_curve() { - // supply is usdt (2), reserve is btc (8) - let normalize = DecimalPlaces::new(2, 8); - // slope is 0.1 (eg hits 1.0 after 10btc) - let curve = Linear::new(decimal(1u128, 1), normalize); - - // do some sanity checks.... - // spot price is 0.1 with 1 USDT supply - assert_eq!( - StdDecimal::permille(100), - curve.spot_price(Uint128::new(100)) - ); - // spot price is 1.7 with 17 USDT supply - assert_eq!( - StdDecimal::permille(1700), - curve.spot_price(Uint128::new(1700)) - ); - // spot price is 0.212 with 2.12 USDT supply - assert_eq!( - StdDecimal::permille(212), - curve.spot_price(Uint128::new(212)) - ); - - // if we have 10 USDT, we should have 5 BTC - let reserve = curve.reserve(Uint128::new(1000)); - assert_eq!(Uint128::new(500_000_000), reserve); - // if we have 20 USDT, we should have 20 BTC - let reserve = curve.reserve(Uint128::new(2000)); - assert_eq!(Uint128::new(2_000_000_000), reserve); - - // if we have 1.25 BTC, we should have 5 USDT - let supply = curve.supply(Uint128::new(125_000_000)); - assert_eq!(Uint128::new(500), supply); - // test square root rounding - // TODO: test when supply has many more decimal places than reserve - // if we have 1.11 BTC, we should have 4.7116875957... USDT - let supply = curve.supply(Uint128::new(111_000_000)); - assert_eq!(Uint128::new(471), supply); - } - - #[test] - fn sqrt_curve() { - // supply is utree (6) reserve is chf (2) - let normalize = DecimalPlaces::new(6, 2); - // slope is 0.35 (eg hits 0.35 after 1 chf, 3.5 after 100chf) - let curve = SquareRoot::new(decimal(35u128, 2), normalize); - - // do some sanity checks.... - // spot price is 0.35 with 1 TREE supply - assert_eq!( - StdDecimal::percent(35), - curve.spot_price(Uint128::new(1_000_000)) - ); - // spot price is 3.5 with 100 TREE supply - assert_eq!( - StdDecimal::percent(350), - curve.spot_price(Uint128::new(100_000_000)) - ); - // spot price should be 23.478713763747788 with 4500 TREE supply (test rounding and reporting here) - // rounds off around 8-9 sig figs (note diff for last points) - assert_eq!( - StdDecimal::from_ratio(2347871365u128, 100_000_000u128), - curve.spot_price(Uint128::new(4_500_000_000)) - ); - - // if we have 1 TREE, we should have 0.2333333333333 CHF - let reserve = curve.reserve(Uint128::new(1_000_000)); - assert_eq!(Uint128::new(23), reserve); - // if we have 100 TREE, we should have 233.333333333 CHF - let reserve = curve.reserve(Uint128::new(100_000_000)); - assert_eq!(Uint128::new(23_333), reserve); - // test rounding - // if we have 235 TREE, we should have 840.5790828021146 CHF - let reserve = curve.reserve(Uint128::new(235_000_000)); - assert_eq!(Uint128::new(84_057), reserve); // round down - - // // if we have 0.23 CHF, we should have 0.990453 TREE (round down) - let supply = curve.supply(Uint128::new(23)); - assert_eq!(Uint128::new(990_000), supply); - // if we have 840.58 CHF, we should have 235.000170 TREE (round down) - let supply = curve.supply(Uint128::new(84058)); - assert_eq!(Uint128::new(235_000_000), supply); - } - - // Idea: generic test that curve.supply(curve.reserve(supply)) == supply (or within some small rounding margin) -} diff --git a/contracts/cw20-bonding/src/error.rs b/contracts/cw20-bonding/src/error.rs deleted file mode 100644 index aa6bcc9ab..000000000 --- a/contracts/cw20-bonding/src/error.rs +++ /dev/null @@ -1,18 +0,0 @@ -use cosmwasm_std::StdError; -use cw_utils::PaymentError; -use thiserror::Error; - -#[derive(Error, Debug, PartialEq)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("{0}")] - Base(#[from] cw20_base::ContractError), - - #[error("{0}")] - Payment(#[from] PaymentError), - - #[error("Unauthorized")] - Unauthorized {}, -} diff --git a/contracts/cw20-bonding/src/lib.rs b/contracts/cw20-bonding/src/lib.rs deleted file mode 100644 index 8ecd1fa67..000000000 --- a/contracts/cw20-bonding/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod contract; -pub mod curves; -mod error; -pub mod msg; -pub mod state; - -pub use crate::error::ContractError; diff --git a/contracts/cw20-bonding/src/msg.rs b/contracts/cw20-bonding/src/msg.rs deleted file mode 100644 index 3bb201c4a..000000000 --- a/contracts/cw20-bonding/src/msg.rs +++ /dev/null @@ -1,145 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use crate::curves::{decimal, Constant, Curve, DecimalPlaces, Linear, SquareRoot}; -use cosmwasm_std::{Binary, Decimal, Uint128}; -use cw20::Expiration; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct InstantiateMsg { - /// name of the supply token - pub name: String, - /// symbol / ticker of the supply token - pub symbol: String, - /// number of decimal places of the supply token, needed for proper curve math. - /// If it is eg. BTC, where a balance of 10^8 means 1 BTC, then use 8 here. - pub decimals: u8, - - /// this is the reserve token denom (only support native for now) - pub reserve_denom: String, - /// number of decimal places for the reserve token, needed for proper curve math. - /// Same format as decimals above, eg. if it is uatom, where 1 unit is 10^-6 ATOM, use 6 here - pub reserve_decimals: u8, - - /// enum to store the curve parameters used for this contract - /// if you want to add a custom Curve, you should make a new contract that imports this one. - /// write a custom `instantiate`, and then dispatch `your::execute` -> `cw20_bonding::do_execute` - /// with your custom curve as a parameter (and same with `query` -> `do_query`) - pub curve_type: CurveType, -} - -pub type CurveFn = Box Box>; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum CurveType { - /// Constant always returns `value * 10^-scale` as spot price - Constant { value: Uint128, scale: u32 }, - /// Linear returns `slope * 10^-scale * supply` as spot price - Linear { slope: Uint128, scale: u32 }, - /// SquareRoot returns `slope * 10^-scale * supply^0.5` as spot price - SquareRoot { slope: Uint128, scale: u32 }, -} - -impl CurveType { - pub fn to_curve_fn(&self) -> CurveFn { - match self.clone() { - CurveType::Constant { value, scale } => { - let calc = move |places| -> Box { - Box::new(Constant::new(decimal(value, scale), places)) - }; - Box::new(calc) - } - CurveType::Linear { slope, scale } => { - let calc = move |places| -> Box { - Box::new(Linear::new(decimal(slope, scale), places)) - }; - Box::new(calc) - } - CurveType::SquareRoot { slope, scale } => { - let calc = move |places| -> Box { - Box::new(SquareRoot::new(decimal(slope, scale), places)) - }; - Box::new(calc) - } - } - } -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg { - /// Buy will attempt to purchase as many supply tokens as possible. - /// You must send only reserve tokens in that message - Buy {}, - - /// Implements CW20. Transfer is a base message to move tokens to another account without triggering actions - Transfer { recipient: String, amount: Uint128 }, - /// Implements CW20. Burn is a base message to destroy tokens forever - Burn { amount: Uint128 }, - /// Implements CW20. Send is a base message to transfer tokens to a contract and trigger an action - /// on the receiving contract. - Send { - contract: String, - amount: Uint128, - msg: Binary, - }, - /// Implements CW20 "approval" extension. Allows spender to access an additional amount tokens - /// from the owner's (env.sender) account. If expires is Some(), overwrites current allowance - /// expiration with this one. - IncreaseAllowance { - spender: String, - amount: Uint128, - expires: Option, - }, - /// Implements CW20 "approval" extension. Lowers the spender's access of tokens - /// from the owner's (env.sender) account by amount. If expires is Some(), overwrites current - /// allowance expiration with this one. - DecreaseAllowance { - spender: String, - amount: Uint128, - expires: Option, - }, - /// Implements CW20 "approval" extension. Transfers amount tokens from owner -> recipient - /// if `env.sender` has sufficient pre-approval. - TransferFrom { - owner: String, - recipient: String, - amount: Uint128, - }, - /// Implements CW20 "approval" extension. Sends amount tokens from owner -> contract - /// if `env.sender` has sufficient pre-approval. - SendFrom { - owner: String, - contract: String, - amount: Uint128, - msg: Binary, - }, - /// Implements CW20 "approval" extension. Destroys tokens forever - BurnFrom { owner: String, amount: Uint128 }, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum QueryMsg { - /// Returns the reserve and supply quantities, as well as the spot price to buy 1 token - CurveInfo {}, - - /// Implements CW20. Returns the current balance of the given address, 0 if unset. - Balance { address: String }, - /// Implements CW20. Returns metadata on the contract - name, decimals, supply, etc. - TokenInfo {}, - /// Implements CW20 "allowance" extension. - /// Returns how much spender can use from owner account, 0 if unset. - Allowance { owner: String, spender: String }, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct CurveInfoResponse { - // how many reserve tokens have been received - pub reserve: Uint128, - // how many supply tokens have been issued - pub supply: Uint128, - pub spot_price: Decimal, - pub reserve_denom: String, -} diff --git a/contracts/cw20-bonding/src/state.rs b/contracts/cw20-bonding/src/state.rs deleted file mode 100644 index 1a54d43de..000000000 --- a/contracts/cw20-bonding/src/state.rs +++ /dev/null @@ -1,38 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::Uint128; -use cw_storage_plus::Item; - -use crate::curves::DecimalPlaces; -use crate::msg::CurveType; - -/// Supply is dynamic and tracks the current supply of staked and ERC20 tokens. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, Default)] -pub struct CurveState { - /// reserve is how many native tokens exist bonded to the validator - pub reserve: Uint128, - /// supply is how many tokens this contract has issued - pub supply: Uint128, - - // the denom of the reserve token - pub reserve_denom: String, - - // how to normalize reserve and supply - pub decimals: DecimalPlaces, -} - -impl CurveState { - pub fn new(reserve_denom: String, decimals: DecimalPlaces) -> Self { - CurveState { - reserve: Uint128::zero(), - supply: Uint128::zero(), - reserve_denom, - decimals, - } - } -} - -pub const CURVE_STATE: Item = Item::new("curve_state"); - -pub const CURVE_TYPE: Item = Item::new("curve_type"); diff --git a/contracts/cw20-escrow/.cargo/config b/contracts/cw20-escrow/.cargo/config deleted file mode 100644 index 8d4bc738b..000000000 --- a/contracts/cw20-escrow/.cargo/config +++ /dev/null @@ -1,6 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib" -integration-test = "test --test integration" -schema = "run --example schema" diff --git a/contracts/cw20-escrow/Cargo.toml b/contracts/cw20-escrow/Cargo.toml deleted file mode 100644 index 1f5f93afa..000000000 --- a/contracts/cw20-escrow/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -[package] -name = "cw20-escrow" -version = "0.11.1" -authors = ["Ethan Frey "] -edition = "2018" -description = "Implementation of an escrow that accepts CosmWasm-20 tokens as well as native tokens" -license = "Apache-2.0" -repository = "https://github.com/CosmWasm/cw-plus" -homepage = "https://cosmwasm.com" -documentation = "https://docs.cosmwasm.com" - -[lib] -crate-type = ["cdylib", "rlib"] - -[features] -backtraces = ["cosmwasm-std/backtraces"] -# use library feature to disable all instantiate/execute/query exports -library = [] - -[dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw20 = { path = "../../packages/cw20", version = "0.11.1" } -cosmwasm-std = { version = "1.0.0-beta3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } -schemars = "0.8.1" -serde = { version = "1.0.103", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.23" } - -[dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1" } -cw20-base = { path = "../cw20-base", version = "0.11.1", features = ["library"] } diff --git a/contracts/cw20-escrow/NOTICE b/contracts/cw20-escrow/NOTICE deleted file mode 100644 index 8e53cb532..000000000 --- a/contracts/cw20-escrow/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -CW20-Escrow: A CosmWasm escrow contract that handles native and cw20 tokens -Copyright (C) 2020 Confio OÜ - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/contracts/cw20-escrow/README.md b/contracts/cw20-escrow/README.md deleted file mode 100644 index 3b04148ac..000000000 --- a/contracts/cw20-escrow/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# CW20 Escrow - -This is an escrow meta-contract that allows multiple users to -create independent escrows. Each escrow has a sender, recipient, -and arbiter. It also has a unique id (for future calls to reference it) -and an optional timeout. - -The basic function is the sender creates an escrow with funds. -The arbiter may at any time decide to release the funds to either -the intended recipient or the original sender (but no one else), -and if it passes with optional timeout, anyone can refund the locked -tokens to the original sender. - -We also add a function called "top_up", which allows anyone to add more -funds to the contract at any time. - -## Token types - -This contract is meant not just to be functional, but also to work as a simple -example of an CW20 "Receiver". And demonstrate how the same calls can be fed -native tokens (via typical `ExecuteMsg` route), or cw20 tokens (via `Receiver` interface). - -Both `create` and `top_up` can be called directly (with a payload of native tokens), -or from a cw20 contract using the [Receiver Interface](../../packages/cw20/README.md#receiver). -This means we can load the escrow with any number of native or cw20 tokens (or a mix), -allow of which get released when the arbiter decides. - -## Running this contract - -You will need Rust 1.44.1+ with `wasm32-unknown-unknown` target installed. - -You can run unit tests on this via: - -`cargo test` - -Once you are happy with the content, you can compile it to wasm via: - -``` -RUSTFLAGS='-C link-arg=-s' cargo wasm -cp ../../target/wasm32-unknown-unknown/release/cw20_escrow.wasm . -ls -l cw20_escrow.wasm -sha256sum cw20_escrow.wasm -``` - -Or for a production-ready (optimized) build, run a build command in the -the repository root: https://github.com/CosmWasm/cw-plus#compiling. diff --git a/contracts/cw20-escrow/examples/schema.rs b/contracts/cw20-escrow/examples/schema.rs deleted file mode 100644 index e290178b2..000000000 --- a/contracts/cw20-escrow/examples/schema.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw20_escrow::msg::{ - DetailsResponse, ExecuteMsg, InstantiateMsg, ListResponse, QueryMsg, ReceiveMsg, -}; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); - export_schema(&schema_for!(ReceiveMsg), &out_dir); - export_schema(&schema_for!(DetailsResponse), &out_dir); - export_schema(&schema_for!(ListResponse), &out_dir); -} diff --git a/contracts/cw20-escrow/src/contract.rs b/contracts/cw20-escrow/src/contract.rs deleted file mode 100644 index f7d477ebf..000000000 --- a/contracts/cw20-escrow/src/contract.rs +++ /dev/null @@ -1,603 +0,0 @@ -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; -use cosmwasm_std::{ - from_binary, to_binary, Addr, BankMsg, Binary, Deps, DepsMut, Env, MessageInfo, Response, - StdResult, SubMsg, WasmMsg, -}; - -use cw2::set_contract_version; -use cw20::{Balance, Cw20Coin, Cw20CoinVerified, Cw20ExecuteMsg, Cw20ReceiveMsg}; - -use crate::error::ContractError; -use crate::msg::{ - CreateMsg, DetailsResponse, ExecuteMsg, InstantiateMsg, ListResponse, QueryMsg, ReceiveMsg, -}; -use crate::state::{all_escrow_ids, Escrow, GenericBalance, ESCROWS}; - -// version info for migration info -const CONTRACT_NAME: &str = "crates.io:cw20-escrow"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn instantiate( - deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: InstantiateMsg, -) -> StdResult { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - // no setup - Ok(Response::default()) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> Result { - match msg { - ExecuteMsg::Create(msg) => { - execute_create(deps, msg, Balance::from(info.funds), &info.sender) - } - ExecuteMsg::Approve { id } => execute_approve(deps, env, info, id), - ExecuteMsg::TopUp { id } => execute_top_up(deps, id, Balance::from(info.funds)), - ExecuteMsg::Refund { id } => execute_refund(deps, env, info, id), - ExecuteMsg::Receive(msg) => execute_receive(deps, info, msg), - } -} - -pub fn execute_receive( - deps: DepsMut, - info: MessageInfo, - wrapper: Cw20ReceiveMsg, -) -> Result { - let msg: ReceiveMsg = from_binary(&wrapper.msg)?; - let balance = Balance::Cw20(Cw20CoinVerified { - address: info.sender, - amount: wrapper.amount, - }); - let api = deps.api; - match msg { - ReceiveMsg::Create(msg) => { - execute_create(deps, msg, balance, &api.addr_validate(&wrapper.sender)?) - } - ReceiveMsg::TopUp { id } => execute_top_up(deps, id, balance), - } -} - -pub fn execute_create( - deps: DepsMut, - msg: CreateMsg, - balance: Balance, - sender: &Addr, -) -> Result { - if balance.is_empty() { - return Err(ContractError::EmptyBalance {}); - } - - let mut cw20_whitelist = msg.addr_whitelist(deps.api)?; - - let escrow_balance = match balance { - Balance::Native(balance) => GenericBalance { - native: balance.0, - cw20: vec![], - }, - Balance::Cw20(token) => { - // make sure the token sent is on the whitelist by default - if !cw20_whitelist.iter().any(|t| t == &token.address) { - cw20_whitelist.push(token.address.clone()) - } - GenericBalance { - native: vec![], - cw20: vec![token], - } - } - }; - - let escrow = Escrow { - arbiter: deps.api.addr_validate(&msg.arbiter)?, - recipient: deps.api.addr_validate(&msg.recipient)?, - source: sender.clone(), - end_height: msg.end_height, - end_time: msg.end_time, - balance: escrow_balance, - cw20_whitelist, - }; - - // try to store it, fail if the id was already in use - ESCROWS.update(deps.storage, &msg.id, |existing| match existing { - None => Ok(escrow), - Some(_) => Err(ContractError::AlreadyInUse {}), - })?; - - let res = Response::new().add_attributes(vec![("action", "create"), ("id", msg.id.as_str())]); - Ok(res) -} - -pub fn execute_top_up( - deps: DepsMut, - id: String, - balance: Balance, -) -> Result { - if balance.is_empty() { - return Err(ContractError::EmptyBalance {}); - } - // this fails is no escrow there - let mut escrow = ESCROWS.load(deps.storage, &id)?; - - if let Balance::Cw20(token) = &balance { - // ensure the token is on the whitelist - if !escrow.cw20_whitelist.iter().any(|t| t == &token.address) { - return Err(ContractError::NotInWhitelist {}); - } - }; - - escrow.balance.add_tokens(balance); - - // and save - ESCROWS.save(deps.storage, &id, &escrow)?; - - let res = Response::new().add_attributes(vec![("action", "top_up"), ("id", id.as_str())]); - Ok(res) -} - -pub fn execute_approve( - deps: DepsMut, - env: Env, - info: MessageInfo, - id: String, -) -> Result { - // this fails is no escrow there - let escrow = ESCROWS.load(deps.storage, &id)?; - - if info.sender != escrow.arbiter { - Err(ContractError::Unauthorized {}) - } else if escrow.is_expired(&env) { - Err(ContractError::Expired {}) - } else { - // we delete the escrow - ESCROWS.remove(deps.storage, &id); - - // send all tokens out - let messages: Vec = send_tokens(&escrow.recipient, &escrow.balance)?; - - Ok(Response::new() - .add_attribute("action", "approve") - .add_attribute("id", id) - .add_attribute("to", escrow.recipient) - .add_submessages(messages)) - } -} - -pub fn execute_refund( - deps: DepsMut, - env: Env, - info: MessageInfo, - id: String, -) -> Result { - // this fails is no escrow there - let escrow = ESCROWS.load(deps.storage, &id)?; - - // the arbiter can send anytime OR anyone can send after expiration - if !escrow.is_expired(&env) && info.sender != escrow.arbiter { - Err(ContractError::Unauthorized {}) - } else { - // we delete the escrow - ESCROWS.remove(deps.storage, &id); - - // send all tokens out - let messages = send_tokens(&escrow.source, &escrow.balance)?; - - Ok(Response::new() - .add_attribute("action", "refund") - .add_attribute("id", id) - .add_attribute("to", escrow.source) - .add_submessages(messages)) - } -} - -fn send_tokens(to: &Addr, balance: &GenericBalance) -> StdResult> { - let native_balance = &balance.native; - let mut msgs: Vec = if native_balance.is_empty() { - vec![] - } else { - vec![SubMsg::new(BankMsg::Send { - to_address: to.into(), - amount: native_balance.to_vec(), - })] - }; - - let cw20_balance = &balance.cw20; - let cw20_msgs: StdResult> = cw20_balance - .iter() - .map(|c| { - let msg = Cw20ExecuteMsg::Transfer { - recipient: to.into(), - amount: c.amount, - }; - let exec = SubMsg::new(WasmMsg::Execute { - contract_addr: c.address.to_string(), - msg: to_binary(&msg)?, - funds: vec![], - }); - Ok(exec) - }) - .collect(); - msgs.append(&mut cw20_msgs?); - Ok(msgs) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::List {} => to_binary(&query_list(deps)?), - QueryMsg::Details { id } => to_binary(&query_details(deps, id)?), - } -} - -fn query_details(deps: Deps, id: String) -> StdResult { - let escrow = ESCROWS.load(deps.storage, &id)?; - - let cw20_whitelist = escrow.human_whitelist(); - - // transform tokens - let native_balance = escrow.balance.native; - - let cw20_balance: StdResult> = escrow - .balance - .cw20 - .into_iter() - .map(|token| { - Ok(Cw20Coin { - address: token.address.into(), - amount: token.amount, - }) - }) - .collect(); - - let details = DetailsResponse { - id, - arbiter: escrow.arbiter.into(), - recipient: escrow.recipient.into(), - source: escrow.source.into(), - end_height: escrow.end_height, - end_time: escrow.end_time, - native_balance, - cw20_balance: cw20_balance?, - cw20_whitelist, - }; - Ok(details) -} - -fn query_list(deps: Deps) -> StdResult { - Ok(ListResponse { - escrows: all_escrow_ids(deps.storage)?, - }) -} - -#[cfg(test)] -mod tests { - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{coin, coins, CosmosMsg, StdError, Uint128}; - - use crate::msg::ExecuteMsg::TopUp; - - use super::*; - - #[test] - fn happy_path_native() { - let mut deps = mock_dependencies(); - - // instantiate an empty contract - let instantiate_msg = InstantiateMsg {}; - let info = mock_info(&String::from("anyone"), &[]); - let res = instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // create an escrow - let create = CreateMsg { - id: "foobar".to_string(), - arbiter: String::from("arbitrate"), - recipient: String::from("recd"), - end_time: None, - end_height: Some(123456), - cw20_whitelist: None, - }; - let sender = String::from("source"); - let balance = coins(100, "tokens"); - let info = mock_info(&sender, &balance); - let msg = ExecuteMsg::Create(create.clone()); - let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(0, res.messages.len()); - assert_eq!(("action", "create"), res.attributes[0]); - - // ensure the details is what we expect - let details = query_details(deps.as_ref(), "foobar".to_string()).unwrap(); - assert_eq!( - details, - DetailsResponse { - id: "foobar".to_string(), - arbiter: String::from("arbitrate"), - recipient: String::from("recd"), - source: String::from("source"), - end_height: Some(123456), - end_time: None, - native_balance: balance.clone(), - cw20_balance: vec![], - cw20_whitelist: vec![], - } - ); - - // approve it - let id = create.id.clone(); - let info = mock_info(&create.arbiter, &[]); - let res = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Approve { id }).unwrap(); - assert_eq!(1, res.messages.len()); - assert_eq!(("action", "approve"), res.attributes[0]); - assert_eq!( - res.messages[0], - SubMsg::new(CosmosMsg::Bank(BankMsg::Send { - to_address: create.recipient, - amount: balance, - })) - ); - - // second attempt fails (not found) - let id = create.id.clone(); - let info = mock_info(&create.arbiter, &[]); - let err = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Approve { id }).unwrap_err(); - assert!(matches!(err, ContractError::Std(StdError::NotFound { .. }))); - } - - #[test] - fn happy_path_cw20() { - let mut deps = mock_dependencies(); - - // instantiate an empty contract - let instantiate_msg = InstantiateMsg {}; - let info = mock_info(&String::from("anyone"), &[]); - let res = instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // create an escrow - let create = CreateMsg { - id: "foobar".to_string(), - arbiter: String::from("arbitrate"), - recipient: String::from("recd"), - end_time: None, - end_height: None, - cw20_whitelist: Some(vec![String::from("other-token")]), - }; - let receive = Cw20ReceiveMsg { - sender: String::from("source"), - amount: Uint128::new(100), - msg: to_binary(&ExecuteMsg::Create(create.clone())).unwrap(), - }; - let token_contract = String::from("my-cw20-token"); - let info = mock_info(&token_contract, &[]); - let msg = ExecuteMsg::Receive(receive.clone()); - let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(0, res.messages.len()); - assert_eq!(("action", "create"), res.attributes[0]); - - // ensure the whitelist is what we expect - let details = query_details(deps.as_ref(), "foobar".to_string()).unwrap(); - assert_eq!( - details, - DetailsResponse { - id: "foobar".to_string(), - arbiter: String::from("arbitrate"), - recipient: String::from("recd"), - source: String::from("source"), - end_height: None, - end_time: None, - native_balance: vec![], - cw20_balance: vec![Cw20Coin { - address: String::from("my-cw20-token"), - amount: Uint128::new(100), - }], - cw20_whitelist: vec![String::from("other-token"), String::from("my-cw20-token")], - } - ); - - // approve it - let id = create.id.clone(); - let info = mock_info(&create.arbiter, &[]); - let res = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Approve { id }).unwrap(); - assert_eq!(1, res.messages.len()); - assert_eq!(("action", "approve"), res.attributes[0]); - let send_msg = Cw20ExecuteMsg::Transfer { - recipient: create.recipient, - amount: receive.amount, - }; - assert_eq!( - res.messages[0], - SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: token_contract, - msg: to_binary(&send_msg).unwrap(), - funds: vec![] - })) - ); - - // second attempt fails (not found) - let id = create.id.clone(); - let info = mock_info(&create.arbiter, &[]); - let err = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Approve { id }).unwrap_err(); - assert!(matches!(err, ContractError::Std(StdError::NotFound { .. }))); - } - - #[test] - fn add_tokens_proper() { - let mut tokens = GenericBalance::default(); - tokens.add_tokens(Balance::from(vec![coin(123, "atom"), coin(789, "eth")])); - tokens.add_tokens(Balance::from(vec![coin(456, "atom"), coin(12, "btc")])); - assert_eq!( - tokens.native, - vec![coin(579, "atom"), coin(789, "eth"), coin(12, "btc")] - ); - } - - #[test] - fn add_cw_tokens_proper() { - let mut tokens = GenericBalance::default(); - let bar_token = Addr::unchecked("bar_token"); - let foo_token = Addr::unchecked("foo_token"); - tokens.add_tokens(Balance::Cw20(Cw20CoinVerified { - address: foo_token.clone(), - amount: Uint128::new(12345), - })); - tokens.add_tokens(Balance::Cw20(Cw20CoinVerified { - address: bar_token.clone(), - amount: Uint128::new(777), - })); - tokens.add_tokens(Balance::Cw20(Cw20CoinVerified { - address: foo_token.clone(), - amount: Uint128::new(23400), - })); - assert_eq!( - tokens.cw20, - vec![ - Cw20CoinVerified { - address: foo_token, - amount: Uint128::new(35745), - }, - Cw20CoinVerified { - address: bar_token, - amount: Uint128::new(777), - } - ] - ); - } - - #[test] - fn top_up_mixed_tokens() { - let mut deps = mock_dependencies(); - - // instantiate an empty contract - let instantiate_msg = InstantiateMsg {}; - let info = mock_info(&String::from("anyone"), &[]); - let res = instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // only accept these tokens - let whitelist = vec![String::from("bar_token"), String::from("foo_token")]; - - // create an escrow with 2 native tokens - let create = CreateMsg { - id: "foobar".to_string(), - arbiter: String::from("arbitrate"), - recipient: String::from("recd"), - end_time: None, - end_height: None, - cw20_whitelist: Some(whitelist), - }; - let sender = String::from("source"); - let balance = vec![coin(100, "fee"), coin(200, "stake")]; - let info = mock_info(&sender, &balance); - let msg = ExecuteMsg::Create(create.clone()); - let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(0, res.messages.len()); - assert_eq!(("action", "create"), res.attributes[0]); - - // top it up with 2 more native tokens - let extra_native = vec![coin(250, "random"), coin(300, "stake")]; - let info = mock_info(&sender, &extra_native); - let top_up = ExecuteMsg::TopUp { - id: create.id.clone(), - }; - let res = execute(deps.as_mut(), mock_env(), info, top_up).unwrap(); - assert_eq!(0, res.messages.len()); - assert_eq!(("action", "top_up"), res.attributes[0]); - - // top up with one foreign token - let bar_token = String::from("bar_token"); - let base = TopUp { - id: create.id.clone(), - }; - let top_up = ExecuteMsg::Receive(Cw20ReceiveMsg { - sender: String::from("random"), - amount: Uint128::new(7890), - msg: to_binary(&base).unwrap(), - }); - let info = mock_info(&bar_token, &[]); - let res = execute(deps.as_mut(), mock_env(), info, top_up).unwrap(); - assert_eq!(0, res.messages.len()); - assert_eq!(("action", "top_up"), res.attributes[0]); - - // top with a foreign token not on the whitelist - // top up with one foreign token - let baz_token = String::from("baz_token"); - let base = TopUp { - id: create.id.clone(), - }; - let top_up = ExecuteMsg::Receive(Cw20ReceiveMsg { - sender: String::from("random"), - amount: Uint128::new(7890), - msg: to_binary(&base).unwrap(), - }); - let info = mock_info(&baz_token, &[]); - let err = execute(deps.as_mut(), mock_env(), info, top_up).unwrap_err(); - assert_eq!(err, ContractError::NotInWhitelist {}); - - // top up with second foreign token - let foo_token = String::from("foo_token"); - let base = TopUp { - id: create.id.clone(), - }; - let top_up = ExecuteMsg::Receive(Cw20ReceiveMsg { - sender: String::from("random"), - amount: Uint128::new(888), - msg: to_binary(&base).unwrap(), - }); - let info = mock_info(&foo_token, &[]); - let res = execute(deps.as_mut(), mock_env(), info, top_up).unwrap(); - assert_eq!(0, res.messages.len()); - assert_eq!(("action", "top_up"), res.attributes[0]); - - // approve it - let id = create.id.clone(); - let info = mock_info(&create.arbiter, &[]); - let res = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Approve { id }).unwrap(); - assert_eq!(("action", "approve"), res.attributes[0]); - assert_eq!(3, res.messages.len()); - - // first message releases all native coins - assert_eq!( - res.messages[0], - SubMsg::new(CosmosMsg::Bank(BankMsg::Send { - to_address: create.recipient.clone(), - amount: vec![coin(100, "fee"), coin(500, "stake"), coin(250, "random")], - })) - ); - - // second one release bar cw20 token - let send_msg = Cw20ExecuteMsg::Transfer { - recipient: create.recipient.clone(), - amount: Uint128::new(7890), - }; - assert_eq!( - res.messages[1], - SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: bar_token, - msg: to_binary(&send_msg).unwrap(), - funds: vec![] - })) - ); - - // third one release foo cw20 token - let send_msg = Cw20ExecuteMsg::Transfer { - recipient: create.recipient, - amount: Uint128::new(888), - }; - assert_eq!( - res.messages[2], - SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: foo_token, - msg: to_binary(&send_msg).unwrap(), - funds: vec![] - })) - ); - } -} diff --git a/contracts/cw20-escrow/src/error.rs b/contracts/cw20-escrow/src/error.rs deleted file mode 100644 index 69e258ccf..000000000 --- a/contracts/cw20-escrow/src/error.rs +++ /dev/null @@ -1,23 +0,0 @@ -use cosmwasm_std::StdError; -use thiserror::Error; - -#[derive(Error, Debug, PartialEq)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("Unauthorized")] - Unauthorized {}, - - #[error("Only accepts tokens in the cw20_whitelist")] - NotInWhitelist {}, - - #[error("Escrow is expired")] - Expired {}, - - #[error("Send some coins to create an escrow")] - EmptyBalance {}, - - #[error("Escrow id already in use")] - AlreadyInUse {}, -} diff --git a/contracts/cw20-escrow/src/integration_test.rs b/contracts/cw20-escrow/src/integration_test.rs deleted file mode 100644 index 44ffab45a..000000000 --- a/contracts/cw20-escrow/src/integration_test.rs +++ /dev/null @@ -1,151 +0,0 @@ -#![cfg(test)] - -use cosmwasm_std::{coins, to_binary, Addr, Empty, Uint128}; -use cw20::{Cw20Coin, Cw20Contract, Cw20ExecuteMsg}; -use cw_multi_test::{App, Contract, ContractWrapper, Executor}; - -use crate::msg::{CreateMsg, DetailsResponse, ExecuteMsg, InstantiateMsg, QueryMsg, ReceiveMsg}; - -pub fn contract_escrow() -> Box> { - let contract = ContractWrapper::new( - crate::contract::execute, - crate::contract::instantiate, - crate::contract::query, - ); - Box::new(contract) -} - -pub fn contract_cw20() -> Box> { - let contract = ContractWrapper::new( - cw20_base::contract::execute, - cw20_base::contract::instantiate, - cw20_base::contract::query, - ); - Box::new(contract) -} - -#[test] -// receive cw20 tokens and release upon approval -fn escrow_happy_path_cw20_tokens() { - // set personal balance - let owner = Addr::unchecked("owner"); - let init_funds = coins(2000, "btc"); - - let mut router = App::new(|router, _, storage| { - router - .bank - .init_balance(storage, &owner, init_funds) - .unwrap(); - }); - - // set up cw20 contract with some tokens - let cw20_id = router.store_code(contract_cw20()); - let msg = cw20_base::msg::InstantiateMsg { - name: "Cash Money".to_string(), - symbol: "CASH".to_string(), - decimals: 2, - initial_balances: vec![Cw20Coin { - address: owner.to_string(), - amount: Uint128::new(5000), - }], - mint: None, - marketing: None, - }; - let cash_addr = router - .instantiate_contract(cw20_id, owner.clone(), &msg, &[], "CASH", None) - .unwrap(); - - // set up reflect contract - let escrow_id = router.store_code(contract_escrow()); - let escrow_addr = router - .instantiate_contract( - escrow_id, - owner.clone(), - &InstantiateMsg {}, - &[], - "Escrow", - None, - ) - .unwrap(); - - // they are different - assert_ne!(cash_addr, escrow_addr); - - // set up cw20 helpers - let cash = Cw20Contract(cash_addr.clone()); - - // ensure our balances - let owner_balance = cash.balance(&router, owner.clone()).unwrap(); - assert_eq!(owner_balance, Uint128::new(5000)); - let escrow_balance = cash.balance(&router, escrow_addr.clone()).unwrap(); - assert_eq!(escrow_balance, Uint128::zero()); - - // send some tokens to create an escrow - let arb = Addr::unchecked("arbiter"); - let ben = String::from("beneficiary"); - let id = "demo".to_string(); - let create_msg = ReceiveMsg::Create(CreateMsg { - id: id.clone(), - arbiter: arb.to_string(), - recipient: ben.clone(), - end_height: None, - end_time: None, - cw20_whitelist: None, - }); - let send_msg = Cw20ExecuteMsg::Send { - contract: escrow_addr.to_string(), - amount: Uint128::new(1200), - msg: to_binary(&create_msg).unwrap(), - }; - let res = router - .execute_contract(owner.clone(), cash_addr.clone(), &send_msg, &[]) - .unwrap(); - assert_eq!(4, res.events.len()); - println!("{:?}", res.events); - - assert_eq!(res.events[0].ty.as_str(), "execute"); - let cw20_attr = res.custom_attrs(1); - println!("{:?}", cw20_attr); - assert_eq!(4, cw20_attr.len()); - - assert_eq!(res.events[2].ty.as_str(), "execute"); - let escrow_attr = res.custom_attrs(3); - println!("{:?}", escrow_attr); - assert_eq!(2, escrow_attr.len()); - - // ensure balances updated - let owner_balance = cash.balance(&router, owner.clone()).unwrap(); - assert_eq!(owner_balance, Uint128::new(3800)); - let escrow_balance = cash.balance(&router, escrow_addr.clone()).unwrap(); - assert_eq!(escrow_balance, Uint128::new(1200)); - - // ensure escrow properly created - let details: DetailsResponse = router - .wrap() - .query_wasm_smart(&escrow_addr, &QueryMsg::Details { id: id.clone() }) - .unwrap(); - assert_eq!(id, details.id); - assert_eq!(arb, details.arbiter); - assert_eq!(ben, details.recipient); - assert_eq!( - vec![Cw20Coin { - address: cash_addr.to_string(), - amount: Uint128::new(1200) - }], - details.cw20_balance - ); - - // release escrow - let approve_msg = ExecuteMsg::Approve { id }; - let _ = router - .execute_contract(arb, escrow_addr.clone(), &approve_msg, &[]) - .unwrap(); - - // ensure balances updated - release to ben - let owner_balance = cash.balance(&router, owner).unwrap(); - assert_eq!(owner_balance, Uint128::new(3800)); - let escrow_balance = cash.balance(&router, escrow_addr).unwrap(); - assert_eq!(escrow_balance, Uint128::zero()); - let ben_balance = cash.balance(&router, ben).unwrap(); - assert_eq!(ben_balance, Uint128::new(1200)); -} diff --git a/contracts/cw20-escrow/src/lib.rs b/contracts/cw20-escrow/src/lib.rs deleted file mode 100644 index 32ed6c387..000000000 --- a/contracts/cw20-escrow/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod contract; -mod error; -mod integration_test; -pub mod msg; -pub mod state; - -pub use crate::error::ContractError; diff --git a/contracts/cw20-escrow/src/msg.rs b/contracts/cw20-escrow/src/msg.rs deleted file mode 100644 index 8dbd607ea..000000000 --- a/contracts/cw20-escrow/src/msg.rs +++ /dev/null @@ -1,123 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::{Addr, Api, Coin, StdResult}; - -use cw20::{Cw20Coin, Cw20ReceiveMsg}; - -#[derive(Serialize, Deserialize, JsonSchema)] -pub struct InstantiateMsg {} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg { - Create(CreateMsg), - /// Adds all sent native tokens to the contract - TopUp { - id: String, - }, - /// Approve sends all tokens to the recipient. - /// Only the arbiter can do this - Approve { - /// id is a human-readable name for the escrow from create - id: String, - }, - /// Refund returns all remaining tokens to the original sender, - /// The arbiter can do this any time, or anyone can do this after a timeout - Refund { - /// id is a human-readable name for the escrow from create - id: String, - }, - /// This accepts a properly-encoded ReceiveMsg from a cw20 contract - Receive(Cw20ReceiveMsg), -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ReceiveMsg { - Create(CreateMsg), - /// Adds all sent native tokens to the contract - TopUp { - id: String, - }, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct CreateMsg { - /// id is a human-readable name for the escrow to use later - /// 3-20 bytes of utf-8 text - pub id: String, - /// arbiter can decide to approve or refund the escrow - pub arbiter: String, - /// if approved, funds go to the recipient - pub recipient: String, - /// When end height set and block height exceeds this value, the escrow is expired. - /// Once an escrow is expired, it can be returned to the original funder (via "refund"). - pub end_height: Option, - /// When end time (in seconds since epoch 00:00:00 UTC on 1 January 1970) is set and - /// block time exceeds this value, the escrow is expired. - /// Once an escrow is expired, it can be returned to the original funder (via "refund"). - pub end_time: Option, - /// Besides any possible tokens sent with the CreateMsg, this is a list of all cw20 token addresses - /// that are accepted by the escrow during a top-up. This is required to avoid a DoS attack by topping-up - /// with an invalid cw20 contract. See https://github.com/CosmWasm/cosmwasm-plus/issues/19 - pub cw20_whitelist: Option>, -} - -impl CreateMsg { - pub fn addr_whitelist(&self, api: &dyn Api) -> StdResult> { - match self.cw20_whitelist.as_ref() { - Some(v) => v.iter().map(|h| api.addr_validate(h)).collect(), - None => Ok(vec![]), - } - } -} - -pub fn is_valid_name(name: &str) -> bool { - let bytes = name.as_bytes(); - if bytes.len() < 3 || bytes.len() > 20 { - return false; - } - true -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum QueryMsg { - /// Show all open escrows. Return type is ListResponse. - List {}, - /// Returns the details of the named escrow, error if not created - /// Return type: DetailsResponse. - Details { id: String }, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct ListResponse { - /// list all registered ids - pub escrows: Vec, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct DetailsResponse { - /// id of this escrow - pub id: String, - /// arbiter can decide to approve or refund the escrow - pub arbiter: String, - /// if approved, funds go to the recipient - pub recipient: String, - /// if refunded, funds go to the source - pub source: String, - /// When end height set and block height exceeds this value, the escrow is expired. - /// Once an escrow is expired, it can be returned to the original funder (via "refund"). - pub end_height: Option, - /// When end time (in seconds since epoch 00:00:00 UTC on 1 January 1970) is set and - /// block time exceeds this value, the escrow is expired. - /// Once an escrow is expired, it can be returned to the original funder (via "refund"). - pub end_time: Option, - /// Balance in native tokens - pub native_balance: Vec, - /// Balance in cw20 tokens - pub cw20_balance: Vec, - /// Whitelisted cw20 tokens - pub cw20_whitelist: Vec, -} diff --git a/contracts/cw20-escrow/src/state.rs b/contracts/cw20-escrow/src/state.rs deleted file mode 100644 index 3940d6160..000000000 --- a/contracts/cw20-escrow/src/state.rs +++ /dev/null @@ -1,145 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::{Addr, Coin, Env, Order, StdResult, Storage, Timestamp}; -use cw_storage_plus::Map; - -use cw20::{Balance, Cw20CoinVerified}; - -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] -pub struct GenericBalance { - pub native: Vec, - pub cw20: Vec, -} - -impl GenericBalance { - pub fn add_tokens(&mut self, add: Balance) { - match add { - Balance::Native(balance) => { - for token in balance.0 { - let index = self.native.iter().enumerate().find_map(|(i, exist)| { - if exist.denom == token.denom { - Some(i) - } else { - None - } - }); - match index { - Some(idx) => self.native[idx].amount += token.amount, - None => self.native.push(token), - } - } - } - Balance::Cw20(token) => { - let index = self.cw20.iter().enumerate().find_map(|(i, exist)| { - if exist.address == token.address { - Some(i) - } else { - None - } - }); - match index { - Some(idx) => self.cw20[idx].amount += token.amount, - None => self.cw20.push(token), - } - } - }; - } -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct Escrow { - /// arbiter can decide to approve or refund the escrow - pub arbiter: Addr, - /// if approved, funds go to the recipient - pub recipient: Addr, - /// if refunded, funds go to the source - pub source: Addr, - /// When end height set and block height exceeds this value, the escrow is expired. - /// Once an escrow is expired, it can be returned to the original funder (via "refund"). - pub end_height: Option, - /// When end time (in seconds since epoch 00:00:00 UTC on 1 January 1970) is set and - /// block time exceeds this value, the escrow is expired. - /// Once an escrow is expired, it can be returned to the original funder (via "refund"). - pub end_time: Option, - /// Balance in Native and Cw20 tokens - pub balance: GenericBalance, - /// All possible contracts that we accept tokens from - pub cw20_whitelist: Vec, -} - -impl Escrow { - pub fn is_expired(&self, env: &Env) -> bool { - if let Some(end_height) = self.end_height { - if env.block.height > end_height { - return true; - } - } - - if let Some(end_time) = self.end_time { - if env.block.time > Timestamp::from_seconds(end_time) { - return true; - } - } - - false - } - - pub fn human_whitelist(&self) -> Vec { - self.cw20_whitelist.iter().map(|a| a.to_string()).collect() - } -} - -pub const ESCROWS: Map<&str, Escrow> = Map::new("escrow"); - -/// This returns the list of ids for all registered escrows -pub fn all_escrow_ids(storage: &dyn Storage) -> StdResult> { - ESCROWS - .keys(storage, None, None, Order::Ascending) - .collect() -} - -#[cfg(test)] -mod tests { - use super::*; - - use cosmwasm_std::testing::MockStorage; - - #[test] - fn no_escrow_ids() { - let storage = MockStorage::new(); - let ids = all_escrow_ids(&storage).unwrap(); - assert_eq!(0, ids.len()); - } - - fn dummy_escrow() -> Escrow { - Escrow { - arbiter: Addr::unchecked("arb"), - recipient: Addr::unchecked("recip"), - source: Addr::unchecked("source"), - end_height: None, - end_time: None, - balance: Default::default(), - cw20_whitelist: vec![], - } - } - - #[test] - fn all_escrow_ids_in_order() { - let mut storage = MockStorage::new(); - ESCROWS - .save(&mut storage, &"lazy", &dummy_escrow()) - .unwrap(); - ESCROWS - .save(&mut storage, &"assign", &dummy_escrow()) - .unwrap(); - ESCROWS.save(&mut storage, &"zen", &dummy_escrow()).unwrap(); - - let ids = all_escrow_ids(&storage).unwrap(); - assert_eq!(3, ids.len()); - assert_eq!( - vec!["assign".to_string(), "lazy".to_string(), "zen".to_string()], - ids - ) - } -} diff --git a/contracts/cw20-merkle-airdrop/.cargo/config b/contracts/cw20-merkle-airdrop/.cargo/config deleted file mode 100644 index 8d4bc738b..000000000 --- a/contracts/cw20-merkle-airdrop/.cargo/config +++ /dev/null @@ -1,6 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib" -integration-test = "test --test integration" -schema = "run --example schema" diff --git a/contracts/cw20-merkle-airdrop/Cargo.toml b/contracts/cw20-merkle-airdrop/Cargo.toml deleted file mode 100644 index fa64e4f28..000000000 --- a/contracts/cw20-merkle-airdrop/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "cw20-merkle-airdrop" -version = "0.7.0" -authors = ["Orkun Kulce ", "Terraform Labs, PTE."] -edition = "2018" -description = "An Airdrop contract for allowing users to claim rewards with Merkle Tree based proof" -license = "Apache-2.0" - -exclude = [ - "contract.wasm", - "hash.txt", -] - -[lib] -crate-type = ["cdylib", "rlib"] - -[features] -backtraces = ["cosmwasm-std/backtraces"] -library = [] - -[dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw20 = { path = "../../packages/cw20", version = "0.11.1" } -cosmwasm-std = { version = "1.0.0-beta3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } -schemars = "0.8.1" -serde = { version = "1.0.103", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.23" } -hex = "0.4" -sha2 = { version = "0.9.5", default-features = false } - -[dev-dependencies] -cosmwasm-schema = "1.0.0-beta3" -serde_json = "1.0" diff --git a/contracts/cw20-merkle-airdrop/NOTICE b/contracts/cw20-merkle-airdrop/NOTICE deleted file mode 100644 index 0f5ee7638..000000000 --- a/contracts/cw20-merkle-airdrop/NOTICE +++ /dev/null @@ -1,16 +0,0 @@ -CW20-Merkle-Airdrop: A reference implementation for merkle airdrop on CosmWasm - -Copyright (C) 2021 Terraform Labs, PTE. -Copyright (C) 2021 Confio OÜ - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/contracts/cw20-merkle-airdrop/README.md b/contracts/cw20-merkle-airdrop/README.md deleted file mode 100644 index a313d0043..000000000 --- a/contracts/cw20-merkle-airdrop/README.md +++ /dev/null @@ -1,105 +0,0 @@ -# CW20 Merkle Airdrop - -This is a merkle airdrop smart contract that works with cw20 token specification Mass airdrop distributions made cheap -and efficient. - -Explanation of merkle -airdrop: [Medium Merkle Airdrop: the Basics](https://medium.com/smartz-blog/merkle-airdrop-the-basics-9a0857fcc930) - -Traditional and non-efficient airdrops: - -- Distributor creates a list of airdrop -- Sends bank send messages to send tokens to recipients - -**Or** - -- Stores list of recipients on smart contract data -- Recipient claims the airdrop - -These two solutions are very ineffective when recipient list is big. First, costly because bank send cost for the -distributor will be costly. Second, whole airdrop list stored in the state, again costly. - -Merkle Airdrop is very efficient even when recipient number is massive. - -This contract works with multiple airdrop rounds, meaning you can execute several airdrops using same instance. - -Uses **SHA256** for merkle root tree construction. - -## Procedure - -- Distributor of contract prepares a list of addresses with many entries and publishes this list in public static .js - file in JSON format -- Distributor reads this list, builds the merkle tree structure and writes down the Merkle root of it. -- Distributor creates contract and places calculated Merkle root into it. -- Distributor says to users, that they can claim their tokens, if they owe any of addresses, presented in list, - published on distributor's site. -- User wants to claim his N tokens, he also builds Merkle tree from public list and prepares Merkle proof, consisting - from log2N hashes, describing the way to reach Merkle root -- User sends transaction with Merkle proof to contract -- Contract checks Merkle proof, and, if proof is correct, then sender's address is in list of allowed addresses, and - contract does some action for this use. -- Distributor sends token to the contract, and registers new merkle root for the next distribution round. - -## Spec - -### Messages - -#### InstantiateMsg - -`InstantiateMsg` instantiates contract with owner and cw20 token address. Airdrop `stage` is set to 0. - -```rust -pub struct InstantiateMsg { - pub owner: String, - pub cw20_token_address: String, -} -``` - -#### ExecuteMsg - -```rust -pub enum ExecuteMsg { - UpdateConfig { - owner: Option, - }, - RegisterMerkleRoot { - merkle_root: String, - }, - Claim { - stage: u8, - amount: Uint128, - proof: Vec, - }, -} -``` - -- `UpdateConfig{owner}` updates configuration. -- `RegisterMerkleRoot {merkle_root}` registers merkle tree root for further claim verification. Airdrop `Stage` - increased by 1. -- `Claim{stage, amount, proof}` recipient executes for claiming airdrop with `stage`, `amount` and `proof` data built - using full list. - -#### QueryMsg - -``` rust -pub enum QueryMsg { - Config {}, - MerkleRoot { stage: u8 }, - LatestStage {}, - IsClaimed { stage: u8, address: String }, -} -``` - -- `{ config: {} }` returns configuration, `{"cw20_token_address": ..., "owner": ...}`. -- `{ merkle_root: { stage: "1" }` returns merkle root of given stage, `{"merkle_root": ... , "stage": ...}` -- `{ latest_stage: {}}` returns current airdrop stage, `{"latest_stage": ...}` -- `{ is_claimed: {stage: "stage", address: "wasm1..."}` returns if address claimed airdrop, `{"is_claimed": "true"}` - -## Merkle Airdrop CLI - -[Merkle Airdrop CLI](helpers) contains js helpers for generating root, generating and verifying proofs for given airdrop -file. - -## Test Vector Generation - -Test vector can be generated using commands at [Merkle Airdrop CLI README](helpers/README.md) diff --git a/contracts/cw20-merkle-airdrop/examples/schema.rs b/contracts/cw20-merkle-airdrop/examples/schema.rs deleted file mode 100644 index d3725a5f8..000000000 --- a/contracts/cw20-merkle-airdrop/examples/schema.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use cw20_merkle_airdrop::msg::{ - ConfigResponse, ExecuteMsg, InstantiateMsg, IsClaimedResponse, LatestStageResponse, - MerkleRootResponse, QueryMsg, -}; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); - export_schema(&schema_for!(LatestStageResponse), &out_dir); - export_schema(&schema_for!(MerkleRootResponse), &out_dir); - export_schema(&schema_for!(IsClaimedResponse), &out_dir); - export_schema(&schema_for!(ConfigResponse), &out_dir); -} diff --git a/contracts/cw20-merkle-airdrop/helpers/.eslintignore b/contracts/cw20-merkle-airdrop/helpers/.eslintignore deleted file mode 100644 index 502167fa0..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -/lib diff --git a/contracts/cw20-merkle-airdrop/helpers/.eslintrc b/contracts/cw20-merkle-airdrop/helpers/.eslintrc deleted file mode 100644 index 7b846193c..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/.eslintrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": [ - "oclif", - "oclif-typescript" - ] -} diff --git a/contracts/cw20-merkle-airdrop/helpers/.gitignore b/contracts/cw20-merkle-airdrop/helpers/.gitignore deleted file mode 100644 index 9d6ea2ca5..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*-debug.log -*-error.log -/.nyc_output -/dist -/lib -/package-lock.json -/tmp -node_modules diff --git a/contracts/cw20-merkle-airdrop/helpers/README.md b/contracts/cw20-merkle-airdrop/helpers/README.md deleted file mode 100644 index c9e4a9760..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/README.md +++ /dev/null @@ -1,47 +0,0 @@ -merkle-airdrop-cli -================== - -This is a helper client shipped along contract. -Use this to generate root, generate proofs and verify proofs - -## Installation - -```shell -yarn install -yarn link -``` - -Binary will be placed to path. - -## Airdrop file format - -```json -[ - { "address": "wasm1k9hwzxs889jpvd7env8z49gad3a3633vg350tq", "amount": "100"}, - { "address": "wasm1uy9ucvgerneekxpnfwyfnpxvlsx5dzdpf0mzjd", "amount": "1010"} -] -``` - -## Commands - -**Generate Root:** -```shell -merkle-airdrop-cli generateRoot --file ../testdata/airdrop_stage_2_list.json -``` - -**Generate proof:** -```shell -merkle-airdrop-cli generateProofs --file ../testdata/airdrop_stage_2_list.json \ - --address wasm1ylna88nach9sn5n7qe7u5l6lh7dmt6lp2y63xx \ - --amount 1000000000 -``` - -**Verify proof:** -```shell -PROOFS='[ "27e9b1ec8cb64709d0a8d3702344561674199fe81b885f1f9c9b2fb268795962","280777995d054081cbf208bccb70f8d736c1766b81d90a1fd21cd97d2d83a5cc","3946ea1758a5a2bf55bae1186168ad35aa0329805bc8bff1ca3d51345faec04a" -]' -merkle-airdrop-cli verifyProofs --file ../testdata/airdrop.json \ - --address wasm1k9hwzxs889jpvd7env8z49gad3a3633vg350tq \ - --amount 100 \ - --proofs $PROOFS -``` diff --git a/contracts/cw20-merkle-airdrop/helpers/bin/run b/contracts/cw20-merkle-airdrop/helpers/bin/run deleted file mode 100755 index 30b14e177..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/bin/run +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env node - -require('@oclif/command').run() -.then(require('@oclif/command/flush')) -.catch(require('@oclif/errors/handle')) diff --git a/contracts/cw20-merkle-airdrop/helpers/bin/run.cmd b/contracts/cw20-merkle-airdrop/helpers/bin/run.cmd deleted file mode 100644 index 968fc3075..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/bin/run.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -node "%~dp0\run" %* diff --git a/contracts/cw20-merkle-airdrop/helpers/package.json b/contracts/cw20-merkle-airdrop/helpers/package.json deleted file mode 100644 index 8e249ee3b..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "merkle-airdrop-cli", - "version": "0.1.0", - "author": "Orkun Külçe @orkunkl", - "bin": { - "merkle-airdrop-cli": "./bin/run" - }, - "dependencies": { - "@cosmjs/crypto": "^0.25.5", - "@cosmjs/encoding": "^0.25.5", - "@oclif/command": "^1", - "@oclif/config": "^1", - "@oclif/plugin-help": "^3", - "@types/crypto-js": "^4.0.2", - "ethereumjs-util": "^7.1.0", - "merkletreejs": "^0.2.23", - "tslib": "^1" - }, - "devDependencies": { - "@oclif/dev-cli": "^1", - "@types/node": "^10", - "eslint": "^5.13", - "eslint-config-oclif": "^3.1", - "eslint-config-oclif-typescript": "^0.1", - "globby": "^10", - "ts-node": "^8", - "typescript": "^3.3" - }, - "engines": { - "node": ">=8.0.0" - }, - "files": [ - "/bin", - "/lib", - "/npm-shrinkwrap.json", - "/oclif.manifest.json" - ], - "keywords": [ - "cosmwasm", - "cw20" - ], - "license": "Apache-2.0", - "main": "lib/index.js", - "oclif": { - "commands": "./lib/commands", - "bin": "merkle-airdrop-cli", - "plugins": [ - "@oclif/plugin-help" - ] - }, - "repository": "CosmWasm/cosmwasm-plus/cw20-merkle-airdrop/merkle-airdrop-cli", - "scripts": { - "postpack": "rm -f oclif.manifest.json", - "posttest": "eslint . --ext .ts --config .eslintrc", - "prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme", - "test": "echo NO TESTS", - "version": "oclif-dev readme && git add README.md" - }, - "types": "lib/index.d.ts" -} diff --git a/contracts/cw20-merkle-airdrop/helpers/src/airdrop.ts b/contracts/cw20-merkle-airdrop/helpers/src/airdrop.ts deleted file mode 100644 index 87972b047..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/src/airdrop.ts +++ /dev/null @@ -1,44 +0,0 @@ -import sha256 from 'crypto-js/sha256' -import { MerkleTree } from 'merkletreejs'; - -class Airdrop { - private tree: MerkleTree; - - constructor(accounts: Array<{ address: string; amount: string }>) { - const leaves = accounts.map((a) => sha256(a.address + a.amount)); - this.tree = new MerkleTree(leaves, sha256, { sort: true }); - } - - public getMerkleRoot(): string { - return this.tree.getHexRoot().replace('0x', ''); - } - - public getMerkleProof(account: { - address: string; - amount: string; - }): string[] { - return this.tree - .getHexProof(sha256(account.address + account.amount).toString()) - .map((v) => v.replace('0x', '')); - } - - public verify( - proof: string[], - account: { address: string; amount: string } - ): boolean { - let hashBuf = Buffer.from(sha256(account.address + account.amount).toString()) - - proof.forEach((proofElem) => { - const proofBuf = Buffer.from(proofElem, 'hex'); - if (hashBuf < proofBuf) { - hashBuf = Buffer.from(sha256(Buffer.concat([hashBuf, proofBuf]).toString())); - } else { - hashBuf = Buffer.from(sha256(Buffer.concat([proofBuf, hashBuf]).toString())); - } - }); - - return this.getMerkleRoot() === hashBuf.toString('hex'); - } -} - -export {Airdrop} diff --git a/contracts/cw20-merkle-airdrop/helpers/src/commands/generateProofs.ts b/contracts/cw20-merkle-airdrop/helpers/src/commands/generateProofs.ts deleted file mode 100644 index 6181e1d9b..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/src/commands/generateProofs.ts +++ /dev/null @@ -1,48 +0,0 @@ -import {Command, flags} from '@oclif/command' -import { readFileSync } from 'fs'; -import {Airdrop} from '../airdrop'; - -export default class GenerateProof extends Command { - static description = 'Generates merkle proofs for given address' - - static examples = [ - `$ merkle-airdrop-cli generateProofs --file ../testdata/airdrop_stage_2.json \ - --address wasm1ylna88nach9sn5n7qe7u5l6lh7dmt6lp2y63xx \ - --amount 1000000000 -`, - ] - - static flags = { - help: flags.help({char: 'h'}), - file: flags.string({char: 'f', description: 'airdrop file location'}), - address: flags.string({char: 'a', description: 'address'}), - amount: flags.string({char: 'b', description: 'amount'}), - } - - async run() { - const {flags} = this.parse(GenerateProof) - - if (!flags.file) { - this.error(new Error('Airdrop file location not defined')) - } - if (!flags.address) { - this.error(new Error('Address not defined')) - } - if (!flags.amount) { - this.error(new Error('Amount not defined')) - } - - let file; - try { - file = readFileSync(flags.file, 'utf-8'); - } catch (e) { - this.error(e) - } - - let receivers: Array<{ address: string; amount: string }> = JSON.parse(file); - - let airdrop = new Airdrop(receivers) - let proof = airdrop.getMerkleProof({address: flags.address, amount: flags.amount}) - console.log(proof) - } -} diff --git a/contracts/cw20-merkle-airdrop/helpers/src/commands/generateRoot.ts b/contracts/cw20-merkle-airdrop/helpers/src/commands/generateRoot.ts deleted file mode 100644 index a8875fe04..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/src/commands/generateRoot.ts +++ /dev/null @@ -1,37 +0,0 @@ -import {Command, flags} from '@oclif/command' -import { readFileSync } from 'fs'; -import {Airdrop} from '../airdrop'; - -export default class GenerateRoot extends Command { - static description = 'Generates merkle root' - - static examples = [ - `$ merkle-airdrop-cli generateRoot --file ../testdata/airdrop_stage_2.json -`, - ] - - static flags = { - help: flags.help({char: 'h'}), - file: flags.string({char: 'f', description: 'Airdrop file location'}), - } - - async run() { - const {flags} = this.parse(GenerateRoot) - - if (!flags.file) { - this.error(new Error('Airdrop file location not defined')) - } - - let file; - try { - file = readFileSync(flags.file, 'utf-8'); - } catch (e) { - this.error(e) - } - - let receivers: Array<{ address: string; amount: string }> = JSON.parse(file); - - let airdrop = new Airdrop(receivers) - console.log(airdrop.getMerkleRoot()) - } -} diff --git a/contracts/cw20-merkle-airdrop/helpers/src/commands/verifyProofs.ts b/contracts/cw20-merkle-airdrop/helpers/src/commands/verifyProofs.ts deleted file mode 100644 index 3915ae45f..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/src/commands/verifyProofs.ts +++ /dev/null @@ -1,55 +0,0 @@ -import {Command, flags} from '@oclif/command' -import { readFileSync } from 'fs'; -import {Airdrop} from '../airdrop'; - -export default class VerifyProof extends Command { - static description = 'Verifies merkle proofs for given address' - - static examples = [ - `$ PROOFS='[ "27e9b1ec8cb64709d0a8d3702344561674199fe81b885f1f9c9b2fb268795962","280777995d054081cbf208bccb70f8d736c1766b81d90a1fd21cd97d2d83a5cc","3946ea1758a5a2bf55bae1186168ad35aa0329805bc8bff1ca3d51345faec04a"]' - $ merkle-airdrop-cli verifyProofs --file ../testdata/airdrop.json \ - --address wasm1k9hwzxs889jpvd7env8z49gad3a3633vg350tq \ - --amount 100 - --proofs $PROOFS -`, - ] - - static flags = { - help: flags.help({char: 'h'}), - file: flags.string({char: 'f', description: 'airdrop file location'}), - proofs: flags.string({char: 'p', description: 'proofs in json format'}), - address: flags.string({char: 'a', description: 'address'}), - amount: flags.string({char: 'b', description: 'amount'}), - } - - async run() { - const {flags} = this.parse(VerifyProof) - - if (!flags.file) { - this.error(new Error('Airdrop file location not defined')) - } - if (!flags.proofs) { - this.error(new Error('Proofs not defined')) - } - if (!flags.address) { - this.error(new Error('Address not defined')) - } - if (!flags.amount) { - this.error(new Error('Amount not defined')) - } - - let file; - try { - file = readFileSync(flags.file, 'utf-8'); - } catch (e) { - this.error(e) - } - - let receivers: Array<{ address: string; amount: string }> = JSON.parse(file); - - let airdrop = new Airdrop(receivers) - let proofs: string[] = JSON.parse(flags.proofs) - - console.log(airdrop.verify(proofs, {address: flags.address, amount: flags.amount})) - } -} diff --git a/contracts/cw20-merkle-airdrop/helpers/src/index.ts b/contracts/cw20-merkle-airdrop/helpers/src/index.ts deleted file mode 100644 index 4caa481ee..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {run} from '@oclif/command' diff --git a/contracts/cw20-merkle-airdrop/helpers/tsconfig.json b/contracts/cw20-merkle-airdrop/helpers/tsconfig.json deleted file mode 100644 index 8964312f8..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/tsconfig.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "compilerOptions": { - "importHelpers": true, - "outDir": "lib", - "rootDir": "src", - "strict": true, - "target": "es2017", - "allowSyntheticDefaultImports": true, - "alwaysStrict": true, - "baseUrl": "./", - "declaration": true, - "esModuleInterop": true, - "lib": ["es2015", "es2016", "es2017", "dom"], - "module": "commonjs", - "moduleResolution": "node", - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noUnusedLocals": false, - "noUnusedParameters": true, - "sourceMap": true, - "strictFunctionTypes": true, - "strictNullChecks": true, - "strictPropertyInitialization": true, - "paths": { - "*": ["src/*"] - } - }, - "include": [ - "src/**/*" - ] -} diff --git a/contracts/cw20-merkle-airdrop/helpers/yarn.lock b/contracts/cw20-merkle-airdrop/helpers/yarn.lock deleted file mode 100644 index a07471937..000000000 --- a/contracts/cw20-merkle-airdrop/helpers/yarn.lock +++ /dev/null @@ -1,2767 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/code-frame@^7.0.0": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.14.5.tgz#23b08d740e83f49c5e59945fbf1b43e80bbf4edb" - integrity sha512-9pzDqyc6OLDaqe+zbACgFkb6fKMNG6CObKpnYXChRsvYGyEdc7CA2BaqeOM+vOtCS5ndmJicPJhKAwYRI6UfFw== - dependencies: - "@babel/highlight" "^7.14.5" - -"@babel/helper-validator-identifier@^7.14.5": - version "7.14.9" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.9.tgz#6654d171b2024f6d8ee151bf2509699919131d48" - integrity sha512-pQYxPY0UP6IHISRitNe8bsijHex4TWZXi2HwKVsjPiltzlhse2znVcm9Ace510VT1kxIHjGJCZZQBX2gJDbo0g== - -"@babel/highlight@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.14.5.tgz#6861a52f03966405001f6aa534a01a24d99e8cd9" - integrity sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg== - dependencies: - "@babel/helper-validator-identifier" "^7.14.5" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@cosmjs/crypto@^0.25.5": - version "0.25.6" - resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.25.6.tgz#695d2d0d2195bdbdd5825d415385646244900bbb" - integrity sha512-ec+YcQLrg2ibcxtNrh4FqQnG9kG9IE/Aik2NH6+OXQdFU/qFuBTxSFcKDgzzBOChwlkXwydllM9Jjbp+dgIzRw== - dependencies: - "@cosmjs/encoding" "^0.25.6" - "@cosmjs/math" "^0.25.6" - "@cosmjs/utils" "^0.25.6" - bip39 "^3.0.2" - bn.js "^4.11.8" - elliptic "^6.5.3" - js-sha3 "^0.8.0" - libsodium-wrappers "^0.7.6" - ripemd160 "^2.0.2" - sha.js "^2.4.11" - -"@cosmjs/encoding@^0.25.5", "@cosmjs/encoding@^0.25.6": - version "0.25.6" - resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.25.6.tgz#da741a33eaf063a6d3611d7d68db5ca3938e0ef5" - integrity sha512-0imUOB8XkUstI216uznPaX1hqgvLQ2Xso3zJj5IV5oJuNlsfDj9nt/iQxXWbJuettc6gvrFfpf+Vw2vBZSZ75g== - dependencies: - base64-js "^1.3.0" - bech32 "^1.1.4" - readonly-date "^1.0.0" - -"@cosmjs/math@^0.25.6": - version "0.25.6" - resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.25.6.tgz#25c7b106aaded889a5b80784693caa9e654b0c28" - integrity sha512-Fmyc9FJ8KMU34n7rdapMJrT/8rx5WhMw2F7WLBu7AVLcBh0yWsXIcMSJCoPHTOnMIiABjXsnrrwEaLrOOBfu6A== - dependencies: - bn.js "^4.11.8" - -"@cosmjs/utils@^0.25.6": - version "0.25.6" - resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.25.6.tgz#934d9a967180baa66163847616a74358732227ca" - integrity sha512-ofOYiuxVKNo238vCPPlaDzqPXy2AQ/5/nashBo5rvPZJkxt9LciGfUEQWPCOb1BIJDNx2Dzu0z4XCf/dwzl0Dg== - -"@nodelib/fs.scandir@2.1.5": - version "2.1.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" - integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== - dependencies: - "@nodelib/fs.stat" "2.0.5" - run-parallel "^1.1.9" - -"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" - integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== - -"@nodelib/fs.walk@^1.2.3": - version "1.2.8" - resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" - integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== - dependencies: - "@nodelib/fs.scandir" "2.1.5" - fastq "^1.6.0" - -"@oclif/command@^1", "@oclif/command@^1.5.20", "@oclif/command@^1.6.0", "@oclif/command@^1.8.0": - version "1.8.0" - resolved "https://registry.yarnpkg.com/@oclif/command/-/command-1.8.0.tgz#c1a499b10d26e9d1a611190a81005589accbb339" - integrity sha512-5vwpq6kbvwkQwKqAoOU3L72GZ3Ta8RRrewKj9OJRolx28KLJJ8Dg9Rf7obRwt5jQA9bkYd8gqzMTrI7H3xLfaw== - dependencies: - "@oclif/config" "^1.15.1" - "@oclif/errors" "^1.3.3" - "@oclif/parser" "^3.8.3" - "@oclif/plugin-help" "^3" - debug "^4.1.1" - semver "^7.3.2" - -"@oclif/config@^1", "@oclif/config@^1.15.1", "@oclif/config@^1.17.0": - version "1.17.0" - resolved "https://registry.yarnpkg.com/@oclif/config/-/config-1.17.0.tgz#ba8639118633102a7e481760c50054623d09fcab" - integrity sha512-Lmfuf6ubjQ4ifC/9bz1fSCHc6F6E653oyaRXxg+lgT4+bYf9bk+nqrUpAbrXyABkCqgIBiFr3J4zR/kiFdE1PA== - dependencies: - "@oclif/errors" "^1.3.3" - "@oclif/parser" "^3.8.0" - debug "^4.1.1" - globby "^11.0.1" - is-wsl "^2.1.1" - tslib "^2.0.0" - -"@oclif/dev-cli@^1": - version "1.26.0" - resolved "https://registry.yarnpkg.com/@oclif/dev-cli/-/dev-cli-1.26.0.tgz#e3ec294b362c010ffc8948003d3770955c7951fd" - integrity sha512-272udZP+bG4qahoAcpWcMTJKiA+V42kRMqQM7n4tgW35brYb2UP5kK+p08PpF8sgSfRTV8MoJVJG9ax5kY82PA== - dependencies: - "@oclif/command" "^1.8.0" - "@oclif/config" "^1.17.0" - "@oclif/errors" "^1.3.3" - "@oclif/plugin-help" "^3.2.0" - cli-ux "^5.2.1" - debug "^4.1.1" - find-yarn-workspace-root "^2.0.0" - fs-extra "^8.1" - github-slugger "^1.2.1" - lodash "^4.17.11" - normalize-package-data "^3.0.0" - qqjs "^0.3.10" - tslib "^2.0.3" - -"@oclif/errors@^1.2.1", "@oclif/errors@^1.2.2", "@oclif/errors@^1.3.3": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@oclif/errors/-/errors-1.3.5.tgz#a1e9694dbeccab10fe2fe15acb7113991bed636c" - integrity sha512-OivucXPH/eLLlOT7FkCMoZXiaVYf8I/w1eTAM1+gKzfhALwWTusxEx7wBmW0uzvkSg/9ovWLycPaBgJbM3LOCQ== - dependencies: - clean-stack "^3.0.0" - fs-extra "^8.1" - indent-string "^4.0.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -"@oclif/linewrap@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@oclif/linewrap/-/linewrap-1.0.0.tgz#aedcb64b479d4db7be24196384897b5000901d91" - integrity sha512-Ups2dShK52xXa8w6iBWLgcjPJWjais6KPJQq3gQ/88AY6BXoTX+MIGFPrWQO1KLMiQfoTpcLnUwloN4brrVUHw== - -"@oclif/parser@^3.8.0", "@oclif/parser@^3.8.3": - version "3.8.5" - resolved "https://registry.yarnpkg.com/@oclif/parser/-/parser-3.8.5.tgz#c5161766a1efca7343e1f25d769efbefe09f639b" - integrity sha512-yojzeEfmSxjjkAvMRj0KzspXlMjCfBzNRPkWw8ZwOSoNWoJn+OCS/m/S+yfV6BvAM4u2lTzX9Y5rCbrFIgkJLg== - dependencies: - "@oclif/errors" "^1.2.2" - "@oclif/linewrap" "^1.0.0" - chalk "^2.4.2" - tslib "^1.9.3" - -"@oclif/plugin-help@^3", "@oclif/plugin-help@^3.2.0": - version "3.2.2" - resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-3.2.2.tgz#063ee08cee556573a5198fbdfdaa32796deba0ed" - integrity sha512-SPZ8U8PBYK0n4srFjCLedk0jWU4QlxgEYLCXIBShJgOwPhTTQknkUlsEwaMIevvCU4iCQZhfMX+D8Pz5GZjFgA== - dependencies: - "@oclif/command" "^1.5.20" - "@oclif/config" "^1.15.1" - "@oclif/errors" "^1.2.2" - chalk "^4.1.0" - indent-string "^4.0.0" - lodash.template "^4.4.0" - string-width "^4.2.0" - strip-ansi "^6.0.0" - widest-line "^3.1.0" - wrap-ansi "^4.0.0" - -"@oclif/screen@^1.0.3": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@oclif/screen/-/screen-1.0.4.tgz#b740f68609dfae8aa71c3a6cab15d816407ba493" - integrity sha512-60CHpq+eqnTxLZQ4PGHYNwUX572hgpMHGPtTWMjdTMsAvlm69lZV/4ly6O3sAYkomo4NggGcomrDpBe34rxUqw== - -"@types/bn.js@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.0.tgz#32c5d271503a12653c62cf4d2b45e6eab8cebc68" - integrity sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA== - dependencies: - "@types/node" "*" - -"@types/crypto-js@^4.0.2": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-4.0.2.tgz#4524325a175bf819fec6e42560c389ce1fb92c97" - integrity sha512-sCVniU+h3GcGqxOmng11BRvf9TfN9yIs8KKjB8C8d75W69cpTfZG80gau9yTx5SxF3gvHGbJhdESzzvnjtf3Og== - -"@types/eslint-visitor-keys@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" - integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== - -"@types/glob@^7.1.1": - version "7.1.4" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.4.tgz#ea59e21d2ee5c517914cb4bc8e4153b99e566672" - integrity sha512-w+LsMxKyYQm347Otw+IfBXOv9UWVjpHpCDdbBMt8Kz/xbvCYNjP+0qPh91Km3iKfSRLBB0P7fAMf0KHrPu+MyA== - dependencies: - "@types/minimatch" "*" - "@types/node" "*" - -"@types/json-schema@^7.0.3": - version "7.0.9" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" - integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== - -"@types/minimatch@*": - version "3.0.5" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" - integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== - -"@types/node@*": - version "16.4.11" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.4.11.tgz#245030af802c776c31f00eb0cdde40ee615db462" - integrity sha512-nWSFUbuNiPKJEe1IViuodSI+9cM+vpM8SWF/O6dJK7wmGRNq55U7XavJHrlRrPkSMuUZUFzg1xaZ1B+ZZCrRWw== - -"@types/node@11.11.6": - version "11.11.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a" - integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== - -"@types/node@^10": - version "10.17.60" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" - integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw== - -"@types/pbkdf2@^3.0.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@types/pbkdf2/-/pbkdf2-3.1.0.tgz#039a0e9b67da0cdc4ee5dab865caa6b267bb66b1" - integrity sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ== - dependencies: - "@types/node" "*" - -"@types/secp256k1@^4.0.1": - version "4.0.3" - resolved "https://registry.yarnpkg.com/@types/secp256k1/-/secp256k1-4.0.3.tgz#1b8e55d8e00f08ee7220b4d59a6abe89c37a901c" - integrity sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w== - dependencies: - "@types/node" "*" - -"@typescript-eslint/eslint-plugin@^2.6.1": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz#6f8ce8a46c7dea4a6f1d171d2bb8fbae6dac2be9" - integrity sha512-4zY3Z88rEE99+CNvTbXSyovv2z9PNOVffTWD2W8QF5s2prBQtwN2zadqERcrHpcR7O/+KMI3fcTAmUUhK/iQcQ== - dependencies: - "@typescript-eslint/experimental-utils" "2.34.0" - functional-red-black-tree "^1.0.1" - regexpp "^3.0.0" - tsutils "^3.17.1" - -"@typescript-eslint/experimental-utils@2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz#d3524b644cdb40eebceca67f8cf3e4cc9c8f980f" - integrity sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA== - dependencies: - "@types/json-schema" "^7.0.3" - "@typescript-eslint/typescript-estree" "2.34.0" - eslint-scope "^5.0.0" - eslint-utils "^2.0.0" - -"@typescript-eslint/parser@^2.6.1": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.34.0.tgz#50252630ca319685420e9a39ca05fe185a256bc8" - integrity sha512-03ilO0ucSD0EPTw2X4PntSIRFtDPWjrVq7C3/Z3VQHRC7+13YB55rcJI3Jt+YgeHbjUdJPcPa7b23rXCBokuyA== - dependencies: - "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "2.34.0" - "@typescript-eslint/typescript-estree" "2.34.0" - eslint-visitor-keys "^1.1.0" - -"@typescript-eslint/typescript-estree@2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz#14aeb6353b39ef0732cc7f1b8285294937cf37d5" - integrity sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg== - dependencies: - debug "^4.1.1" - eslint-visitor-keys "^1.1.0" - glob "^7.1.6" - is-glob "^4.0.1" - lodash "^4.17.15" - semver "^7.3.2" - tsutils "^3.17.1" - -acorn-jsx@^5.0.0: - version "5.3.2" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" - integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== - -acorn@^6.0.7: - version "6.4.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.2.tgz#35866fd710528e92de10cf06016498e47e39e1e6" - integrity sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ== - -ajv@^6.10.2, ajv@^6.9.1: - version "6.12.6" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ansi-escapes@^3.1.0, ansi-escapes@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" - integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ== - -ansi-escapes@^4.3.0: - version "4.3.2" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" - integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== - dependencies: - type-fest "^0.21.3" - -ansi-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" - integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= - -ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== - -ansi-regex@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" - integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== - -ansi-styles@^3.2.0, ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0, ansi-styles@^4.1.0, ansi-styles@^4.2.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -ansicolors@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979" - integrity sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk= - -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - -argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== - -astral-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" - integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -base-x@^3.0.2: - version "3.0.8" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.8.tgz#1e1106c2537f0162e8b52474a557ebb09000018d" - integrity sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA== - dependencies: - safe-buffer "^5.0.1" - -base64-js@^1.3.0, base64-js@^1.3.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - -bech32@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" - integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== - -bignumber.js@^9.0.1: - version "9.0.1" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.1.tgz#8d7ba124c882bfd8e43260c67475518d0689e4e5" - integrity sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA== - -bip39@^3.0.2: - version "3.0.4" - resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.0.4.tgz#5b11fed966840b5e1b8539f0f54ab6392969b2a0" - integrity sha512-YZKQlb752TrUWqHWj7XAwCSjYEgGAk+/Aas3V7NyjQeZYsztO8JnQUaCWhcnL4T+jL8nvB8typ2jRPzTlgugNw== - dependencies: - "@types/node" "11.11.6" - create-hash "^1.1.0" - pbkdf2 "^3.0.9" - randombytes "^2.0.1" - -bl@^4.0.3: - version "4.1.0" - resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" - integrity sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w== - dependencies: - buffer "^5.5.0" - inherits "^2.0.4" - readable-stream "^3.4.0" - -blakejs@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.1.1.tgz#bf313053978b2cd4c444a48795710be05c785702" - integrity sha512-bLG6PHOCZJKNshTjGRBvET0vTciwQE6zFKOKKXPDJfwFBd4Ac0yBfPZqcGvGJap50l7ktvlpFqc2jGVaUgbJgg== - -bn.js@4.11.6: - version "4.11.6" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" - integrity sha1-UzRK2xRhehP26N0s4okF0cC6MhU= - -bn.js@^4.11.1, bn.js@^4.11.6, bn.js@^4.11.8, bn.js@^4.11.9: - version "4.12.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" - integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== - -bn.js@^5.1.2: - version "5.2.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^3.0.1: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -brorand@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" - integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= - -browserify-aes@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" - integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== - dependencies: - buffer-xor "^1.0.3" - cipher-base "^1.0.0" - create-hash "^1.1.0" - evp_bytestokey "^1.0.3" - inherits "^2.0.1" - safe-buffer "^5.0.1" - -bs58@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" - integrity sha1-vhYedsNU9veIrkBx9j806MTwpCo= - dependencies: - base-x "^3.0.2" - -bs58check@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" - integrity sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA== - dependencies: - bs58 "^4.0.0" - create-hash "^1.1.0" - safe-buffer "^5.1.2" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -buffer-reverse@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/buffer-reverse/-/buffer-reverse-1.0.1.tgz#49283c8efa6f901bc01fa3304d06027971ae2f60" - integrity sha1-SSg8jvpvkBvAH6MwTQYCeXGuL2A= - -buffer-to-arraybuffer@^0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz#6064a40fa76eb43c723aba9ef8f6e1216d10511a" - integrity sha1-YGSkD6dutDxyOrqe+PbhIW0QURo= - -buffer-xor@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" - integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= - -buffer@^5.5.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" - integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.1.13" - -callsites@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" - integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== - -cardinal@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/cardinal/-/cardinal-2.1.1.tgz#7cc1055d822d212954d07b085dea251cc7bc5505" - integrity sha1-fMEFXYItISlU0HsIXeolHMe8VQU= - dependencies: - ansicolors "~0.3.2" - redeyed "~2.1.0" - -chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chardet@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" - integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== - -chownr@^1.1.1: - version "1.1.4" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" - integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== - -cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" - integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -clean-regexp@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/clean-regexp/-/clean-regexp-1.0.0.tgz#8df7c7aae51fd36874e8f8d05b9180bc11a3fed7" - integrity sha1-jffHquUf02h06PjQW5GAvBGj/tc= - dependencies: - escape-string-regexp "^1.0.5" - -clean-stack@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-3.0.1.tgz#155bf0b2221bf5f4fba89528d24c5953f17fe3a8" - integrity sha512-lR9wNiMRcVQjSB3a7xXGLuz4cr4wJuuXlaAEbRutGowQTmlp7R72/DOgN21e8jdwblMWl9UOJMJXarX94pzKdg== - dependencies: - escape-string-regexp "4.0.0" - -cli-cursor@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" - integrity sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU= - dependencies: - restore-cursor "^2.0.0" - -cli-progress@^3.4.0: - version "3.9.0" - resolved "https://registry.yarnpkg.com/cli-progress/-/cli-progress-3.9.0.tgz#25db83447deb812e62d05bac1af9aec5387ef3d4" - integrity sha512-g7rLWfhAo/7pF+a/STFH/xPyosaL1zgADhI0OM83hl3c7S43iGvJWEAV2QuDOnQ8i6EMBj/u4+NTd0d5L+4JfA== - dependencies: - colors "^1.1.2" - string-width "^4.2.0" - -cli-ux@^5.2.1: - version "5.6.3" - resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-5.6.3.tgz#eecdb2e0261171f2b28f2be6b18c490291c3a287" - integrity sha512-/oDU4v8BiDjX2OKcSunGH0iGDiEtj2rZaGyqNuv9IT4CgcSMyVWAMfn0+rEHaOc4n9ka78B0wo1+N1QX89f7mw== - dependencies: - "@oclif/command" "^1.6.0" - "@oclif/errors" "^1.2.1" - "@oclif/linewrap" "^1.0.0" - "@oclif/screen" "^1.0.3" - ansi-escapes "^4.3.0" - ansi-styles "^4.2.0" - cardinal "^2.1.1" - chalk "^4.1.0" - clean-stack "^3.0.0" - cli-progress "^3.4.0" - extract-stack "^2.0.0" - fs-extra "^8.1" - hyperlinker "^1.0.0" - indent-string "^4.0.0" - is-wsl "^2.2.0" - js-yaml "^3.13.1" - lodash "^4.17.11" - natural-orderby "^2.0.1" - object-treeify "^1.1.4" - password-prompt "^1.1.2" - semver "^7.3.2" - string-width "^4.2.0" - strip-ansi "^6.0.0" - supports-color "^8.1.0" - supports-hyperlinks "^2.1.0" - tslib "^2.0.0" - -cli-width@^2.0.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.1.tgz#b0433d0b4e9c847ef18868a4ef16fd5fc8271c48" - integrity sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw== - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -colors@^1.1.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" - integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -content-type@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" - integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== - -create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" - integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== - dependencies: - cipher-base "^1.0.1" - inherits "^2.0.1" - md5.js "^1.3.4" - ripemd160 "^2.0.1" - sha.js "^2.4.0" - -create-hmac@^1.1.4, create-hmac@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" - integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== - dependencies: - cipher-base "^1.0.3" - create-hash "^1.1.0" - inherits "^2.0.1" - ripemd160 "^2.0.0" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -cross-spawn@^6.0.0, cross-spawn@^6.0.5: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== - dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" - -crypto-js@^3.1.9-1: - version "3.3.0" - resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b" - integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q== - -debug@^4.0.1, debug@^4.1.1: - version "4.3.2" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b" - integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw== - dependencies: - ms "2.1.2" - -decode-uri-component@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" - integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= - -decompress-response@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" - integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M= - dependencies: - mimic-response "^1.0.0" - -deep-is@~0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" - integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= - -detect-indent@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.1.0.tgz#592485ebbbf6b3b1ab2be175c8393d04ca0d57e6" - integrity sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA== - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -dir-glob@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" - integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== - dependencies: - path-type "^4.0.0" - -doctrine@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" - integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== - dependencies: - esutils "^2.0.2" - -dom-walk@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84" - integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w== - -elliptic@^6.4.0, elliptic@^6.5.2, elliptic@^6.5.3: - version "6.5.4" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" - integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== - dependencies: - bn.js "^4.11.9" - brorand "^1.1.0" - hash.js "^1.0.0" - hmac-drbg "^1.0.1" - inherits "^2.0.4" - minimalistic-assert "^1.0.1" - minimalistic-crypto-utils "^1.0.1" - -"emoji-regex@>=6.0.0 <=6.1.1": - version "6.1.1" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-6.1.1.tgz#c6cd0ec1b0642e2a3c67a1137efc5e796da4f88e" - integrity sha1-xs0OwbBkLio8Z6ETfvxeeW2k+I4= - -emoji-regex@^7.0.1: - version "7.0.3" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" - integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -end-of-stream@^1.1.0, end-of-stream@^1.4.1: - version "1.4.4" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" - integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== - dependencies: - once "^1.4.0" - -error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -escape-string-regexp@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" - integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -eslint-ast-utils@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/eslint-ast-utils/-/eslint-ast-utils-1.1.0.tgz#3d58ba557801cfb1c941d68131ee9f8c34bd1586" - integrity sha512-otzzTim2/1+lVrlH19EfQQJEhVJSu0zOb9ygb3iapN6UlyaDtyRq4b5U1FuW0v1lRa9Fp/GJyHkSwm6NqABgCA== - dependencies: - lodash.get "^4.4.2" - lodash.zip "^4.2.0" - -eslint-config-oclif-typescript@^0.1: - version "0.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-oclif-typescript/-/eslint-config-oclif-typescript-0.1.0.tgz#c310767c5ee8916ea5d08cf027d0317dd52ed8ba" - integrity sha512-BjXNJcH2F02MdaSFml9vJskviUFVkLHbTPGM5tinIt98H6klFNKP7/lQ+fB/Goc2wB45usEuuw6+l/fwAv9i7g== - dependencies: - "@typescript-eslint/eslint-plugin" "^2.6.1" - "@typescript-eslint/parser" "^2.6.1" - eslint-config-oclif "^3.1.0" - eslint-config-xo-space "^0.20.0" - eslint-plugin-mocha "^5.2.0" - eslint-plugin-node "^7.0.1" - eslint-plugin-unicorn "^6.0.1" - -eslint-config-oclif@^3.1, eslint-config-oclif@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-oclif/-/eslint-config-oclif-3.1.0.tgz#cbc207ced09e31676dcee2f724fc509cd20eb0bd" - integrity sha512-Tqgy43cNXsSdhTLWW4RuDYGFhV240sC4ISSv/ZiUEg/zFxExSEUpRE6J+AGnkKY9dYwIW4C9b2YSUVv8z/miMA== - dependencies: - eslint-config-xo-space "^0.20.0" - eslint-plugin-mocha "^5.2.0" - eslint-plugin-node "^7.0.1" - eslint-plugin-unicorn "^6.0.1" - -eslint-config-xo-space@^0.20.0: - version "0.20.0" - resolved "https://registry.yarnpkg.com/eslint-config-xo-space/-/eslint-config-xo-space-0.20.0.tgz#75e1fb86d1b052fc1cc3036ca2fa441fa92b85e4" - integrity sha512-bOsoZA8M6v1HviDUIGVq1fLVnSu3mMZzn85m2tqKb73tSzu4GKD4Jd2Py4ZKjCgvCbRRByEB5HPC3fTMnnJ1uw== - dependencies: - eslint-config-xo "^0.24.0" - -eslint-config-xo@^0.24.0: - version "0.24.2" - resolved "https://registry.yarnpkg.com/eslint-config-xo/-/eslint-config-xo-0.24.2.tgz#f61b8ce692e9f9519bdb6edc4ed7ebcd5be48f48" - integrity sha512-ivQ7qISScW6gfBp+p31nQntz1rg34UCybd3uvlngcxt5Utsf4PMMi9QoAluLFcPUM5Tvqk4JGraR9qu3msKPKQ== - -eslint-plugin-es@^1.3.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-1.4.1.tgz#12acae0f4953e76ba444bfd1b2271081ac620998" - integrity sha512-5fa/gR2yR3NxQf+UXkeLeP8FBBl6tSgdrAz1+cF84v1FMM4twGwQoqTnn+QxFLcPOrF4pdKEJKDB/q9GoyJrCA== - dependencies: - eslint-utils "^1.4.2" - regexpp "^2.0.1" - -eslint-plugin-mocha@^5.2.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-mocha/-/eslint-plugin-mocha-5.3.0.tgz#cf3eb18ae0e44e433aef7159637095a7cb19b15b" - integrity sha512-3uwlJVLijjEmBeNyH60nzqgA1gacUWLUmcKV8PIGNvj1kwP/CTgAWQHn2ayyJVwziX+KETkr9opNwT1qD/RZ5A== - dependencies: - ramda "^0.26.1" - -eslint-plugin-node@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-7.0.1.tgz#a6e054e50199b2edd85518b89b4e7b323c9f36db" - integrity sha512-lfVw3TEqThwq0j2Ba/Ckn2ABdwmL5dkOgAux1rvOk6CO7A6yGyPI2+zIxN6FyNkp1X1X/BSvKOceD6mBWSj4Yw== - dependencies: - eslint-plugin-es "^1.3.1" - eslint-utils "^1.3.1" - ignore "^4.0.2" - minimatch "^3.0.4" - resolve "^1.8.1" - semver "^5.5.0" - -eslint-plugin-unicorn@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-6.0.1.tgz#4a97f0bc9449e20b82848dad12094ee2ba72347e" - integrity sha512-hjy9LhTdtL7pz8WTrzS0CGXRkWK3VAPLDjihofj8JC+uxQLfXm0WwZPPPB7xKmcjRyoH+jruPHOCrHNEINpG/Q== - dependencies: - clean-regexp "^1.0.0" - eslint-ast-utils "^1.0.0" - import-modules "^1.1.0" - lodash.camelcase "^4.1.1" - lodash.kebabcase "^4.0.1" - lodash.snakecase "^4.0.1" - lodash.upperfirst "^4.2.0" - safe-regex "^1.1.0" - -eslint-scope@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" - integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg== - dependencies: - esrecurse "^4.1.0" - estraverse "^4.1.1" - -eslint-scope@^5.0.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" - integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== - dependencies: - esrecurse "^4.3.0" - estraverse "^4.1.1" - -eslint-utils@^1.3.1, eslint-utils@^1.4.2: - version "1.4.3" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" - integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== - dependencies: - eslint-visitor-keys "^1.1.0" - -eslint-utils@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" - integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== - dependencies: - eslint-visitor-keys "^1.1.0" - -eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" - integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== - -eslint@^5.13: - version "5.16.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.16.0.tgz#a1e3ac1aae4a3fbd8296fcf8f7ab7314cbb6abea" - integrity sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg== - dependencies: - "@babel/code-frame" "^7.0.0" - ajv "^6.9.1" - chalk "^2.1.0" - cross-spawn "^6.0.5" - debug "^4.0.1" - doctrine "^3.0.0" - eslint-scope "^4.0.3" - eslint-utils "^1.3.1" - eslint-visitor-keys "^1.0.0" - espree "^5.0.1" - esquery "^1.0.1" - esutils "^2.0.2" - file-entry-cache "^5.0.1" - functional-red-black-tree "^1.0.1" - glob "^7.1.2" - globals "^11.7.0" - ignore "^4.0.6" - import-fresh "^3.0.0" - imurmurhash "^0.1.4" - inquirer "^6.2.2" - js-yaml "^3.13.0" - json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.3.0" - lodash "^4.17.11" - minimatch "^3.0.4" - mkdirp "^0.5.1" - natural-compare "^1.4.0" - optionator "^0.8.2" - path-is-inside "^1.0.2" - progress "^2.0.0" - regexpp "^2.0.1" - semver "^5.5.1" - strip-ansi "^4.0.0" - strip-json-comments "^2.0.1" - table "^5.2.3" - text-table "^0.2.0" - -espree@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-5.0.1.tgz#5d6526fa4fc7f0788a5cf75b15f30323e2f81f7a" - integrity sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A== - dependencies: - acorn "^6.0.7" - acorn-jsx "^5.0.0" - eslint-visitor-keys "^1.0.0" - -esprima@^4.0.0, esprima@~4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - -esquery@^1.0.1: - version "1.4.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5" - integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w== - dependencies: - estraverse "^5.1.0" - -esrecurse@^4.1.0, esrecurse@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" - integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== - dependencies: - estraverse "^5.2.0" - -estraverse@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - -estraverse@^5.1.0, estraverse@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" - integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== - -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - -eth-lib@0.2.8: - version "0.2.8" - resolved "https://registry.yarnpkg.com/eth-lib/-/eth-lib-0.2.8.tgz#b194058bef4b220ad12ea497431d6cb6aa0623c8" - integrity sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw== - dependencies: - bn.js "^4.11.6" - elliptic "^6.4.0" - xhr-request-promise "^0.1.2" - -ethereum-bloom-filters@^1.0.6: - version "1.0.10" - resolved "https://registry.yarnpkg.com/ethereum-bloom-filters/-/ethereum-bloom-filters-1.0.10.tgz#3ca07f4aed698e75bd134584850260246a5fed8a" - integrity sha512-rxJ5OFN3RwjQxDcFP2Z5+Q9ho4eIdEmSc2ht0fCu8Se9nbXjZ7/031uXoUYJ87KHCOdVeiUuwSnoS7hmYAGVHA== - dependencies: - js-sha3 "^0.8.0" - -ethereum-cryptography@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz#8d6143cfc3d74bf79bbd8edecdf29e4ae20dd191" - integrity sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ== - dependencies: - "@types/pbkdf2" "^3.0.0" - "@types/secp256k1" "^4.0.1" - blakejs "^1.1.0" - browserify-aes "^1.2.0" - bs58check "^2.1.2" - create-hash "^1.2.0" - create-hmac "^1.1.7" - hash.js "^1.1.7" - keccak "^3.0.0" - pbkdf2 "^3.0.17" - randombytes "^2.1.0" - safe-buffer "^5.1.2" - scrypt-js "^3.0.0" - secp256k1 "^4.0.1" - setimmediate "^1.0.5" - -ethereumjs-util@^7.1.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.1.0.tgz#e2b43a30bfcdbcb432a4eb42bd5f2393209b3fd5" - integrity sha512-kR+vhu++mUDARrsMMhsjjzPduRVAeundLGXucGRHF3B4oEltOUspfgCVco4kckucj3FMlLaZHUl9n7/kdmr6Tw== - dependencies: - "@types/bn.js" "^5.1.0" - bn.js "^5.1.2" - create-hash "^1.1.2" - ethereum-cryptography "^0.1.3" - ethjs-util "0.1.6" - rlp "^2.2.4" - -ethjs-unit@0.1.6: - version "0.1.6" - resolved "https://registry.yarnpkg.com/ethjs-unit/-/ethjs-unit-0.1.6.tgz#c665921e476e87bce2a9d588a6fe0405b2c41699" - integrity sha1-xmWSHkduh7ziqdWIpv4EBbLEFpk= - dependencies: - bn.js "4.11.6" - number-to-bn "1.7.0" - -ethjs-util@0.1.6: - version "0.1.6" - resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" - integrity sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w== - dependencies: - is-hex-prefixed "1.0.0" - strip-hex-prefix "1.0.0" - -evp_bytestokey@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" - integrity sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA== - dependencies: - md5.js "^1.3.4" - safe-buffer "^5.1.1" - -execa@^0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.10.0.tgz#ff456a8f53f90f8eccc71a96d11bdfc7f082cb50" - integrity sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw== - dependencies: - cross-spawn "^6.0.0" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - -external-editor@^3.0.3: - version "3.1.0" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" - integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew== - dependencies: - chardet "^0.7.0" - iconv-lite "^0.4.24" - tmp "^0.0.33" - -extract-stack@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/extract-stack/-/extract-stack-2.0.0.tgz#11367bc865bfcd9bc0db3123e5edb57786f11f9b" - integrity sha512-AEo4zm+TenK7zQorGK1f9mJ8L14hnTDi2ZQPR+Mub1NX8zimka1mXpV5LpH8x9HoUmFSHZCfLHqWvp0Y4FxxzQ== - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-glob@^3.0.3, fast-glob@^3.1.1: - version "3.2.7" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1" - integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.4" - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fast-levenshtein@~2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= - -fastq@^1.6.0: - version "1.11.1" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.11.1.tgz#5d8175aae17db61947f8b162cfc7f63264d22807" - integrity sha512-HOnr8Mc60eNYl1gzwp6r5RoUyAn5/glBolUzP/Ez6IFVPMPirxn/9phgL6zhOtaTy7ISwPvQ+wT+hfcRZh/bzw== - dependencies: - reusify "^1.0.4" - -figures@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" - integrity sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI= - dependencies: - escape-string-regexp "^1.0.5" - -file-entry-cache@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" - integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g== - dependencies: - flat-cache "^2.0.1" - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -find-up@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - -find-yarn-workspace-root@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd" - integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ== - dependencies: - micromatch "^4.0.2" - -flat-cache@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" - integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA== - dependencies: - flatted "^2.0.0" - rimraf "2.6.3" - write "1.0.3" - -flatted@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" - integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== - -fs-constants@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" - integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== - -fs-extra@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-6.0.1.tgz#8abc128f7946e310135ddc93b98bddb410e7a34b" - integrity sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA== - dependencies: - graceful-fs "^4.1.2" - jsonfile "^4.0.0" - universalify "^0.1.0" - -fs-extra@^8.1: - version "8.1.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" - integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^4.0.0" - universalify "^0.1.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= - -get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= - -get-stream@^5.1.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" - integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== - dependencies: - pump "^3.0.0" - -github-slugger@^1.2.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/github-slugger/-/github-slugger-1.3.0.tgz#9bd0a95c5efdfc46005e82a906ef8e2a059124c9" - integrity sha512-gwJScWVNhFYSRDvURk/8yhcFBee6aFjye2a7Lhb2bUyRulpIoek9p0I9Kt7PT67d/nUlZbFu8L9RLiA0woQN8Q== - dependencies: - emoji-regex ">=6.0.0 <=6.1.1" - -glob-parent@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob@^7.1.2, glob@^7.1.3, glob@^7.1.6: - version "7.1.7" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" - integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -global@~4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/global/-/global-4.4.0.tgz#3e7b105179006a323ed71aafca3e9c57a5cc6406" - integrity sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w== - dependencies: - min-document "^2.19.0" - process "^0.11.10" - -globals@^11.7.0: - version "11.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" - integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== - -globby@^10, globby@^10.0.1: - version "10.0.2" - resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.2.tgz#277593e745acaa4646c3ab411289ec47a0392543" - integrity sha512-7dUi7RvCoT/xast/o/dLN53oqND4yk0nsHkhRgn9w65C4PofCLOoJ39iSOg+qVDdWQPIEj+eszMHQ+aLVwwQSg== - dependencies: - "@types/glob" "^7.1.1" - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.0.3" - glob "^7.1.3" - ignore "^5.1.1" - merge2 "^1.2.3" - slash "^3.0.0" - -globby@^11.0.1: - version "11.0.4" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5" - integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.1.1" - ignore "^5.1.4" - merge2 "^1.3.0" - slash "^3.0.0" - -graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0: - version "4.2.6" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee" - integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -hash-base@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" - integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== - dependencies: - inherits "^2.0.4" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - -hash.js@^1.0.0, hash.js@^1.0.3, hash.js@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" - integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.1" - -hmac-drbg@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" - integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= - dependencies: - hash.js "^1.0.3" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.1" - -hosted-git-info@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-4.0.2.tgz#5e425507eede4fea846b7262f0838456c4209961" - integrity sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg== - dependencies: - lru-cache "^6.0.0" - -http-call@^5.1.2: - version "5.3.0" - resolved "https://registry.yarnpkg.com/http-call/-/http-call-5.3.0.tgz#4ded815b13f423de176eb0942d69c43b25b148db" - integrity sha512-ahwimsC23ICE4kPl9xTBjKB4inbRaeLyZeRunC/1Jy/Z6X8tv22MEAjK+KBOMSVLaqXPTTmd8638waVIKLGx2w== - dependencies: - content-type "^1.0.4" - debug "^4.1.1" - is-retry-allowed "^1.1.0" - is-stream "^2.0.0" - parse-json "^4.0.0" - tunnel-agent "^0.6.0" - -hyperlinker@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/hyperlinker/-/hyperlinker-1.0.0.tgz#23dc9e38a206b208ee49bc2d6c8ef47027df0c0e" - integrity sha512-Ty8UblRWFEcfSuIaajM34LdPXIhbs1ajEX/BBPv24J+enSVaEVY63xQ6lTO9VRYS5LAoghIG0IDJ+p+IPzKUQQ== - -iconv-lite@^0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - -ieee754@^1.1.13: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - -ignore@^4.0.2, ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== - -ignore@^5.1.1, ignore@^5.1.4: - version "5.1.8" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" - integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== - -import-fresh@^3.0.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" - integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== - dependencies: - parent-module "^1.0.0" - resolve-from "^4.0.0" - -import-modules@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/import-modules/-/import-modules-1.1.0.tgz#748db79c5cc42bb9701efab424f894e72600e9dc" - integrity sha1-dI23nFzEK7lwHvq0JPiU5yYA6dw= - -imurmurhash@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= - -indent-string@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" - integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -inquirer@^6.2.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.5.2.tgz#ad50942375d036d327ff528c08bd5fab089928ca" - integrity sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ== - dependencies: - ansi-escapes "^3.2.0" - chalk "^2.4.2" - cli-cursor "^2.1.0" - cli-width "^2.0.0" - external-editor "^3.0.3" - figures "^2.0.0" - lodash "^4.17.12" - mute-stream "0.0.7" - run-async "^2.2.0" - rxjs "^6.4.0" - string-width "^2.1.0" - strip-ansi "^5.1.0" - through "^2.3.6" - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= - -is-core-module@^2.2.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.5.0.tgz#f754843617c70bfd29b7bd87327400cda5c18491" - integrity sha512-TXCMSDsEHMEEZ6eCA8rwRDbLu55MRGmrctljsBX/2v1d9/GzqHOxW5c5oPSgrUt2vBFXebu9rGqckXGPWOlYpg== - dependencies: - has "^1.0.3" - -is-docker@^2.0.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" - integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= - -is-fullwidth-code-point@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" - integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-function@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.2.tgz#4f097f30abf6efadac9833b17ca5dc03f8144e08" - integrity sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ== - -is-glob@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" - integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== - dependencies: - is-extglob "^2.1.1" - -is-hex-prefixed@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz#7d8d37e6ad77e5d127148913c573e082d777f554" - integrity sha1-fY035q135dEnFIkTxXPggtd39VQ= - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-plain-obj@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" - integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== - -is-retry-allowed@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4" - integrity sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg== - -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= - -is-stream@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" - integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== - -is-typedarray@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= - -is-wsl@^2.1.1, is-wsl@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" - integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== - dependencies: - is-docker "^2.0.0" - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -js-sha3@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" - integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-yaml@^3.13.0, js-yaml@^3.13.1: - version "3.14.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" - integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - -json-parse-better-errors@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" - integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== - -json-parse-even-better-errors@^2.3.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json-stable-stringify-without-jsonify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= - -jsonfile@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" - integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= - optionalDependencies: - graceful-fs "^4.1.6" - -keccak@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.1.tgz#ae30a0e94dbe43414f741375cff6d64c8bea0bff" - integrity sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA== - dependencies: - node-addon-api "^2.0.0" - node-gyp-build "^4.2.0" - -levn@^0.3.0, levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= - dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" - -libsodium-wrappers@^0.7.6: - version "0.7.9" - resolved "https://registry.yarnpkg.com/libsodium-wrappers/-/libsodium-wrappers-0.7.9.tgz#4ffc2b69b8f7c7c7c5594a93a4803f80f6d0f346" - integrity sha512-9HaAeBGk1nKTRFRHkt7nzxqCvnkWTjn1pdjKgcUnZxj0FyOP4CnhgFhMdrFfgNsukijBGyBLpP2m2uKT1vuWhQ== - dependencies: - libsodium "^0.7.0" - -libsodium@^0.7.0: - version "0.7.9" - resolved "https://registry.yarnpkg.com/libsodium/-/libsodium-0.7.9.tgz#4bb7bcbf662ddd920d8795c227ae25bbbfa3821b" - integrity sha512-gfeADtR4D/CM0oRUviKBViMGXZDgnFdMKMzHsvBdqLBHd9ySi6EtYnmuhHVDDYgYpAO8eU8hEY+F8vIUAPh08A== - -lines-and-columns@^1.1.6: - version "1.1.6" - resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" - integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= - -load-json-file@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-6.2.0.tgz#5c7770b42cafa97074ca2848707c61662f4251a1" - integrity sha512-gUD/epcRms75Cw8RT1pUdHugZYM5ce64ucs2GEISABwkRsOQr0q2wm/MV2TKThycIe5e0ytRweW2RZxclogCdQ== - dependencies: - graceful-fs "^4.1.15" - parse-json "^5.0.0" - strip-bom "^4.0.0" - type-fest "^0.6.0" - -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== - dependencies: - p-locate "^4.1.0" - -lodash._reinterpolate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" - integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= - -lodash.camelcase@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" - integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY= - -lodash.get@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" - integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= - -lodash.kebabcase@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36" - integrity sha1-hImxyw0p/4gZXM7KRI/21swpXDY= - -lodash.snakecase@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz#39d714a35357147837aefd64b5dcbb16becd8f8d" - integrity sha1-OdcUo1NXFHg3rv1ktdy7Fr7Nj40= - -lodash.template@^4.4.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" - integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A== - dependencies: - lodash._reinterpolate "^3.0.0" - lodash.templatesettings "^4.0.0" - -lodash.templatesettings@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz#e481310f049d3cf6d47e912ad09313b154f0fb33" - integrity sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ== - dependencies: - lodash._reinterpolate "^3.0.0" - -lodash.upperfirst@^4.2.0: - version "4.3.1" - resolved "https://registry.yarnpkg.com/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz#1365edf431480481ef0d1c68957a5ed99d49f7ce" - integrity sha1-E2Xt9DFIBIHvDRxolXpe2Z1J984= - -lodash.zip@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/lodash.zip/-/lodash.zip-4.2.0.tgz#ec6662e4896408ed4ab6c542a3990b72cc080020" - integrity sha1-7GZi5IlkCO1KtsVCo5kLcswIACA= - -lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - -make-dir@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" - integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== - dependencies: - semver "^6.0.0" - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -md5.js@^1.3.4: - version "1.3.5" - resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" - integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -merge2@^1.2.3, merge2@^1.3.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" - integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== - -merkletreejs@^0.2.23: - version "0.2.24" - resolved "https://registry.yarnpkg.com/merkletreejs/-/merkletreejs-0.2.24.tgz#6dc52b3e0946846c25816216f1b60094a18a5e7a" - integrity sha512-JUv2zSFuTpMj9uxqNXAOAQz6LKXL/AUalyuDzvqyf0fV09VeU7WjNDMDD+wbdtrA1mNEbV5w1XDWXMud8aNYTg== - dependencies: - bignumber.js "^9.0.1" - buffer-reverse "^1.0.1" - crypto-js "^3.1.9-1" - treeify "^1.1.0" - web3-utils "^1.3.4" - -micromatch@^4.0.2, micromatch@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" - integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== - dependencies: - braces "^3.0.1" - picomatch "^2.2.3" - -mimic-fn@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" - integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== - -mimic-response@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" - integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== - -min-document@^2.19.0: - version "2.19.0" - resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685" - integrity sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU= - dependencies: - dom-walk "^0.1.0" - -minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimalistic-crypto-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" - integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= - -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== - dependencies: - brace-expansion "^1.1.7" - -minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== - -mkdirp-classic@^0.5.2: - version "0.5.3" - resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" - integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== - -mkdirp@^0.5.1: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -mute-stream@0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" - integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s= - -natural-compare@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" - integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= - -natural-orderby@^2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/natural-orderby/-/natural-orderby-2.0.3.tgz#8623bc518ba162f8ff1cdb8941d74deb0fdcc016" - integrity sha512-p7KTHxU0CUrcOXe62Zfrb5Z13nLvPhSWR/so3kFulUQU0sgUll2Z0LwpsLN351eOOD+hRGu/F1g+6xDfPeD++Q== - -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== - -node-addon-api@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" - integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== - -node-gyp-build@^4.2.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.2.3.tgz#ce6277f853835f718829efb47db20f3e4d9c4739" - integrity sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg== - -normalize-package-data@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-3.0.2.tgz#cae5c410ae2434f9a6c1baa65d5bc3b9366c8699" - integrity sha512-6CdZocmfGaKnIHPVFhJJZ3GuR8SsLKvDANFp47Jmy51aKIr8akjAWTSxtpI+MBgBFdSMRyo4hMpDlT6dTffgZg== - dependencies: - hosted-git-info "^4.0.1" - resolve "^1.20.0" - semver "^7.3.4" - validate-npm-package-license "^3.0.1" - -npm-run-path@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" - integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= - dependencies: - path-key "^2.0.0" - -number-to-bn@1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/number-to-bn/-/number-to-bn-1.7.0.tgz#bb3623592f7e5f9e0030b1977bd41a0c53fe1ea0" - integrity sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA= - dependencies: - bn.js "4.11.6" - strip-hex-prefix "1.0.0" - -object-assign@^4.1.0, object-assign@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - -object-treeify@^1.1.4: - version "1.1.33" - resolved "https://registry.yarnpkg.com/object-treeify/-/object-treeify-1.1.33.tgz#f06fece986830a3cba78ddd32d4c11d1f76cdf40" - integrity sha512-EFVjAYfzWqWsBMRHPMAXLCDIJnpMhdWAqR7xG6M6a2cs6PMFpl/+Z20w9zDW4vkxOFfddegBKq9Rehd0bxWE7A== - -once@^1.3.0, once@^1.3.1, once@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -onetime@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" - integrity sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ= - dependencies: - mimic-fn "^1.0.0" - -optionator@^0.8.2: - version "0.8.3" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" - integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== - dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.6" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - word-wrap "~1.2.3" - -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= - -p-finally@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= - -p-limit@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -parent-module@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" - integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== - dependencies: - callsites "^3.0.0" - -parse-headers@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/parse-headers/-/parse-headers-2.0.3.tgz#5e8e7512383d140ba02f0c7aa9f49b4399c92515" - integrity sha512-QhhZ+DCCit2Coi2vmAKbq5RGTRcQUOE2+REgv8vdyu7MnYx2eZztegqtTx99TZ86GTIwqiy3+4nQTWZ2tgmdCA== - -parse-json@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" - integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= - dependencies: - error-ex "^1.3.1" - json-parse-better-errors "^1.0.1" - -parse-json@^5.0.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" - integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== - dependencies: - "@babel/code-frame" "^7.0.0" - error-ex "^1.3.1" - json-parse-even-better-errors "^2.3.0" - lines-and-columns "^1.1.6" - -password-prompt@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/password-prompt/-/password-prompt-1.1.2.tgz#85b2f93896c5bd9e9f2d6ff0627fa5af3dc00923" - integrity sha512-bpuBhROdrhuN3E7G/koAju0WjVw9/uQOG5Co5mokNj0MiOSBVZS1JTwM4zl55hu0WFmIEFvO9cU9sJQiBIYeIA== - dependencies: - ansi-escapes "^3.1.0" - cross-spawn "^6.0.5" - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -path-is-inside@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" - integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= - -path-key@^2.0.0, path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= - -path-parse@^1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - -pbkdf2@^3.0.17, pbkdf2@^3.0.9: - version "3.1.2" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.2.tgz#dd822aa0887580e52f1a039dc3eda108efae3075" - integrity sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA== - dependencies: - create-hash "^1.1.2" - create-hmac "^1.1.4" - ripemd160 "^2.0.1" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -picomatch@^2.2.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972" - integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw== - -pkg-dir@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" - integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== - dependencies: - find-up "^4.0.0" - -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= - -process@^0.11.10: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= - -progress@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== - -pump@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" - integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -qqjs@^0.3.10: - version "0.3.11" - resolved "https://registry.yarnpkg.com/qqjs/-/qqjs-0.3.11.tgz#795b9f7d00807d75c391b1241b5be3077143d9ea" - integrity sha512-pB2X5AduTl78J+xRSxQiEmga1jQV0j43jOPs/MTgTLApGFEOn6NgdE2dEjp7nvDtjkIOZbvFIojAiYUx6ep3zg== - dependencies: - chalk "^2.4.1" - debug "^4.1.1" - execa "^0.10.0" - fs-extra "^6.0.1" - get-stream "^5.1.0" - glob "^7.1.2" - globby "^10.0.1" - http-call "^5.1.2" - load-json-file "^6.2.0" - pkg-dir "^4.2.0" - tar-fs "^2.0.0" - tmp "^0.1.0" - write-json-file "^4.1.1" - -query-string@^5.0.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb" - integrity sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw== - dependencies: - decode-uri-component "^0.2.0" - object-assign "^4.1.0" - strict-uri-encode "^1.0.0" - -queue-microtask@^1.2.2: - version "1.2.3" - resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" - integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== - -ramda@^0.26.1: - version "0.26.1" - resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.26.1.tgz#8d41351eb8111c55353617fc3bbffad8e4d35d06" - integrity sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ== - -randombytes@^2.0.1, randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readonly-date@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/readonly-date/-/readonly-date-1.0.0.tgz#5af785464d8c7d7c40b9d738cbde8c646f97dcd9" - integrity sha512-tMKIV7hlk0h4mO3JTmmVuIlJVXjKk3Sep9Bf5OH0O+758ruuVkUy2J9SttDLm91IEX/WHlXPSpxMGjPj4beMIQ== - -redeyed@~2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/redeyed/-/redeyed-2.1.1.tgz#8984b5815d99cb220469c99eeeffe38913e6cc0b" - integrity sha1-iYS1gV2ZyyIEacme7v/jiRPmzAs= - dependencies: - esprima "~4.0.0" - -regexpp@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" - integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== - -regexpp@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" - integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== - -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== - -resolve@^1.20.0, resolve@^1.8.1: - version "1.20.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" - integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== - dependencies: - is-core-module "^2.2.0" - path-parse "^1.0.6" - -restore-cursor@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" - integrity sha1-n37ih/gv0ybU/RYpI9YhKe7g368= - dependencies: - onetime "^2.0.0" - signal-exit "^3.0.2" - -ret@~0.1.10: - version "0.1.15" - resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" - integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== - -reusify@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" - integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== - -rimraf@2.6.3: - version "2.6.3" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" - integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== - dependencies: - glob "^7.1.3" - -rimraf@^2.6.3: - version "2.7.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" - -ripemd160@^2.0.0, ripemd160@^2.0.1, ripemd160@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" - integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - -rlp@^2.2.4: - version "2.2.6" - resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.2.6.tgz#c80ba6266ac7a483ef1e69e8e2f056656de2fb2c" - integrity sha512-HAfAmL6SDYNWPUOJNrM500x4Thn4PZsEy5pijPh40U9WfNk0z15hUYzO9xVIMAdIHdFtD8CBDHd75Td1g36Mjg== - dependencies: - bn.js "^4.11.1" - -run-async@^2.2.0: - version "2.4.1" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" - integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== - -run-parallel@^1.1.9: - version "1.2.0" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" - integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== - dependencies: - queue-microtask "^1.2.2" - -rxjs@^6.4.0: - version "6.6.7" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.7.tgz#90ac018acabf491bf65044235d5863c4dab804c9" - integrity sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ== - dependencies: - tslib "^1.9.0" - -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-regex@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" - integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4= - dependencies: - ret "~0.1.10" - -"safer-buffer@>= 2.1.2 < 3": - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -scrypt-js@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312" - integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== - -secp256k1@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.2.tgz#15dd57d0f0b9fdb54ac1fa1694f40e5e9a54f4a1" - integrity sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg== - dependencies: - elliptic "^6.5.2" - node-addon-api "^2.0.0" - node-gyp-build "^4.2.0" - -semver@^5.5.0, semver@^5.5.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -semver@^6.0.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - -semver@^7.3.2, semver@^7.3.4: - version "7.3.5" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" - integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== - dependencies: - lru-cache "^6.0.0" - -setimmediate@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= - -sha.js@^2.4.0, sha.js@^2.4.11, sha.js@^2.4.8: - version "2.4.11" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" - integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== - dependencies: - inherits "^2.0.1" - safe-buffer "^5.0.1" - -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= - dependencies: - shebang-regex "^1.0.0" - -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= - -signal-exit@^3.0.0, signal-exit@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" - integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== - -simple-concat@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.1.tgz#f46976082ba35c2263f1c8ab5edfe26c41c9552f" - integrity sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q== - -simple-get@^2.7.0: - version "2.8.1" - resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-2.8.1.tgz#0e22e91d4575d87620620bc91308d57a77f44b5d" - integrity sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw== - dependencies: - decompress-response "^3.3.0" - once "^1.3.1" - simple-concat "^1.0.0" - -slash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - -slice-ansi@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" - integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== - dependencies: - ansi-styles "^3.2.0" - astral-regex "^1.0.0" - is-fullwidth-code-point "^2.0.0" - -sort-keys@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-4.2.0.tgz#6b7638cee42c506fff8c1cecde7376d21315be18" - integrity sha512-aUYIEU/UviqPgc8mHR6IW1EGxkAXpeRETYcrzg8cLAvUPZcpAlleSXHV2mY7G12GphSH6Gzv+4MMVSSkbdteHg== - dependencies: - is-plain-obj "^2.0.0" - -source-map-support@^0.5.17: - version "0.5.19" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" - integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -spdx-correct@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" - integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== - dependencies: - spdx-expression-parse "^3.0.0" - spdx-license-ids "^3.0.0" - -spdx-exceptions@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" - integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== - -spdx-expression-parse@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" - integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== - dependencies: - spdx-exceptions "^2.1.0" - spdx-license-ids "^3.0.0" - -spdx-license-ids@^3.0.0: - version "3.0.9" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.9.tgz#8a595135def9592bda69709474f1cbeea7c2467f" - integrity sha512-Ki212dKK4ogX+xDo4CtOZBVIwhsKBEfsEEcwmJfLQzirgc2jIWdzg40Unxz/HzEUqM1WFzVlQSMF9kZZ2HboLQ== - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -strict-uri-encode@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" - integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM= - -string-width@^2.1.0, string-width@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" - integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== - dependencies: - is-fullwidth-code-point "^2.0.0" - strip-ansi "^4.0.0" - -string-width@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" - integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== - dependencies: - emoji-regex "^7.0.1" - is-fullwidth-code-point "^2.0.0" - strip-ansi "^5.1.0" - -string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0: - version "4.2.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5" - integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" - -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -strip-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" - integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= - dependencies: - ansi-regex "^3.0.0" - -strip-ansi@^5.1.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" - integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== - dependencies: - ansi-regex "^4.1.0" - -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== - dependencies: - ansi-regex "^5.0.0" - -strip-bom@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878" - integrity sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w== - -strip-eof@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= - -strip-hex-prefix@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz#0c5f155fef1151373377de9dbb588da05500e36f" - integrity sha1-DF8VX+8RUTczd96du1iNoFUA428= - dependencies: - is-hex-prefixed "1.0.0" - -strip-json-comments@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-color@^7.0.0, supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-color@^8.1.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - -supports-hyperlinks@^2.1.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.2.0.tgz#4f77b42488765891774b70c79babd87f9bd594bb" - integrity sha512-6sXEzV5+I5j8Bmq9/vUphGRM/RJNT9SCURJLjwfOg51heRtguGWDzcaBlgAzKhQa0EVNpPEKzQuBwZ8S8WaCeQ== - dependencies: - has-flag "^4.0.0" - supports-color "^7.0.0" - -table@^5.2.3: - version "5.4.6" - resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" - integrity sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug== - dependencies: - ajv "^6.10.2" - lodash "^4.17.14" - slice-ansi "^2.1.0" - string-width "^3.0.0" - -tar-fs@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.1.tgz#489a15ab85f1f0befabb370b7de4f9eb5cbe8784" - integrity sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng== - dependencies: - chownr "^1.1.1" - mkdirp-classic "^0.5.2" - pump "^3.0.0" - tar-stream "^2.1.4" - -tar-stream@^2.1.4: - version "2.2.0" - resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-2.2.0.tgz#acad84c284136b060dc3faa64474aa9aebd77287" - integrity sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ== - dependencies: - bl "^4.0.3" - end-of-stream "^1.4.1" - fs-constants "^1.0.0" - inherits "^2.0.3" - readable-stream "^3.1.1" - -text-table@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= - -through@^2.3.6: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -timed-out@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" - integrity sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8= - -tmp@^0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== - dependencies: - os-tmpdir "~1.0.2" - -tmp@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.1.0.tgz#ee434a4e22543082e294ba6201dcc6eafefa2877" - integrity sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw== - dependencies: - rimraf "^2.6.3" - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -treeify@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/treeify/-/treeify-1.1.0.tgz#4e31c6a463accd0943879f30667c4fdaff411bb8" - integrity sha512-1m4RA7xVAJrSGrrXGs0L3YTwyvBs2S8PbRHaLZAkFw7JR8oIFwYtysxlBZhYIa7xSyiYJKZ3iGrrk55cGA3i9A== - -ts-node@^8: - version "8.10.2" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d" - integrity sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA== - dependencies: - arg "^4.1.0" - diff "^4.0.1" - make-error "^1.1.1" - source-map-support "^0.5.17" - yn "3.1.1" - -tslib@^1, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: - version "1.14.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" - integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== - -tslib@^2.0.0, tslib@^2.0.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.0.tgz#803b8cdab3e12ba581a4ca41c8839bbb0dacb09e" - integrity sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg== - -tsutils@^3.17.1: - version "3.21.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" - integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== - dependencies: - tslib "^1.8.1" - -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" - integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= - dependencies: - safe-buffer "^5.0.1" - -type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I= - dependencies: - prelude-ls "~1.1.2" - -type-fest@^0.21.3: - version "0.21.3" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" - integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== - -type-fest@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.6.0.tgz#8d2a2370d3df886eb5c90ada1c5bf6188acf838b" - integrity sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg== - -typedarray-to-buffer@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" - integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q== - dependencies: - is-typedarray "^1.0.0" - -typescript@^3.3: - version "3.9.10" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8" - integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q== - -universalify@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== - -uri-js@^4.2.2: - version "4.4.1" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" - integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== - dependencies: - punycode "^2.1.0" - -url-set-query@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/url-set-query/-/url-set-query-1.0.0.tgz#016e8cfd7c20ee05cafe7795e892bd0702faa339" - integrity sha1-AW6M/Xwg7gXK/neV6JK9BwL6ozk= - -utf8@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1" - integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ== - -util-deprecate@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -validate-npm-package-license@^3.0.1: - version "3.0.4" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" - integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== - dependencies: - spdx-correct "^3.0.0" - spdx-expression-parse "^3.0.0" - -web3-utils@^1.3.4: - version "1.5.0" - resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.5.0.tgz#48c8ba0d95694e73b9a6d473d955880cd4758e4a" - integrity sha512-hNyw7Oxi6TM3ivXmv4hK5Cvyi9ML3UoKtcCYvLF9woPWh5v2dwCCVO1U3Iq5HHK7Dqq28t1d4CxWHqUfOfAkgg== - dependencies: - bn.js "^4.11.9" - eth-lib "0.2.8" - ethereum-bloom-filters "^1.0.6" - ethjs-unit "0.1.6" - number-to-bn "1.7.0" - randombytes "^2.1.0" - utf8 "3.0.0" - -which@^1.2.9: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - -widest-line@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-3.1.0.tgz#8292333bbf66cb45ff0de1603b136b7ae1496eca" - integrity sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg== - dependencies: - string-width "^4.0.0" - -word-wrap@~1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" - integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== - -wrap-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-4.0.0.tgz#b3570d7c70156159a2d42be5cc942e957f7b1131" - integrity sha512-uMTsj9rDb0/7kk1PbcbCcwvHUxp60fGDB/NNXpVa0Q+ic/e7y5+BwTxKfQ33VYgDppSwi/FBzpetYzo8s6tfbg== - dependencies: - ansi-styles "^3.2.0" - string-width "^2.1.1" - strip-ansi "^4.0.0" - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -write-file-atomic@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.3.tgz#56bd5c5a5c70481cd19c571bd39ab965a5de56e8" - integrity sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q== - dependencies: - imurmurhash "^0.1.4" - is-typedarray "^1.0.0" - signal-exit "^3.0.2" - typedarray-to-buffer "^3.1.5" - -write-json-file@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/write-json-file/-/write-json-file-4.3.0.tgz#908493d6fd23225344af324016e4ca8f702dd12d" - integrity sha512-PxiShnxf0IlnQuMYOPPhPkhExoCQuTUNPOa/2JWCYTmBquU9njyyDuwRKN26IZBlp4yn1nt+Agh2HOOBl+55HQ== - dependencies: - detect-indent "^6.0.0" - graceful-fs "^4.1.15" - is-plain-obj "^2.0.0" - make-dir "^3.0.0" - sort-keys "^4.0.0" - write-file-atomic "^3.0.0" - -write@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" - integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== - dependencies: - mkdirp "^0.5.1" - -xhr-request-promise@^0.1.2: - version "0.1.3" - resolved "https://registry.yarnpkg.com/xhr-request-promise/-/xhr-request-promise-0.1.3.tgz#2d5f4b16d8c6c893be97f1a62b0ed4cf3ca5f96c" - integrity sha512-YUBytBsuwgitWtdRzXDDkWAXzhdGB8bYm0sSzMPZT7Z2MBjMSTHFsyCT1yCRATY+XC69DUrQraRAEgcoCRaIPg== - dependencies: - xhr-request "^1.1.0" - -xhr-request@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/xhr-request/-/xhr-request-1.1.0.tgz#f4a7c1868b9f198723444d82dcae317643f2e2ed" - integrity sha512-Y7qzEaR3FDtL3fP30k9wO/e+FBnBByZeybKOhASsGP30NIkRAAkKD/sCnLvgEfAIEC1rcmK7YG8f4oEnIrrWzA== - dependencies: - buffer-to-arraybuffer "^0.0.5" - object-assign "^4.1.1" - query-string "^5.0.1" - simple-get "^2.7.0" - timed-out "^4.0.1" - url-set-query "^1.0.0" - xhr "^2.0.4" - -xhr@^2.0.4: - version "2.6.0" - resolved "https://registry.yarnpkg.com/xhr/-/xhr-2.6.0.tgz#b69d4395e792b4173d6b7df077f0fc5e4e2b249d" - integrity sha512-/eCGLb5rxjx5e3mF1A7s+pLlR6CGyqWN91fv1JgER5mVWg1MZmlhBvy9kjcsOdRk8RrIujotWyJamfyrp+WIcA== - dependencies: - global "~4.4.0" - is-function "^1.0.1" - parse-headers "^2.0.0" - xtend "^4.0.0" - -xtend@^4.0.0: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== diff --git a/contracts/cw20-merkle-airdrop/src/contract.rs b/contracts/cw20-merkle-airdrop/src/contract.rs deleted file mode 100644 index bdf555e84..000000000 --- a/contracts/cw20-merkle-airdrop/src/contract.rs +++ /dev/null @@ -1,548 +0,0 @@ -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; -use cosmwasm_std::{ - attr, to_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, Uint128, - WasmMsg, -}; -use cw2::{get_contract_version, set_contract_version}; -use cw20::Cw20ExecuteMsg; -use sha2::Digest; -use std::convert::TryInto; - -use crate::error::ContractError; -use crate::msg::{ - ConfigResponse, ExecuteMsg, InstantiateMsg, IsClaimedResponse, LatestStageResponse, - MerkleRootResponse, MigrateMsg, QueryMsg, -}; -use crate::state::{Config, CLAIM, CONFIG, LATEST_STAGE, MERKLE_ROOT}; - -// Version info, for migration info -const CONTRACT_NAME: &str = "crates.io:cw20-merkle-airdrop"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn instantiate( - deps: DepsMut, - _env: Env, - info: MessageInfo, - msg: InstantiateMsg, -) -> StdResult { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - - let owner = msg - .owner - .map_or(Ok(info.sender), |o| deps.api.addr_validate(&o))?; - - let config = Config { - owner: Some(owner), - cw20_token_address: deps.api.addr_validate(&msg.cw20_token_address)?, - }; - CONFIG.save(deps.storage, &config)?; - - let stage = 0; - LATEST_STAGE.save(deps.storage, &stage)?; - - Ok(Response::default()) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> Result { - match msg { - ExecuteMsg::UpdateConfig { new_owner } => execute_update_config(deps, env, info, new_owner), - ExecuteMsg::RegisterMerkleRoot { merkle_root } => { - execute_register_merkle_root(deps, env, info, merkle_root) - } - ExecuteMsg::Claim { - stage, - amount, - proof, - } => execute_claim(deps, env, info, stage, amount, proof), - } -} - -pub fn execute_update_config( - deps: DepsMut, - _env: Env, - info: MessageInfo, - new_owner: Option, -) -> Result { - // authorize owner - let cfg = CONFIG.load(deps.storage)?; - let owner = cfg.owner.ok_or(ContractError::Unauthorized {})?; - if info.sender != owner { - return Err(ContractError::Unauthorized {}); - } - - // if owner some validated to addr, otherwise set to none - let mut tmp_owner = None; - if let Some(addr) = new_owner { - tmp_owner = Some(deps.api.addr_validate(&addr)?) - } - - CONFIG.update(deps.storage, |mut exists| -> StdResult<_> { - exists.owner = tmp_owner; - Ok(exists) - })?; - - Ok(Response::new().add_attribute("action", "update_config")) -} - -pub fn execute_register_merkle_root( - deps: DepsMut, - _env: Env, - info: MessageInfo, - merkle_root: String, -) -> Result { - let cfg = CONFIG.load(deps.storage)?; - - // if owner set validate, otherwise unauthorized - let owner = cfg.owner.ok_or(ContractError::Unauthorized {})?; - if info.sender != owner { - return Err(ContractError::Unauthorized {}); - } - - // check merkle root length - let mut root_buf: [u8; 32] = [0; 32]; - hex::decode_to_slice(merkle_root.to_string(), &mut root_buf)?; - - let stage = LATEST_STAGE.update(deps.storage, |stage| -> StdResult<_> { Ok(stage + 1) })?; - - MERKLE_ROOT.save(deps.storage, stage, &merkle_root)?; - LATEST_STAGE.save(deps.storage, &stage)?; - - Ok(Response::new().add_attributes(vec![ - attr("action", "register_merkle_root"), - attr("stage", stage.to_string()), - attr("merkle_root", merkle_root), - ])) -} - -pub fn execute_claim( - deps: DepsMut, - _env: Env, - info: MessageInfo, - stage: u8, - amount: Uint128, - proof: Vec, -) -> Result { - // verify not claimed - let claimed = CLAIM.may_load(deps.storage, (&info.sender, stage))?; - if claimed.is_some() { - return Err(ContractError::Claimed {}); - } - - let config = CONFIG.load(deps.storage)?; - let merkle_root = MERKLE_ROOT.load(deps.storage, stage)?; - - let user_input = format!("{}{}", info.sender, amount); - let hash = sha2::Sha256::digest(user_input.as_bytes()) - .as_slice() - .try_into() - .map_err(|_| ContractError::WrongLength {})?; - - let hash = proof.into_iter().try_fold(hash, |hash, p| { - let mut proof_buf = [0; 32]; - hex::decode_to_slice(p, &mut proof_buf)?; - let mut hashes = [hash, proof_buf]; - hashes.sort_unstable(); - sha2::Sha256::digest(&hashes.concat()) - .as_slice() - .try_into() - .map_err(|_| ContractError::WrongLength {}) - })?; - - let mut root_buf: [u8; 32] = [0; 32]; - hex::decode_to_slice(merkle_root, &mut root_buf)?; - if root_buf != hash { - return Err(ContractError::VerificationFailed {}); - } - - // Update claim index to the current stage - CLAIM.save(deps.storage, (&info.sender, stage), &true)?; - - let res = Response::new() - .add_message(WasmMsg::Execute { - contract_addr: config.cw20_token_address.to_string(), - funds: vec![], - msg: to_binary(&Cw20ExecuteMsg::Transfer { - recipient: info.sender.to_string(), - amount, - })?, - }) - .add_attributes(vec![ - attr("action", "claim"), - attr("stage", stage.to_string()), - attr("address", info.sender), - attr("amount", amount), - ]); - Ok(res) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::Config {} => to_binary(&query_config(deps)?), - QueryMsg::MerkleRoot { stage } => to_binary(&query_merkle_root(deps, stage)?), - QueryMsg::LatestStage {} => to_binary(&query_latest_stage(deps)?), - QueryMsg::IsClaimed { stage, address } => { - to_binary(&query_is_claimed(deps, stage, address)?) - } - } -} - -pub fn query_config(deps: Deps) -> StdResult { - let cfg = CONFIG.load(deps.storage)?; - Ok(ConfigResponse { - owner: cfg.owner.map(|o| o.to_string()), - cw20_token_address: cfg.cw20_token_address.to_string(), - }) -} - -pub fn query_merkle_root(deps: Deps, stage: u8) -> StdResult { - let merkle_root = MERKLE_ROOT.load(deps.storage, stage)?; - let resp = MerkleRootResponse { stage, merkle_root }; - - Ok(resp) -} - -pub fn query_latest_stage(deps: Deps) -> StdResult { - let latest_stage = LATEST_STAGE.load(deps.storage)?; - let resp = LatestStageResponse { latest_stage }; - - Ok(resp) -} - -pub fn query_is_claimed(deps: Deps, stage: u8, address: String) -> StdResult { - let key: (&Addr, u8) = (&deps.api.addr_validate(&address)?, stage); - let is_claimed = CLAIM.may_load(deps.storage, key)?.unwrap_or(false); - let resp = IsClaimedResponse { is_claimed }; - - Ok(resp) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { - let version = get_contract_version(deps.storage)?; - if version.contract != CONTRACT_NAME { - return Err(ContractError::CannotMigrate { - previous_contract: version.contract, - }); - } - Ok(Response::default()) -} - -#[cfg(test)] -mod tests { - use super::*; - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{from_binary, from_slice, CosmosMsg, SubMsg}; - use serde::Deserialize; - - #[test] - fn proper_instantiation() { - let mut deps = mock_dependencies(); - - let msg = InstantiateMsg { - owner: Some("owner0000".to_string()), - cw20_token_address: "anchor0000".to_string(), - }; - - let env = mock_env(); - let info = mock_info("addr0000", &[]); - - // we can just call .unwrap() to assert this was a success - let _res = instantiate(deps.as_mut(), env.clone(), info, msg).unwrap(); - - // it worked, let's query the state - let res = query(deps.as_ref(), env.clone(), QueryMsg::Config {}).unwrap(); - let config: ConfigResponse = from_binary(&res).unwrap(); - assert_eq!("owner0000", config.owner.unwrap().as_str()); - assert_eq!("anchor0000", config.cw20_token_address.as_str()); - - let res = query(deps.as_ref(), env, QueryMsg::LatestStage {}).unwrap(); - let latest_stage: LatestStageResponse = from_binary(&res).unwrap(); - assert_eq!(0u8, latest_stage.latest_stage); - } - - #[test] - fn update_config() { - let mut deps = mock_dependencies(); - - let msg = InstantiateMsg { - owner: None, - cw20_token_address: "anchor0000".to_string(), - }; - - let env = mock_env(); - let info = mock_info("owner0000", &[]); - let _res = instantiate(deps.as_mut(), env, info, msg).unwrap(); - - // update owner - let env = mock_env(); - let info = mock_info("owner0000", &[]); - let msg = ExecuteMsg::UpdateConfig { - new_owner: Some("owner0001".to_string()), - }; - - let res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // it worked, let's query the state - let res = query(deps.as_ref(), env, QueryMsg::Config {}).unwrap(); - let config: ConfigResponse = from_binary(&res).unwrap(); - assert_eq!("owner0001", config.owner.unwrap().as_str()); - - // Unauthorized err - let env = mock_env(); - let info = mock_info("owner0000", &[]); - let msg = ExecuteMsg::UpdateConfig { new_owner: None }; - - let res = execute(deps.as_mut(), env, info, msg).unwrap_err(); - assert_eq!(res, ContractError::Unauthorized {}); - } - - #[test] - fn register_merkle_root() { - let mut deps = mock_dependencies(); - - let msg = InstantiateMsg { - owner: Some("owner0000".to_string()), - cw20_token_address: "anchor0000".to_string(), - }; - - let env = mock_env(); - let info = mock_info("addr0000", &[]); - let _res = instantiate(deps.as_mut(), env, info, msg).unwrap(); - - // register new merkle root - let env = mock_env(); - let info = mock_info("owner0000", &[]); - let msg = ExecuteMsg::RegisterMerkleRoot { - merkle_root: "634de21cde1044f41d90373733b0f0fb1c1c71f9652b905cdf159e73c4cf0d37" - .to_string(), - }; - - let res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); - assert_eq!( - res.attributes, - vec![ - attr("action", "register_merkle_root"), - attr("stage", "1"), - attr( - "merkle_root", - "634de21cde1044f41d90373733b0f0fb1c1c71f9652b905cdf159e73c4cf0d37" - ) - ] - ); - - let res = query(deps.as_ref(), env.clone(), QueryMsg::LatestStage {}).unwrap(); - let latest_stage: LatestStageResponse = from_binary(&res).unwrap(); - assert_eq!(1u8, latest_stage.latest_stage); - - let res = query( - deps.as_ref(), - env, - QueryMsg::MerkleRoot { - stage: latest_stage.latest_stage, - }, - ) - .unwrap(); - let merkle_root: MerkleRootResponse = from_binary(&res).unwrap(); - assert_eq!( - "634de21cde1044f41d90373733b0f0fb1c1c71f9652b905cdf159e73c4cf0d37".to_string(), - merkle_root.merkle_root - ); - } - - const TEST_DATA_1: &[u8] = include_bytes!("../testdata/airdrop_stage_1_test_data.json"); - const TEST_DATA_2: &[u8] = include_bytes!("../testdata/airdrop_stage_2_test_data.json"); - - #[derive(Deserialize, Debug)] - struct Encoded { - account: String, - amount: Uint128, - root: String, - proofs: Vec, - } - - #[test] - fn claim() { - // Run test 1 - let mut deps = mock_dependencies(); - let test_data: Encoded = from_slice(TEST_DATA_1).unwrap(); - - let msg = InstantiateMsg { - owner: Some("owner0000".to_string()), - cw20_token_address: "token0000".to_string(), - }; - - let env = mock_env(); - let info = mock_info("addr0000", &[]); - let _res = instantiate(deps.as_mut(), env, info, msg).unwrap(); - - let env = mock_env(); - let info = mock_info("owner0000", &[]); - let msg = ExecuteMsg::RegisterMerkleRoot { - merkle_root: test_data.root, - }; - let _res = execute(deps.as_mut(), env, info, msg).unwrap(); - - let msg = ExecuteMsg::Claim { - amount: test_data.amount, - stage: 1u8, - proof: test_data.proofs, - }; - - let env = mock_env(); - let info = mock_info(test_data.account.as_str(), &[]); - let res = execute(deps.as_mut(), env.clone(), info.clone(), msg.clone()).unwrap(); - let expected = SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: "token0000".to_string(), - funds: vec![], - msg: to_binary(&Cw20ExecuteMsg::Transfer { - recipient: test_data.account.clone(), - amount: test_data.amount, - }) - .unwrap(), - })); - assert_eq!(res.messages, vec![expected]); - - assert_eq!( - res.attributes, - vec![ - attr("action", "claim"), - attr("stage", "1"), - attr("address", test_data.account.clone()), - attr("amount", test_data.amount) - ] - ); - - assert!( - from_binary::( - &query( - deps.as_ref(), - env.clone(), - QueryMsg::IsClaimed { - stage: 1, - address: test_data.account - } - ) - .unwrap() - ) - .unwrap() - .is_claimed - ); - - // Second test - - let test_data: Encoded = from_slice(TEST_DATA_2).unwrap(); - // check claimed - let res = execute(deps.as_mut(), env, info, msg).unwrap_err(); - assert_eq!(res, ContractError::Claimed {}); - - // register new drop - let env = mock_env(); - let info = mock_info("owner0000", &[]); - let msg = ExecuteMsg::RegisterMerkleRoot { - merkle_root: test_data.root, - }; - let _res = execute(deps.as_mut(), env, info, msg).unwrap(); - - // Claim next airdrop - let msg = ExecuteMsg::Claim { - amount: test_data.amount, - stage: 2u8, - proof: test_data.proofs, - }; - - let env = mock_env(); - let info = mock_info(test_data.account.as_str(), &[]); - let res = execute(deps.as_mut(), env, info, msg).unwrap(); - let expected: SubMsg<_> = SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: "token0000".to_string(), - funds: vec![], - msg: to_binary(&Cw20ExecuteMsg::Transfer { - recipient: test_data.account.clone(), - amount: test_data.amount, - }) - .unwrap(), - })); - assert_eq!(res.messages, vec![expected]); - - assert_eq!( - res.attributes, - vec![ - attr("action", "claim"), - attr("stage", "2"), - attr("address", test_data.account), - attr("amount", test_data.amount) - ] - ); - } - - #[test] - fn owner_freeze() { - let mut deps = mock_dependencies(); - - let msg = InstantiateMsg { - owner: Some("owner0000".to_string()), - cw20_token_address: "token0000".to_string(), - }; - - let env = mock_env(); - let info = mock_info("addr0000", &[]); - let _res = instantiate(deps.as_mut(), env, info, msg).unwrap(); - - // can register merkle root - let env = mock_env(); - let info = mock_info("owner0000", &[]); - let msg = ExecuteMsg::RegisterMerkleRoot { - merkle_root: "5d4f48f147cb6cb742b376dce5626b2a036f69faec10cd73631c791780e150fc" - .to_string(), - }; - let _res = execute(deps.as_mut(), env, info, msg).unwrap(); - - // can update owner - let env = mock_env(); - let info = mock_info("owner0000", &[]); - let msg = ExecuteMsg::UpdateConfig { - new_owner: Some("owner0001".to_string()), - }; - - let res = execute(deps.as_mut(), env, info, msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // freeze contract - let env = mock_env(); - let info = mock_info("owner0001", &[]); - let msg = ExecuteMsg::UpdateConfig { new_owner: None }; - - let res = execute(deps.as_mut(), env, info, msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // cannot register new drop - let env = mock_env(); - let info = mock_info("owner0001", &[]); - let msg = ExecuteMsg::RegisterMerkleRoot { - merkle_root: "ebaa83c7eaf7467c378d2f37b5e46752d904d2d17acd380b24b02e3b398b3e5a" - .to_string(), - }; - let res = execute(deps.as_mut(), env, info, msg).unwrap_err(); - assert_eq!(res, ContractError::Unauthorized {}); - - // cannot update config - let env = mock_env(); - let info = mock_info("owner0001", &[]); - let msg = ExecuteMsg::RegisterMerkleRoot { - merkle_root: "ebaa83c7eaf7467c378d2f37b5e46752d904d2d17acd380b24b02e3b398b3e5a" - .to_string(), - }; - let res = execute(deps.as_mut(), env, info, msg).unwrap_err(); - assert_eq!(res, ContractError::Unauthorized {}); - } -} diff --git a/contracts/cw20-merkle-airdrop/src/error.rs b/contracts/cw20-merkle-airdrop/src/error.rs deleted file mode 100644 index 737bc68ad..000000000 --- a/contracts/cw20-merkle-airdrop/src/error.rs +++ /dev/null @@ -1,30 +0,0 @@ -use cosmwasm_std::StdError; -use hex::FromHexError; -use thiserror::Error; - -#[derive(Error, Debug, PartialEq)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("{0}")] - Hex(#[from] FromHexError), - - #[error("Unauthorized")] - Unauthorized {}, - - #[error("Invalid input")] - InvalidInput {}, - - #[error("Already claimed")] - Claimed {}, - - #[error("Wrong length")] - WrongLength {}, - - #[error("Verification failed")] - VerificationFailed {}, - - #[error("Cannot migrate from different contract type: {previous_contract}")] - CannotMigrate { previous_contract: String }, -} diff --git a/contracts/cw20-merkle-airdrop/src/lib.rs b/contracts/cw20-merkle-airdrop/src/lib.rs deleted file mode 100644 index dfedc9dc6..000000000 --- a/contracts/cw20-merkle-airdrop/src/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod contract; -mod error; -pub mod msg; -pub mod state; - -pub use crate::error::ContractError; diff --git a/contracts/cw20-merkle-airdrop/src/msg.rs b/contracts/cw20-merkle-airdrop/src/msg.rs deleted file mode 100644 index 0dea179eb..000000000 --- a/contracts/cw20-merkle-airdrop/src/msg.rs +++ /dev/null @@ -1,68 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::Uint128; - -#[derive(Serialize, Deserialize, JsonSchema)] -pub struct InstantiateMsg { - /// Owner if none set to info.sender. - pub owner: Option, - pub cw20_token_address: String, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg { - UpdateConfig { - /// NewOwner if non sent, contract gets locked. Recipients can receive airdrops - /// but owner cannot register new stages. - new_owner: Option, - }, - RegisterMerkleRoot { - /// MerkleRoot is hex-encoded merkle root. - merkle_root: String, - }, - /// Claim does not check if contract has enough funds, owner must ensure it. - Claim { - stage: u8, - amount: Uint128, - /// Proof is hex-encoded merkle proof. - proof: Vec, - }, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum QueryMsg { - Config {}, - MerkleRoot { stage: u8 }, - LatestStage {}, - IsClaimed { stage: u8, address: String }, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] -pub struct ConfigResponse { - pub owner: Option, - pub cw20_token_address: String, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct MerkleRootResponse { - pub stage: u8, - /// MerkleRoot is hex-encoded merkle root. - pub merkle_root: String, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct LatestStageResponse { - pub latest_stage: u8, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct IsClaimedResponse { - pub is_claimed: bool, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct MigrateMsg {} diff --git a/contracts/cw20-merkle-airdrop/src/state.rs b/contracts/cw20-merkle-airdrop/src/state.rs deleted file mode 100644 index c06471f87..000000000 --- a/contracts/cw20-merkle-airdrop/src/state.rs +++ /dev/null @@ -1,24 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::Addr; -use cw_storage_plus::{Item, Map}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct Config { - /// Owner If None set, contract is frozen. - pub owner: Option, - pub cw20_token_address: Addr, -} - -pub const CONFIG_KEY: &str = "config"; -pub const CONFIG: Item = Item::new(CONFIG_KEY); - -pub const LATEST_STAGE_KEY: &str = "stage"; -pub const LATEST_STAGE: Item = Item::new(LATEST_STAGE_KEY); - -pub const MERKLE_ROOT_PREFIX: &str = "merkle_root"; -pub const MERKLE_ROOT: Map = Map::new(MERKLE_ROOT_PREFIX); - -pub const CLAIM_PREFIX: &str = "claim"; -pub const CLAIM: Map<(&Addr, u8), bool> = Map::new(CLAIM_PREFIX); diff --git a/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_1_list.json b/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_1_list.json deleted file mode 100644 index 08368d7ec..000000000 --- a/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_1_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - { "address": "wasm1k9hwzxs889jpvd7env8z49gad3a3633vg350tq", "amount": "100"}, - { "address": "wasm1uy9ucvgerneekxpnfwyfnpxvlsx5dzdpf0mzjd", "amount": "1010"}, - { "address": "wasm1a4x6au55s0fusctyj2ulrxvfpmjcxa92k7ze2v", "amount": "10220"}, - { "address": "wasm1ylna88nach9sn5n7qe7u5l6lh7dmt6lp2y63xx", "amount": "10333"}, - { "address": "wasm1qzy8rg0f406uvvl54dlww6ptlh30303xq2u3xu", "amount": "10220"}, - { "address": "wasm1xn46zz5m3fhymcrcwe82m0ac8ytt588dkpaeas", "amount": "10220"} -] - diff --git a/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_1_test_data.json b/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_1_test_data.json deleted file mode 100644 index 2c8fa8c81..000000000 --- a/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_1_test_data.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "account": "wasm1k9hwzxs889jpvd7env8z49gad3a3633vg350tq", - "amount": "100", - "root": "b45c1ea28b26adb13e412933c9e055b01fdf7585304b00cd8f1cb220aa6c5e88", - "proofs": [ - "a714186eaedddde26b08b9afda38cf62fdf88d68e3aa0d5a4b55033487fe14a1", - "fb57090a813128eeb953a4210dd64ee73d2632b8158231effe2f0a18b2d3b5dd", - "c30992d264c74c58b636a31098c6c27a5fc08b3f61b7eafe2a33dcb445822343" - ] -} diff --git a/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_2_list.json b/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_2_list.json deleted file mode 100644 index 74437e38b..000000000 --- a/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_2_list.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { "address": "wasm1k9hwzxs889jpvd7env8z49gad3a3633vg350tq", "amount": "666666666"}, - { "address": "wasm1uy9ucvgerneekxpnfwyfnpxvlsx5dzdpf0mzjd", "amount": "1010"}, - { "address": "wasm1a4x6au55s0fusctyj2ulrxvfpmjcxa92k7ze2v", "amount": "999"}, - { "address": "wasm1ylna88nach9sn5n7qe7u5l6lh7dmt6lp2y63xx", "amount": "1000000000"}, - { "address": "wasm1qzy8rg0f406uvvl54dlww6ptlh30303xq2u3xu", "amount": "10220"}, - { "address": "wasm1c99d6aw39e027fmy5f2gj38g8p8c3cf0vn3qqn", "amount": "1322"}, - { "address": "wasm1uwcjkghqlz030r989clzqs8zlaujwyphx0yumy", "amount": "14"}, - { "address": "wasm1yggt0x0r3x5ujk96kfeps6v4yakgun8mdth90j", "amount": "9000000"}, - { "address": "wasm1f6s77fjplerjrh4yjj08msqdq36mam4xv9tjvs", "amount": "12333"}, - { "address": "wasm1xn46zz5m3fhymcrcwe82m0ac8ytt588dkpaeas", "amount": "1322"} -] - diff --git a/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_2_test_data.json b/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_2_test_data.json deleted file mode 100644 index f90bfccae..000000000 --- a/contracts/cw20-merkle-airdrop/testdata/airdrop_stage_2_test_data.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "account": "wasm1uwcjkghqlz030r989clzqs8zlaujwyphx0yumy", - "amount": "14", - "root": "a5587bd4d158618b83badf57b1a4206f86e33407e18797ef690c931d73b36232", - "proofs": [ - "a714186eaedddde26b08b9afda38cf62fdf88d68e3aa0d5a4b55033487fe14a1", - "1eb08e61c40d5ba334f3c32f3f136e714f0841e5d53af6b78ec94e3b29a01e74", - "fe570ffb0015447c01bffdcd266fe4ee21a23eb6b499461b9ced5a03c6a9b2f0", - "fa0224da936bcebd0f018a46ba15a5a9fc2d637f72f7c14b31aeffd8964983b5" - ] -} diff --git a/contracts/cw20-staking/.cargo/config b/contracts/cw20-staking/.cargo/config deleted file mode 100644 index 8d4bc738b..000000000 --- a/contracts/cw20-staking/.cargo/config +++ /dev/null @@ -1,6 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib" -integration-test = "test --test integration" -schema = "run --example schema" diff --git a/contracts/cw20-staking/Cargo.toml b/contracts/cw20-staking/Cargo.toml deleted file mode 100644 index 0275d354b..000000000 --- a/contracts/cw20-staking/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "cw20-staking" -version = "0.11.1" -authors = ["Ethan Frey "] -edition = "2018" -description = "Implement simple staking derivatives as a cw20 token" -license = "Apache-2.0" -repository = "https://github.com/CosmWasm/cw-plus" -homepage = "https://cosmwasm.com" -documentation = "https://docs.cosmwasm.com" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["cdylib", "rlib"] - -[features] -backtraces = ["cosmwasm-std/backtraces"] -# use library feature to disable all instantiate/execute/query exports -library = [] - -[dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw20 = { path = "../../packages/cw20", version = "0.11.1" } -cw-controllers = { path = "../../packages/controllers", version = "0.11.1" } -cw20-base = { path = "../../contracts/cw20-base", version = "0.11.1", features = ["library"] } -cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } -schemars = "0.8.1" -serde = { version = "1.0.103", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.23" } - -[dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } diff --git a/contracts/cw20-staking/NOTICE b/contracts/cw20-staking/NOTICE deleted file mode 100644 index f785e88f3..000000000 --- a/contracts/cw20-staking/NOTICE +++ /dev/null @@ -1,14 +0,0 @@ -CW20-Staking: Staking Derivatives as a CW20 token -Copyright 2020 Ethan Frey - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/contracts/cw20-staking/README.md b/contracts/cw20-staking/README.md deleted file mode 100644 index 9a23707dc..000000000 --- a/contracts/cw20-staking/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Staking Derivatives - -This is a sample contract that releases a minimal form of staking derivatives. -This is to be used for integration tests and as a foundation for other to build -more complex logic upon. - -## Functionality - -On one side, this acts as a CW20 token, holding a list of -balances for multiple addresses, and exposing queries and transfers (no -allowances and "transfer from" to focus the logic on the staking stuff). -However, it has no initial balance. Instead, it mints and burns them based on -delegations. - -For such a "bonding curve" we expose two additional message types. A "bond" -message sends native staking tokens to the contract to be bonded to a validator -and credits the user with the appropriate amount of derivative tokens. Likewise -you can burn some of your derivative tokens, and the contract will unbond the -proportional amount of stake to the user's account (after typical 21-day -unbonding period). - -To show an example of charging for such a service, we allow the contract owner -to take a small exit tax, thus maybe 98% of the tokens will be unbonded and sent -to the original account, and 2% of the tokens are not unbonded, but rather -transferred to the owners account. (The ownership can also be transferred). diff --git a/contracts/cw20-staking/examples/schema.rs b/contracts/cw20-staking/examples/schema.rs deleted file mode 100644 index f60ed253a..000000000 --- a/contracts/cw20-staking/examples/schema.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw20::{AllowanceResponse, BalanceResponse, TokenInfoResponse}; -use cw20_staking::msg::{ClaimsResponse, ExecuteMsg, InstantiateMsg, InvestmentResponse, QueryMsg}; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); - export_schema(&schema_for!(AllowanceResponse), &out_dir); - export_schema(&schema_for!(BalanceResponse), &out_dir); - export_schema(&schema_for!(ClaimsResponse), &out_dir); - export_schema(&schema_for!(InvestmentResponse), &out_dir); - export_schema(&schema_for!(TokenInfoResponse), &out_dir); -} diff --git a/contracts/cw20-staking/src/contract.rs b/contracts/cw20-staking/src/contract.rs deleted file mode 100644 index a64dc0174..000000000 --- a/contracts/cw20-staking/src/contract.rs +++ /dev/null @@ -1,965 +0,0 @@ -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; -use cosmwasm_std::{ - coin, to_binary, Addr, BankMsg, Binary, Decimal, Deps, DepsMut, DistributionMsg, Env, - MessageInfo, QuerierWrapper, Response, StakingMsg, StdError, StdResult, Uint128, WasmMsg, -}; - -use cw2::set_contract_version; -use cw20_base::allowances::{ - execute_burn_from, execute_decrease_allowance, execute_increase_allowance, execute_send_from, - execute_transfer_from, query_allowance, -}; -use cw20_base::contract::{ - execute_burn, execute_mint, execute_send, execute_transfer, query_balance, query_token_info, -}; -use cw20_base::state::{MinterData, TokenInfo, TOKEN_INFO}; - -use crate::error::ContractError; -use crate::msg::{ExecuteMsg, InstantiateMsg, InvestmentResponse, QueryMsg}; -use crate::state::{InvestmentInfo, Supply, CLAIMS, INVESTMENT, TOTAL_SUPPLY}; - -const FALLBACK_RATIO: Decimal = Decimal::one(); - -// version info for migration info -const CONTRACT_NAME: &str = "crates.io:cw20-staking"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn instantiate( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: InstantiateMsg, -) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - - // ensure the validator is registered - let vals = deps.querier.query_all_validators()?; - if !vals.iter().any(|v| v.address == msg.validator) { - return Err(ContractError::NotInValidatorSet { - validator: msg.validator, - }); - } - - // store token info using cw20-base format - let data = TokenInfo { - name: msg.name, - symbol: msg.symbol, - decimals: msg.decimals, - total_supply: Uint128::zero(), - // set self as minter, so we can properly execute mint and burn - mint: Some(MinterData { - minter: env.contract.address, - cap: None, - }), - }; - TOKEN_INFO.save(deps.storage, &data)?; - - let denom = deps.querier.query_bonded_denom()?; - let invest = InvestmentInfo { - owner: info.sender, - exit_tax: msg.exit_tax, - unbonding_period: msg.unbonding_period, - bond_denom: denom, - validator: msg.validator, - min_withdrawal: msg.min_withdrawal, - }; - INVESTMENT.save(deps.storage, &invest)?; - - // set supply to 0 - let supply = Supply::default(); - TOTAL_SUPPLY.save(deps.storage, &supply)?; - - Ok(Response::default()) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> Result { - match msg { - ExecuteMsg::Bond {} => bond(deps, env, info), - ExecuteMsg::Unbond { amount } => unbond(deps, env, info, amount), - ExecuteMsg::Claim {} => claim(deps, env, info), - ExecuteMsg::Reinvest {} => reinvest(deps, env, info), - ExecuteMsg::_BondAllTokens {} => _bond_all_tokens(deps, env, info), - - // these all come from cw20-base to implement the cw20 standard - ExecuteMsg::Transfer { recipient, amount } => { - Ok(execute_transfer(deps, env, info, recipient, amount)?) - } - ExecuteMsg::Burn { amount } => Ok(execute_burn(deps, env, info, amount)?), - ExecuteMsg::Send { - contract, - amount, - msg, - } => Ok(execute_send(deps, env, info, contract, amount, msg)?), - ExecuteMsg::IncreaseAllowance { - spender, - amount, - expires, - } => Ok(execute_increase_allowance( - deps, env, info, spender, amount, expires, - )?), - ExecuteMsg::DecreaseAllowance { - spender, - amount, - expires, - } => Ok(execute_decrease_allowance( - deps, env, info, spender, amount, expires, - )?), - ExecuteMsg::TransferFrom { - owner, - recipient, - amount, - } => Ok(execute_transfer_from( - deps, env, info, owner, recipient, amount, - )?), - ExecuteMsg::BurnFrom { owner, amount } => { - Ok(execute_burn_from(deps, env, info, owner, amount)?) - } - ExecuteMsg::SendFrom { - owner, - contract, - amount, - msg, - } => Ok(execute_send_from( - deps, env, info, owner, contract, amount, msg, - )?), - } -} - -// get_bonded returns the total amount of delegations from contract -// it ensures they are all the same denom -fn get_bonded(querier: &QuerierWrapper, contract: &Addr) -> Result { - let bonds = querier.query_all_delegations(contract)?; - if bonds.is_empty() { - return Ok(Uint128::zero()); - } - let denom = bonds[0].amount.denom.as_str(); - bonds.iter().fold(Ok(Uint128::zero()), |racc, d| { - let acc = racc?; - if d.amount.denom.as_str() != denom { - Err(ContractError::DifferentBondDenom { - denom1: denom.into(), - denom2: d.amount.denom.to_string(), - }) - } else { - Ok(acc + d.amount.amount) - } - }) -} - -fn assert_bonds(supply: &Supply, bonded: Uint128) -> Result<(), ContractError> { - if supply.bonded != bonded { - Err(ContractError::BondedMismatch { - stored: supply.bonded, - queried: bonded, - }) - } else { - Ok(()) - } -} - -pub fn bond(deps: DepsMut, env: Env, info: MessageInfo) -> Result { - // ensure we have the proper denom - let invest = INVESTMENT.load(deps.storage)?; - // payment finds the proper coin (or throws an error) - let payment = info - .funds - .iter() - .find(|x| x.denom == invest.bond_denom) - .ok_or_else(|| ContractError::EmptyBalance { - denom: invest.bond_denom.clone(), - })?; - - // bonded is the total number of tokens we have delegated from this address - let bonded = get_bonded(&deps.querier, &env.contract.address)?; - - // calculate to_mint and update total supply - let mut supply = TOTAL_SUPPLY.load(deps.storage)?; - // TODO: this is just a safety assertion - do we keep it, or remove caching? - // in the end supply is just there to cache the (expected) results of get_bonded() so we don't - // have expensive queries everywhere - assert_bonds(&supply, bonded)?; - let to_mint = if supply.issued.is_zero() || bonded.is_zero() { - FALLBACK_RATIO * payment.amount - } else { - payment.amount.multiply_ratio(supply.issued, bonded) - }; - supply.bonded = bonded + payment.amount; - supply.issued += to_mint; - TOTAL_SUPPLY.save(deps.storage, &supply)?; - - // call into cw20-base to mint the token, call as self as no one else is allowed - let sub_info = MessageInfo { - sender: env.contract.address.clone(), - funds: vec![], - }; - execute_mint(deps, env, sub_info, info.sender.to_string(), to_mint)?; - - // bond them to the validator - let res = Response::new() - .add_message(StakingMsg::Delegate { - validator: invest.validator, - amount: payment.clone(), - }) - .add_attribute("action", "bond") - .add_attribute("from", info.sender) - .add_attribute("bonded", payment.amount) - .add_attribute("minted", to_mint); - Ok(res) -} - -pub fn unbond( - mut deps: DepsMut, - env: Env, - info: MessageInfo, - amount: Uint128, -) -> Result { - let invest = INVESTMENT.load(deps.storage)?; - // ensure it is big enough to care - if amount < invest.min_withdrawal { - return Err(ContractError::UnbondTooSmall { - min_bonded: invest.min_withdrawal, - denom: invest.bond_denom, - }); - } - // calculate tax and remainer to unbond - let tax = amount * invest.exit_tax; - - // burn from the original caller - execute_burn(deps.branch(), env.clone(), info.clone(), amount)?; - if tax > Uint128::zero() { - let sub_info = MessageInfo { - sender: env.contract.address.clone(), - funds: vec![], - }; - // call into cw20-base to mint tokens to owner, call as self as no one else is allowed - execute_mint( - deps.branch(), - env.clone(), - sub_info, - invest.owner.to_string(), - tax, - )?; - } - - // re-calculate bonded to ensure we have real values - // bonded is the total number of tokens we have delegated from this address - let bonded = get_bonded(&deps.querier, &env.contract.address)?; - - // calculate how many native tokens this is worth and update supply - let remainder = amount.checked_sub(tax).map_err(StdError::overflow)?; - let mut supply = TOTAL_SUPPLY.load(deps.storage)?; - // TODO: this is just a safety assertion - do we keep it, or remove caching? - // in the end supply is just there to cache the (expected) results of get_bonded() so we don't - // have expensive queries everywhere - assert_bonds(&supply, bonded)?; - let unbond = remainder.multiply_ratio(bonded, supply.issued); - supply.bonded = bonded.checked_sub(unbond).map_err(StdError::overflow)?; - supply.issued = supply - .issued - .checked_sub(remainder) - .map_err(StdError::overflow)?; - supply.claims += unbond; - TOTAL_SUPPLY.save(deps.storage, &supply)?; - - CLAIMS.create_claim( - deps.storage, - &info.sender, - unbond, - invest.unbonding_period.after(&env.block), - )?; - - // unbond them - let res = Response::new() - .add_message(StakingMsg::Undelegate { - validator: invest.validator, - amount: coin(unbond.u128(), &invest.bond_denom), - }) - .add_attribute("action", "unbond") - .add_attribute("to", info.sender) - .add_attribute("unbonded", unbond) - .add_attribute("burnt", amount); - Ok(res) -} - -pub fn claim(deps: DepsMut, env: Env, info: MessageInfo) -> Result { - // find how many tokens the contract has - let invest = INVESTMENT.load(deps.storage)?; - let mut balance = deps - .querier - .query_balance(&env.contract.address, &invest.bond_denom)?; - if balance.amount < invest.min_withdrawal { - return Err(ContractError::BalanceTooSmall {}); - } - - // check how much to send - min(balance, claims[sender]), and reduce the claim - // Ensure we have enough balance to cover this and only send some claims if that is all we can cover - let to_send = - CLAIMS.claim_tokens(deps.storage, &info.sender, &env.block, Some(balance.amount))?; - if to_send == Uint128::zero() { - return Err(ContractError::NothingToClaim {}); - } - - // update total supply (lower claim) - TOTAL_SUPPLY.update(deps.storage, |mut supply| -> StdResult<_> { - supply.claims = supply.claims.checked_sub(to_send)?; - Ok(supply) - })?; - - // transfer tokens to the sender - balance.amount = to_send; - let res = Response::new() - .add_message(BankMsg::Send { - to_address: info.sender.to_string(), - amount: vec![balance], - }) - .add_attribute("action", "claim") - .add_attribute("from", info.sender) - .add_attribute("amount", to_send); - Ok(res) -} - -/// reinvest will withdraw all pending rewards, -/// then issue a callback to itself via _bond_all_tokens -/// to reinvest the new earnings (and anything else that accumulated) -pub fn reinvest(deps: DepsMut, env: Env, _info: MessageInfo) -> Result { - let contract_addr = env.contract.address; - let invest = INVESTMENT.load(deps.storage)?; - let msg = to_binary(&ExecuteMsg::_BondAllTokens {})?; - - // and bond them to the validator - let res = Response::new() - .add_message(DistributionMsg::WithdrawDelegatorReward { - validator: invest.validator, - }) - .add_message(WasmMsg::Execute { - contract_addr: contract_addr.to_string(), - msg, - funds: vec![], - }); - Ok(res) -} - -pub fn _bond_all_tokens( - deps: DepsMut, - env: Env, - info: MessageInfo, -) -> Result { - // this is just meant as a call-back to ourself - if info.sender != env.contract.address { - return Err(ContractError::Unauthorized {}); - } - - // find how many tokens we have to bond - let invest = INVESTMENT.load(deps.storage)?; - let mut balance = deps - .querier - .query_balance(&env.contract.address, &invest.bond_denom)?; - - // we deduct pending claims from our account balance before reinvesting. - // if there is not enough funds, we just return a no-op - match TOTAL_SUPPLY.update(deps.storage, |mut supply| -> StdResult<_> { - balance.amount = balance.amount.checked_sub(supply.claims)?; - // this just triggers the "no op" case if we don't have min_withdrawal left to reinvest - balance.amount.checked_sub(invest.min_withdrawal)?; - supply.bonded += balance.amount; - Ok(supply) - }) { - Ok(_) => {} - // if it is below the minimum, we do a no-op (do not revert other state from withdrawal) - Err(StdError::Overflow { .. }) => return Ok(Response::default()), - Err(e) => return Err(ContractError::Std(e)), - } - - // and bond them to the validator - let res = Response::new() - .add_message(StakingMsg::Delegate { - validator: invest.validator, - amount: balance.clone(), - }) - .add_attribute("action", "reinvest") - .add_attribute("bonded", balance.amount); - Ok(res) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - // custom queries - QueryMsg::Claims { address } => { - to_binary(&CLAIMS.query_claims(deps, &deps.api.addr_validate(&address)?)?) - } - QueryMsg::Investment {} => to_binary(&query_investment(deps)?), - // inherited from cw20-base - QueryMsg::TokenInfo {} => to_binary(&query_token_info(deps)?), - QueryMsg::Balance { address } => to_binary(&query_balance(deps, address)?), - QueryMsg::Allowance { owner, spender } => { - to_binary(&query_allowance(deps, owner, spender)?) - } - } -} - -pub fn query_investment(deps: Deps) -> StdResult { - let invest = INVESTMENT.load(deps.storage)?; - let supply = TOTAL_SUPPLY.load(deps.storage)?; - - let res = InvestmentResponse { - owner: invest.owner.to_string(), - exit_tax: invest.exit_tax, - validator: invest.validator, - min_withdrawal: invest.min_withdrawal, - token_supply: supply.issued, - staked_tokens: coin(supply.bonded.u128(), &invest.bond_denom), - nominal_value: if supply.issued.is_zero() { - FALLBACK_RATIO - } else { - Decimal::from_ratio(supply.bonded, supply.issued) - }, - }; - Ok(res) -} - -#[cfg(test)] -mod tests { - use super::*; - use std::str::FromStr; - - use cosmwasm_std::testing::{ - mock_dependencies, mock_env, mock_info, MockQuerier, MOCK_CONTRACT_ADDR, - }; - use cosmwasm_std::{ - coins, Coin, CosmosMsg, Decimal, FullDelegation, OverflowError, OverflowOperation, - Validator, - }; - use cw_controllers::Claim; - use cw_utils::{Duration, DAY, HOUR, WEEK}; - - fn sample_validator(addr: &str) -> Validator { - Validator { - address: addr.into(), - commission: Decimal::percent(3), - max_commission: Decimal::percent(10), - max_change_rate: Decimal::percent(1), - } - } - - fn sample_delegation(addr: &str, amount: Coin) -> FullDelegation { - let can_redelegate = amount.clone(); - let accumulated_rewards = coins(0, &amount.denom); - FullDelegation { - validator: addr.into(), - delegator: Addr::unchecked(MOCK_CONTRACT_ADDR), - amount, - can_redelegate, - accumulated_rewards, - } - } - - fn set_validator(querier: &mut MockQuerier) { - querier.update_staking("ustake", &[sample_validator(DEFAULT_VALIDATOR)], &[]); - } - - fn set_delegation(querier: &mut MockQuerier, amount: u128, denom: &str) { - querier.update_staking( - "ustake", - &[sample_validator(DEFAULT_VALIDATOR)], - &[sample_delegation(DEFAULT_VALIDATOR, coin(amount, denom))], - ); - } - - // just a test helper, forgive the panic - fn later(env: &Env, delta: Duration) -> Env { - let time_delta = match delta { - Duration::Time(t) => t, - _ => panic!("Must provide duration in time"), - }; - let mut res = env.clone(); - res.block.time = res.block.time.plus_seconds(time_delta); - res - } - - const DEFAULT_VALIDATOR: &str = "default-validator"; - - fn default_instantiate(tax_percent: u64, min_withdrawal: u128) -> InstantiateMsg { - InstantiateMsg { - name: "Cool Derivative".to_string(), - symbol: "DRV".to_string(), - decimals: 9, - validator: String::from(DEFAULT_VALIDATOR), - unbonding_period: DAY * 3, - exit_tax: Decimal::percent(tax_percent), - min_withdrawal: Uint128::new(min_withdrawal), - } - } - - fn get_balance>(deps: Deps, addr: U) -> Uint128 { - query_balance(deps, addr.into()).unwrap().balance - } - - fn get_claims(deps: Deps, addr: &str) -> Vec { - CLAIMS - .query_claims(deps, &Addr::unchecked(addr)) - .unwrap() - .claims - } - - #[test] - fn instantiation_with_missing_validator() { - let mut deps = mock_dependencies(); - deps.querier - .update_staking("ustake", &[sample_validator("john")], &[]); - - let creator = String::from("creator"); - let msg = InstantiateMsg { - name: "Cool Derivative".to_string(), - symbol: "DRV".to_string(), - decimals: 9, - validator: String::from("my-validator"), - unbonding_period: WEEK, - exit_tax: Decimal::percent(2), - min_withdrawal: Uint128::new(50), - }; - let info = mock_info(&creator, &[]); - - // make sure we can instantiate with this - let err = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap_err(); - assert_eq!( - err, - ContractError::NotInValidatorSet { - validator: "my-validator".into() - } - ); - } - - #[test] - fn proper_instantiation() { - let mut deps = mock_dependencies(); - deps.querier.update_staking( - "ustake", - &[ - sample_validator("john"), - sample_validator("mary"), - sample_validator("my-validator"), - ], - &[], - ); - - let creator = String::from("creator"); - let msg = InstantiateMsg { - name: "Cool Derivative".to_string(), - symbol: "DRV".to_string(), - decimals: 0, - validator: String::from("my-validator"), - unbonding_period: HOUR * 12, - exit_tax: Decimal::percent(2), - min_withdrawal: Uint128::new(50), - }; - let info = mock_info(&creator, &[]); - - // make sure we can instantiate with this - let res = instantiate(deps.as_mut(), mock_env(), info, msg.clone()).unwrap(); - assert_eq!(0, res.messages.len()); - - // token info is proper - let token = query_token_info(deps.as_ref()).unwrap(); - assert_eq!(&token.name, &msg.name); - assert_eq!(&token.symbol, &msg.symbol); - assert_eq!(token.decimals, msg.decimals); - assert_eq!(token.total_supply, Uint128::zero()); - - // no balance - assert_eq!(get_balance(deps.as_ref(), &creator), Uint128::zero()); - // no claims - assert_eq!(get_claims(deps.as_ref(), &creator), vec![]); - - // investment info correct - let invest = query_investment(deps.as_ref()).unwrap(); - assert_eq!(&invest.owner, &creator); - assert_eq!(&invest.validator, &msg.validator); - assert_eq!(invest.exit_tax, msg.exit_tax); - assert_eq!(invest.min_withdrawal, msg.min_withdrawal); - - assert_eq!(invest.token_supply, Uint128::zero()); - assert_eq!(invest.staked_tokens, coin(0, "ustake")); - assert_eq!(invest.nominal_value, Decimal::one()); - } - - #[test] - fn bonding_issues_tokens() { - let mut deps = mock_dependencies(); - set_validator(&mut deps.querier); - - let creator = String::from("creator"); - let instantiate_msg = default_instantiate(2, 50); - let info = mock_info(&creator, &[]); - - // make sure we can instantiate with this - let res = instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // let's bond some tokens now - let bob = String::from("bob"); - let bond_msg = ExecuteMsg::Bond {}; - let info = mock_info(&bob, &[coin(10, "random"), coin(1000, "ustake")]); - - // try to bond and make sure we trigger delegation - let res = execute(deps.as_mut(), mock_env(), info, bond_msg).unwrap(); - assert_eq!(1, res.messages.len()); - let delegate = &res.messages[0]; - match &delegate.msg { - CosmosMsg::Staking(StakingMsg::Delegate { validator, amount }) => { - assert_eq!(validator.as_str(), DEFAULT_VALIDATOR); - assert_eq!(amount, &coin(1000, "ustake")); - } - _ => panic!("Unexpected message: {:?}", delegate), - } - - // bob got 1000 DRV for 1000 stake at a 1.0 ratio - assert_eq!(get_balance(deps.as_ref(), &bob), Uint128::new(1000)); - - // investment info correct (updated supply) - let invest = query_investment(deps.as_ref()).unwrap(); - assert_eq!(invest.token_supply, Uint128::new(1000)); - assert_eq!(invest.staked_tokens, coin(1000, "ustake")); - assert_eq!(invest.nominal_value, Decimal::one()); - - // token info also properly updated - let token = query_token_info(deps.as_ref()).unwrap(); - assert_eq!(token.total_supply, Uint128::new(1000)); - } - - #[test] - fn rebonding_changes_pricing() { - let mut deps = mock_dependencies(); - set_validator(&mut deps.querier); - - let creator = String::from("creator"); - let instantiate_msg = default_instantiate(2, 50); - let info = mock_info(&creator, &[]); - - // make sure we can instantiate with this - let res = instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // let's bond some tokens now - let bob = String::from("bob"); - let bond_msg = ExecuteMsg::Bond {}; - let info = mock_info(&bob, &[coin(10, "random"), coin(1000, "ustake")]); - let res = execute(deps.as_mut(), mock_env(), info, bond_msg).unwrap(); - assert_eq!(1, res.messages.len()); - - // update the querier with new bond - set_delegation(&mut deps.querier, 1000, "ustake"); - - // fake a reinvestment (this must be sent by the contract itself) - let rebond_msg = ExecuteMsg::_BondAllTokens {}; - let info = mock_info(MOCK_CONTRACT_ADDR, &[]); - deps.querier - .update_balance(MOCK_CONTRACT_ADDR, coins(500, "ustake")); - let _ = execute(deps.as_mut(), mock_env(), info, rebond_msg).unwrap(); - - // update the querier with new bond - set_delegation(&mut deps.querier, 1500, "ustake"); - - // we should now see 1000 issues and 1500 bonded (and a price of 1.5) - let invest = query_investment(deps.as_ref()).unwrap(); - assert_eq!(invest.token_supply, Uint128::new(1000)); - assert_eq!(invest.staked_tokens, coin(1500, "ustake")); - let ratio = Decimal::from_str("1.5").unwrap(); - assert_eq!(invest.nominal_value, ratio); - - // we bond some other tokens and get a different issuance price (maintaining the ratio) - let alice = String::from("alice"); - let bond_msg = ExecuteMsg::Bond {}; - let info = mock_info(&alice, &[coin(3000, "ustake")]); - let res = execute(deps.as_mut(), mock_env(), info, bond_msg).unwrap(); - assert_eq!(1, res.messages.len()); - - // update the querier with new bond - set_delegation(&mut deps.querier, 3000, "ustake"); - - // alice should have gotten 2000 DRV for the 3000 stake, keeping the ratio at 1.5 - assert_eq!(get_balance(deps.as_ref(), &alice), Uint128::new(2000)); - - let invest = query_investment(deps.as_ref()).unwrap(); - assert_eq!(invest.token_supply, Uint128::new(3000)); - assert_eq!(invest.staked_tokens, coin(4500, "ustake")); - assert_eq!(invest.nominal_value, ratio); - } - - #[test] - fn bonding_fails_with_wrong_denom() { - let mut deps = mock_dependencies(); - set_validator(&mut deps.querier); - - let creator = String::from("creator"); - let instantiate_msg = default_instantiate(2, 50); - let info = mock_info(&creator, &[]); - - // make sure we can instantiate with this - let res = instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // let's bond some tokens now - let bob = String::from("bob"); - let bond_msg = ExecuteMsg::Bond {}; - let info = mock_info(&bob, &[coin(500, "photon")]); - - // try to bond and make sure we trigger delegation - let err = execute(deps.as_mut(), mock_env(), info, bond_msg).unwrap_err(); - assert_eq!( - err, - ContractError::EmptyBalance { - denom: "ustake".to_string() - } - ); - } - - #[test] - fn unbonding_maintains_price_ratio() { - let mut deps = mock_dependencies(); - set_validator(&mut deps.querier); - - let creator = String::from("creator"); - let instantiate_msg = default_instantiate(10, 50); - let info = mock_info(&creator, &[]); - - // make sure we can instantiate with this - let res = instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // let's bond some tokens now - let bob = String::from("bob"); - let bond_msg = ExecuteMsg::Bond {}; - let info = mock_info(&bob, &[coin(10, "random"), coin(1000, "ustake")]); - let res = execute(deps.as_mut(), mock_env(), info, bond_msg).unwrap(); - assert_eq!(1, res.messages.len()); - - // update the querier with new bond - set_delegation(&mut deps.querier, 1000, "ustake"); - - // fake a reinvestment (this must be sent by the contract itself) - // after this, we see 1000 issues and 1500 bonded (and a price of 1.5) - let rebond_msg = ExecuteMsg::_BondAllTokens {}; - let info = mock_info(MOCK_CONTRACT_ADDR, &[]); - deps.querier - .update_balance(MOCK_CONTRACT_ADDR, coins(500, "ustake")); - let _ = execute(deps.as_mut(), mock_env(), info, rebond_msg).unwrap(); - - // update the querier with new bond, lower balance - set_delegation(&mut deps.querier, 1500, "ustake"); - deps.querier.update_balance(MOCK_CONTRACT_ADDR, vec![]); - - // creator now tries to unbond these tokens - this must fail - let unbond_msg = ExecuteMsg::Unbond { - amount: Uint128::new(600), - }; - let info = mock_info(&creator, &[]); - let err = execute(deps.as_mut(), mock_env(), info, unbond_msg).unwrap_err(); - assert_eq!( - err, - ContractError::Std(StdError::overflow(OverflowError::new( - OverflowOperation::Sub, - 0, - 600 - ))) - ); - - // bob unbonds 600 tokens at 10% tax... - // 60 are taken and send to the owner - // 540 are unbonded in exchange for 540 * 1.5 = 810 native tokens - let unbond_msg = ExecuteMsg::Unbond { - amount: Uint128::new(600), - }; - let owner_cut = Uint128::new(60); - let bobs_claim = Uint128::new(810); - let bobs_balance = Uint128::new(400); - let env = mock_env(); - let info = mock_info(&bob, &[]); - let res = execute(deps.as_mut(), env.clone(), info, unbond_msg).unwrap(); - assert_eq!(1, res.messages.len()); - let delegate = &res.messages[0]; - match &delegate.msg { - CosmosMsg::Staking(StakingMsg::Undelegate { validator, amount }) => { - assert_eq!(validator.as_str(), DEFAULT_VALIDATOR); - assert_eq!(amount, &coin(bobs_claim.u128(), "ustake")); - } - _ => panic!("Unexpected message: {:?}", delegate), - } - - // update the querier with new bond, lower balance - set_delegation(&mut deps.querier, 690, "ustake"); - - // check balances - assert_eq!(get_balance(deps.as_ref(), &bob), bobs_balance); - assert_eq!(get_balance(deps.as_ref(), &creator), owner_cut); - // proper claims - let expected_claims = vec![Claim { - amount: bobs_claim, - release_at: (DAY * 3).after(&env.block), - }]; - assert_eq!(expected_claims, get_claims(deps.as_ref(), &bob)); - - // supplies updated, ratio the same (1.5) - let ratio = Decimal::from_str("1.5").unwrap(); - - let invest = query_investment(deps.as_ref()).unwrap(); - assert_eq!(invest.token_supply, bobs_balance + owner_cut); - assert_eq!(invest.staked_tokens, coin(690, "ustake")); // 1500 - 810 - assert_eq!(invest.nominal_value, ratio); - } - - #[test] - fn claims_paid_out_properly() { - let mut deps = mock_dependencies(); - set_validator(&mut deps.querier); - - // create contract - let creator = String::from("creator"); - let instantiate_msg = default_instantiate(10, 50); - let info = mock_info(&creator, &[]); - instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); - - // bond some tokens - let bob = String::from("bob"); - let info = mock_info(&bob, &coins(1000, "ustake")); - execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Bond {}).unwrap(); - set_delegation(&mut deps.querier, 1000, "ustake"); - - // unbond part of them - let unbond_msg = ExecuteMsg::Unbond { - amount: Uint128::new(600), - }; - let env = mock_env(); - let info = mock_info(&bob, &[]); - execute(deps.as_mut(), env.clone(), info.clone(), unbond_msg).unwrap(); - set_delegation(&mut deps.querier, 460, "ustake"); - - // ensure claims are proper - let bobs_claim = Uint128::new(540); - let original_claims = vec![Claim { - amount: bobs_claim, - release_at: (DAY * 3).after(&env.block), - }]; - assert_eq!(original_claims, get_claims(deps.as_ref(), &bob)); - - // bob cannot exercise claims without enough balance - let claim_ready = later(&env, (DAY * 3 + HOUR).unwrap()); - let too_soon = later(&env, DAY); - let fail = execute( - deps.as_mut(), - claim_ready.clone(), - info.clone(), - ExecuteMsg::Claim {}, - ); - assert!(fail.is_err(), "{:?}", fail); - - // provide the balance, but claim not yet mature - also prohibited - deps.querier - .update_balance(MOCK_CONTRACT_ADDR, coins(540, "ustake")); - let fail = execute(deps.as_mut(), too_soon, info.clone(), ExecuteMsg::Claim {}); - assert!(fail.is_err(), "{:?}", fail); - - // this should work with cash and claims ready - let res = execute(deps.as_mut(), claim_ready, info, ExecuteMsg::Claim {}).unwrap(); - assert_eq!(1, res.messages.len()); - let payout = &res.messages[0]; - match &payout.msg { - CosmosMsg::Bank(BankMsg::Send { to_address, amount }) => { - assert_eq!(amount, &coins(540, "ustake")); - assert_eq!(to_address, &bob); - } - _ => panic!("Unexpected message: {:?}", payout), - } - - // claims have been removed - assert_eq!(get_claims(deps.as_ref(), &bob), vec![]); - } - - #[test] - fn cw20_imports_work() { - let mut deps = mock_dependencies(); - set_validator(&mut deps.querier); - - // set the actors... bob stakes, sends coins to carl, and gives allowance to alice - let bob = String::from("bob"); - let alice = String::from("alice"); - let carl = String::from("carl"); - - // create the contract - let creator = String::from("creator"); - let instantiate_msg = default_instantiate(2, 50); - let info = mock_info(&creator, &[]); - instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); - - // bond some tokens to create a balance - let info = mock_info(&bob, &[coin(10, "random"), coin(1000, "ustake")]); - execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Bond {}).unwrap(); - - // bob got 1000 DRV for 1000 stake at a 1.0 ratio - assert_eq!(get_balance(deps.as_ref(), &bob), Uint128::new(1000)); - - // send coins to carl - let bob_info = mock_info(&bob, &[]); - let transfer = ExecuteMsg::Transfer { - recipient: carl.clone(), - amount: Uint128::new(200), - }; - execute(deps.as_mut(), mock_env(), bob_info.clone(), transfer).unwrap(); - assert_eq!(get_balance(deps.as_ref(), &bob), Uint128::new(800)); - assert_eq!(get_balance(deps.as_ref(), &carl), Uint128::new(200)); - - // allow alice - let allow = ExecuteMsg::IncreaseAllowance { - spender: alice.clone(), - amount: Uint128::new(350), - expires: None, - }; - execute(deps.as_mut(), mock_env(), bob_info.clone(), allow).unwrap(); - assert_eq!(get_balance(deps.as_ref(), &bob), Uint128::new(800)); - assert_eq!(get_balance(deps.as_ref(), &alice), Uint128::zero()); - assert_eq!( - query_allowance(deps.as_ref(), bob.clone(), alice.clone()) - .unwrap() - .allowance, - Uint128::new(350) - ); - - // alice takes some for herself - let self_pay = ExecuteMsg::TransferFrom { - owner: bob.clone(), - recipient: alice.clone(), - amount: Uint128::new(250), - }; - let alice_info = mock_info(&alice, &[]); - execute(deps.as_mut(), mock_env(), alice_info, self_pay).unwrap(); - assert_eq!(get_balance(deps.as_ref(), &bob), Uint128::new(550)); - assert_eq!(get_balance(deps.as_ref(), &alice), Uint128::new(250)); - assert_eq!( - query_allowance(deps.as_ref(), bob.clone(), alice) - .unwrap() - .allowance, - Uint128::new(100) - ); - - // burn some, but not too much - let burn_too_much = ExecuteMsg::Burn { - amount: Uint128::new(1000), - }; - let failed = execute(deps.as_mut(), mock_env(), bob_info.clone(), burn_too_much); - assert!(failed.is_err()); - assert_eq!(get_balance(deps.as_ref(), &bob), Uint128::new(550)); - let burn = ExecuteMsg::Burn { - amount: Uint128::new(130), - }; - execute(deps.as_mut(), mock_env(), bob_info, burn).unwrap(); - assert_eq!(get_balance(deps.as_ref(), &bob), Uint128::new(420)); - } -} diff --git a/contracts/cw20-staking/src/error.rs b/contracts/cw20-staking/src/error.rs deleted file mode 100644 index 521945d39..000000000 --- a/contracts/cw20-staking/src/error.rs +++ /dev/null @@ -1,69 +0,0 @@ -use cosmwasm_std::{StdError, Uint128}; -use thiserror::Error; - -#[derive(Error, Debug, PartialEq)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("Unauthorized")] - Unauthorized {}, - - #[error("Validator '{validator}' not in current validator set")] - NotInValidatorSet { validator: String }, - - #[error("Different denominations in bonds: '{denom1}' vs. '{denom2}'")] - DifferentBondDenom { denom1: String, denom2: String }, - - #[error("Stored bonded {stored}, but query bonded {queried}")] - BondedMismatch { stored: Uint128, queried: Uint128 }, - - #[error("No {denom} tokens sent")] - EmptyBalance { denom: String }, - - #[error("Must unbond at least {min_bonded} {denom}")] - UnbondTooSmall { min_bonded: Uint128, denom: String }, - - #[error("Insufficient balance in contract to process claim")] - BalanceTooSmall {}, - - #[error("No claims that can be released currently")] - NothingToClaim {}, - - #[error("Cannot set to own account")] - CannotSetOwnAccount {}, - - #[error("Invalid zero amount")] - InvalidZeroAmount {}, - - #[error("Allowance is expired")] - Expired {}, - - #[error("No allowance for this account")] - NoAllowance {}, - - #[error("Minting cannot exceed the cap")] - CannotExceedCap {}, -} - -impl From for ContractError { - fn from(err: cw20_base::ContractError) -> Self { - match err { - cw20_base::ContractError::Std(error) => ContractError::Std(error), - cw20_base::ContractError::Unauthorized {} => ContractError::Unauthorized {}, - cw20_base::ContractError::CannotSetOwnAccount {} => { - ContractError::CannotSetOwnAccount {} - } - cw20_base::ContractError::InvalidZeroAmount {} => ContractError::InvalidZeroAmount {}, - cw20_base::ContractError::Expired {} => ContractError::Expired {}, - cw20_base::ContractError::NoAllowance {} => ContractError::NoAllowance {}, - cw20_base::ContractError::CannotExceedCap {} => ContractError::CannotExceedCap {}, - // This should never happen, as this contract doesn't use logo - cw20_base::ContractError::LogoTooBig {} - | cw20_base::ContractError::InvalidPngHeader {} - | cw20_base::ContractError::InvalidXmlPreamble {} => { - ContractError::Std(StdError::generic_err(err.to_string())) - } - } - } -} diff --git a/contracts/cw20-staking/src/lib.rs b/contracts/cw20-staking/src/lib.rs deleted file mode 100644 index dfedc9dc6..000000000 --- a/contracts/cw20-staking/src/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod contract; -mod error; -pub mod msg; -pub mod state; - -pub use crate::error::ContractError; diff --git a/contracts/cw20-staking/src/msg.rs b/contracts/cw20-staking/src/msg.rs deleted file mode 100644 index b9c22f11b..000000000 --- a/contracts/cw20-staking/src/msg.rs +++ /dev/null @@ -1,130 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::{Binary, Coin, Decimal, Uint128}; -use cw20::Expiration; -pub use cw_controllers::ClaimsResponse; -use cw_utils::Duration; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct InstantiateMsg { - /// name of the derivative token - pub name: String, - /// symbol / ticker of the derivative token - pub symbol: String, - /// decimal places of the derivative token (for UI) - pub decimals: u8, - - /// This is the validator that all tokens will be bonded to - pub validator: String, - /// This is the unbonding period of the native staking module - /// We need this to only allow claims to be redeemed after the money has arrived - pub unbonding_period: Duration, - - /// this is how much the owner takes as a cut when someone unbonds - pub exit_tax: Decimal, - /// This is the minimum amount we will pull out to reinvest, as well as a minimum - /// that can be unbonded (to avoid needless staking tx) - pub min_withdrawal: Uint128, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg { - /// Bond will bond all staking tokens sent with the message and release derivative tokens - Bond {}, - /// Unbond will "burn" the given amount of derivative tokens and send the unbonded - /// staking tokens to the message sender (after exit tax is deducted) - Unbond { amount: Uint128 }, - /// Claim is used to claim your native tokens that you previously "unbonded" - /// after the chain-defined waiting period (eg. 3 weeks) - Claim {}, - /// Reinvest will check for all accumulated rewards, withdraw them, and - /// re-bond them to the same validator. Anyone can call this, which updates - /// the value of the token (how much under custody). - Reinvest {}, - /// _BondAllTokens can only be called by the contract itself, after all rewards have been - /// withdrawn. This is an example of using "callbacks" in message flows. - /// This can only be invoked by the contract itself as a return from Reinvest - _BondAllTokens {}, - - /// Implements CW20. Transfer is a base message to move tokens to another account without triggering actions - Transfer { recipient: String, amount: Uint128 }, - /// Implements CW20. Burn is a base message to destroy tokens forever - Burn { amount: Uint128 }, - /// Implements CW20. Send is a base message to transfer tokens to a contract and trigger an action - /// on the receiving contract. - Send { - contract: String, - amount: Uint128, - msg: Binary, - }, - /// Implements CW20 "approval" extension. Allows spender to access an additional amount tokens - /// from the owner's (env.sender) account. If expires is Some(), overwrites current allowance - /// expiration with this one. - IncreaseAllowance { - spender: String, - amount: Uint128, - expires: Option, - }, - /// Implements CW20 "approval" extension. Lowers the spender's access of tokens - /// from the owner's (env.sender) account by amount. If expires is Some(), overwrites current - /// allowance expiration with this one. - DecreaseAllowance { - spender: String, - amount: Uint128, - expires: Option, - }, - /// Implements CW20 "approval" extension. Transfers amount tokens from owner -> recipient - /// if `env.sender` has sufficient pre-approval. - TransferFrom { - owner: String, - recipient: String, - amount: Uint128, - }, - /// Implements CW20 "approval" extension. Sends amount tokens from owner -> contract - /// if `env.sender` has sufficient pre-approval. - SendFrom { - owner: String, - contract: String, - amount: Uint128, - msg: Binary, - }, - /// Implements CW20 "approval" extension. Destroys tokens forever - BurnFrom { owner: String, amount: Uint128 }, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum QueryMsg { - /// Claims shows the number of tokens this address can access when they are done unbonding - Claims { address: String }, - /// Investment shows metadata on the staking info of the contract - Investment {}, - - /// Implements CW20. Returns the current balance of the given address, 0 if unset. - Balance { address: String }, - /// Implements CW20. Returns metadata on the contract - name, decimals, supply, etc. - TokenInfo {}, - /// Implements CW20 "allowance" extension. - /// Returns how much spender can use from owner account, 0 if unset. - Allowance { owner: String, spender: String }, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct InvestmentResponse { - pub token_supply: Uint128, - pub staked_tokens: Coin, - // ratio of staked_tokens / token_supply (or how many native tokens that one derivative token is nominally worth) - pub nominal_value: Decimal, - - /// owner created the contract and takes a cut - pub owner: String, - /// this is how much the owner takes as a cut when someone unbonds - pub exit_tax: Decimal, - /// All tokens are bonded to this validator - pub validator: String, - /// This is the minimum amount we will pull out to reinvest, as well as a minimum - /// that can be unbonded (to avoid needless staking tx) - pub min_withdrawal: Uint128, -} diff --git a/contracts/cw20-staking/src/state.rs b/contracts/cw20-staking/src/state.rs deleted file mode 100644 index e179665fd..000000000 --- a/contracts/cw20-staking/src/state.rs +++ /dev/null @@ -1,43 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::{Addr, Decimal, Uint128}; -use cw_controllers::Claims; -use cw_storage_plus::Item; -use cw_utils::Duration; - -pub const CLAIMS: Claims = Claims::new("claims"); - -/// Investment info is fixed at instantiation, and is used to control the function of the contract -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct InvestmentInfo { - /// Owner created the contract and takes a cut - pub owner: Addr, - /// This is the denomination we can stake (and only one we accept for payments) - pub bond_denom: String, - /// This is the unbonding period of the native staking module - /// We need this to only allow claims to be redeemed after the money has arrived - pub unbonding_period: Duration, - /// This is how much the owner takes as a cut when someone unbonds - pub exit_tax: Decimal, - /// All tokens are bonded to this validator - /// FIXME: address validation doesn't work for validator addresses - pub validator: String, - /// This is the minimum amount we will pull out to reinvest, as well as a minimum - /// that can be unbonded (to avoid needless staking tx) - pub min_withdrawal: Uint128, -} - -/// Supply is dynamic and tracks the current supply of staked and ERC20 tokens. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, Default)] -pub struct Supply { - /// issued is how many derivative tokens this contract has issued - pub issued: Uint128, - /// bonded is how many native tokens exist bonded to the validator - pub bonded: Uint128, - /// claims is how many tokens need to be reserved paying back those who unbonded - pub claims: Uint128, -} - -pub const INVESTMENT: Item = Item::new("invest"); -pub const TOTAL_SUPPLY: Item = Item::new("total_supply"); From fa8304d2a3a0e5301eae02647f5d7212af4ffb82 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 28 Dec 2021 19:04:43 +0100 Subject: [PATCH 123/352] Regenerate Cargo.lock --- Cargo.lock | 239 ++++------------------------------------------------- 1 file changed, 16 insertions(+), 223 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf9ab4438..63f146579 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,12 +26,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - [[package]] name = "assert_matches" version = "1.5.0" @@ -65,42 +59,15 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "byteorder" version = "1.4.3" @@ -137,7 +104,7 @@ version = "1.0.0-beta3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a380b87642204557629c9b72988c47b55fbfe6d474960adba56b22331504956a" dependencies = [ - "digest 0.9.0", + "digest", "ed25519-zebra", "k256", "rand_core 0.5.1", @@ -210,7 +177,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" dependencies = [ - "generic-array 0.14.4", + "generic-array", "rand_core 0.6.3", "subtle", "zeroize", @@ -222,7 +189,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ - "generic-array 0.14.4", + "generic-array", "subtle", ] @@ -233,7 +200,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ "byteorder", - "digest 0.9.0", + "digest", "rand_core 0.5.1", "subtle", "zeroize", @@ -401,23 +368,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cw20-atomic-swap" -version = "0.11.1" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "cw2", - "cw20", - "hex 0.3.2", - "schemars", - "serde", - "sha2 0.8.2", - "thiserror", -] - [[package]] name = "cw20-base" version = "0.11.1" @@ -433,42 +383,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cw20-bonding" -version = "0.11.1" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "cw2", - "cw20", - "cw20-base", - "integer-cbrt", - "integer-sqrt", - "rust_decimal", - "schemars", - "serde", - "thiserror", -] - -[[package]] -name = "cw20-escrow" -version = "0.11.1" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-multi-test", - "cw-storage-plus", - "cw-utils", - "cw2", - "cw20", - "cw20-base", - "schemars", - "serde", - "thiserror", -] - [[package]] name = "cw20-ics20" version = "0.11.1" @@ -484,41 +398,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cw20-merkle-airdrop" -version = "0.7.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "cw2", - "cw20", - "hex 0.4.3", - "schemars", - "serde", - "serde_json", - "sha2 0.9.8", - "thiserror", -] - -[[package]] -name = "cw20-staking" -version = "0.11.1" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-controllers", - "cw-storage-plus", - "cw-utils", - "cw2", - "cw20", - "cw20-base", - "schemars", - "serde", - "thiserror", -] - [[package]] name = "cw3" version = "0.11.1" @@ -631,22 +510,13 @@ dependencies = [ "syn", ] -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -674,10 +544,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a128b76af6dd4b427e34a6fd43dc78dbfe73672ec41ff615a2414c1a0ad0409" dependencies = [ "curve25519-dalek", - "hex 0.4.3", + "hex", "rand_core 0.5.1", "serde", - "sha2 0.9.8", + "sha2", "thiserror", ] @@ -695,7 +565,7 @@ checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" dependencies = [ "crypto-bigint", "ff", - "generic-array 0.14.4", + "generic-array", "group", "pkcs8", "rand_core 0.6.3", @@ -703,12 +573,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "ff" version = "0.10.1" @@ -719,15 +583,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.4" @@ -777,12 +632,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" - [[package]] name = "hex" version = "0.4.3" @@ -796,25 +645,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ "crypto-mac", - "digest 0.9.0", -] - -[[package]] -name = "integer-cbrt" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "151bce4481ba7da831c7d12c32353cc79c73bf79732e343b92786e4cbbb2948c" -dependencies = [ - "num-traits", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits", + "digest", ] [[package]] @@ -841,7 +672,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sha2 0.9.8", + "sha2", ] [[package]] @@ -866,15 +697,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg", -] - [[package]] name = "object" version = "0.27.1" @@ -884,12 +706,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -965,17 +781,6 @@ dependencies = [ "getrandom 0.2.3", ] -[[package]] -name = "rust_decimal" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71b5a9625a7e6060b23db692facf49082cc78889a7e6ac94a735356ae49db4b0" -dependencies = [ - "arrayvec", - "num-traits", - "serde", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1069,29 +874,17 @@ dependencies = [ "serde", ] -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - [[package]] name = "sha2" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ - "block-buffer 0.9.0", + "block-buffer", "cfg-if", "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest", + "opaque-debug", ] [[package]] @@ -1100,7 +893,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" dependencies = [ - "digest 0.9.0", + "digest", "rand_core 0.6.3", ] @@ -1170,7 +963,7 @@ checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" dependencies = [ "byteorder", "crunchy", - "hex 0.4.3", + "hex", "static_assertions", ] From 59bf5d862aff1b996fbd147aca94a521dc0ac4cf Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 30 Dec 2021 07:55:56 +0100 Subject: [PATCH 124/352] Publish `PrefixBound` --- packages/storage-plus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index e054879cf..0bcbafce0 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -38,6 +38,6 @@ pub use keys_old::IntKeyOld; pub use map::Map; pub use path::Path; #[cfg(feature = "iterator")] -pub use prefix::{range_with_prefix, Bound, Prefix}; +pub use prefix::{range_with_prefix, Bound, Prefix, PrefixBound}; #[cfg(feature = "iterator")] pub use snapshot::{SnapshotItem, SnapshotMap, Strategy}; From b7dbdb66a067f8023983ba000dcca25185b9110d Mon Sep 17 00:00:00 2001 From: John Y Date: Thu, 30 Dec 2021 07:22:42 -0500 Subject: [PATCH 125/352] fix readme update coralnet to sandynet-1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 152d92557..062c7fd10 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ many custom contracts. If you don't know what CosmWasm is, please check out [our homepage](https://cosmwasm.com) and [our documentation](https://docs.cosmwasm.com) to get more background. -We are running a [public testnet](https://github.com/CosmWasm/testnets/blob/master/coralnet/README.md) +We are running a [public testnet](https://github.com/CosmWasm/testnets/blob/master/sandynet-1/README.md) you can use to test out any contracts. **Warning** None of these contracts have been audited and no liability is From 5036dce6a2e47d44b4305404edc7fd75d99a8688 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 26 Dec 2021 14:15:28 +0100 Subject: [PATCH 126/352] Add signed int key benches --- packages/storage-plus/Cargo.toml | 11 ++++ packages/storage-plus/benches/main.rs | 94 +++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 packages/storage-plus/benches/main.rs diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 9eefb2040..bf5172df1 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -13,7 +13,18 @@ documentation = "https://docs.cosmwasm.com" default = ["iterator"] iterator = ["cosmwasm-std/iterator"] +[lib] +# See https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options +bench = false + [dependencies] cosmwasm-std = { version = "1.0.0-beta3", default-features = false } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } + +[dev-dependencies] +criterion = { version = "0.3", features = [ "html_reports" ] } + +[[bench]] +name = "main" +harness = false \ No newline at end of file diff --git a/packages/storage-plus/benches/main.rs b/packages/storage-plus/benches/main.rs new file mode 100644 index 000000000..cd9bca200 --- /dev/null +++ b/packages/storage-plus/benches/main.rs @@ -0,0 +1,94 @@ +use std::mem; +use std::time::Duration; +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use cw_storage_plus::CwIntKey; + +fn bench_signed_int_key(c: &mut Criterion) { + let mut group = c.benchmark_group("Signed int keys"); + + let k: i32 = 0x42434445; + type Buf = [u8; mem::size_of::()]; + + group.bench_function("i32 to_cw_bytes: xored (u32) + to_be_bytes", |b| { + #[inline] + fn to_cw_bytes(value: &i32) -> Buf { + (*value as u32 ^ i32::MIN as u32).to_be_bytes() + } + + assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); + assert_eq!(to_cw_bytes(&k), i32::to_cw_bytes(&k)); + assert_eq!(to_cw_bytes(&-k), i32::to_cw_bytes(&-k)); + + b.iter(|| { + black_box(to_cw_bytes(&k)); + }); + }); + + group.bench_function("i32 to_cw_bytes: xored (u128) + to_be_bytes", |b| { + #[inline] + fn to_cw_bytes(value: &i32) -> Buf { + ((*value as u128 ^ i32::MIN as u128) as i32).to_be_bytes() + } + + assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); + assert_eq!(to_cw_bytes(&k), i32::to_cw_bytes(&k)); + assert_eq!(to_cw_bytes(&-k), i32::to_cw_bytes(&-k)); + + b.iter(|| { + black_box(to_cw_bytes(&k)); + }); + }); + + group.bench_function("i32 to_cw_bytes: mut to_be_bytes + xor", |b| { + #[inline] + fn to_cw_bytes(value: &i32) -> Buf { + let mut buf = i32::to_be_bytes(*value); + buf[0] ^= 0x80; + buf + } + + assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); + assert_eq!(to_cw_bytes(&k), i32::to_cw_bytes(&k)); + assert_eq!(to_cw_bytes(&-k), i32::to_cw_bytes(&-k)); + + b.iter(|| { + black_box(to_cw_bytes(&k)); + }); + }); + + group.bench_function("i32 to_cw_bytes: branching plus / minus", |b| { + #[inline] + fn to_cw_bytes(value: &i32) -> Buf { + if value >= &0i32 { + (*value as u32 - i32::MIN as u32).to_be_bytes() + } else { + (*value as u32 + i32::MIN as u32).to_be_bytes() + } + } + + assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); + assert_eq!(to_cw_bytes(&k), i32::to_cw_bytes(&k)); + assert_eq!(to_cw_bytes(&-k), i32::to_cw_bytes(&-k)); + + b.iter(|| { + black_box(to_cw_bytes(&k)); + }); + }); + + group.finish(); +} + +fn make_config() -> Criterion { + Criterion::default() + .without_plots() + .measurement_time(Duration::new(10, 0)) + .sample_size(12) + .configure_from_args() +} + +criterion_group!( + name = signed_int_key; + config = make_config(); + targets = bench_signed_int_key +); +criterion_main!(signed_int_key); From 9d10ba13f3d89b16e412fecdefb8464e0153a496 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 26 Dec 2021 14:26:18 +0100 Subject: [PATCH 127/352] Use random values for signed int key benches --- packages/storage-plus/Cargo.toml | 1 + packages/storage-plus/benches/main.rs | 47 ++++++++++++++++++--------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index bf5172df1..d2370031d 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -24,6 +24,7 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] criterion = { version = "0.3", features = [ "html_reports" ] } +rand = "0.8" [[bench]] name = "main" diff --git a/packages/storage-plus/benches/main.rs b/packages/storage-plus/benches/main.rs index cd9bca200..9b4c41cc1 100644 --- a/packages/storage-plus/benches/main.rs +++ b/packages/storage-plus/benches/main.rs @@ -1,12 +1,23 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; + +use rand::Rng; use std::mem; use std::time::Duration; -use criterion::{black_box, criterion_group, criterion_main, Criterion}; + use cw_storage_plus::CwIntKey; fn bench_signed_int_key(c: &mut Criterion) { let mut group = c.benchmark_group("Signed int keys"); - let k: i32 = 0x42434445; + fn k() -> i32 { + // let k: i32 = 0x42434445; + // k + let r = rand::thread_rng().gen_range(i32::MIN..i32::MAX); + r + } + // For the asserts + let k_check = k(); + type Buf = [u8; mem::size_of::()]; group.bench_function("i32 to_cw_bytes: xored (u32) + to_be_bytes", |b| { @@ -16,11 +27,12 @@ fn bench_signed_int_key(c: &mut Criterion) { } assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); - assert_eq!(to_cw_bytes(&k), i32::to_cw_bytes(&k)); - assert_eq!(to_cw_bytes(&-k), i32::to_cw_bytes(&-k)); + assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check)); + assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); b.iter(|| { - black_box(to_cw_bytes(&k)); + black_box(to_cw_bytes(&k())); + black_box(to_cw_bytes(&-k())); }); }); @@ -31,11 +43,12 @@ fn bench_signed_int_key(c: &mut Criterion) { } assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); - assert_eq!(to_cw_bytes(&k), i32::to_cw_bytes(&k)); - assert_eq!(to_cw_bytes(&-k), i32::to_cw_bytes(&-k)); + assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check)); + assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); b.iter(|| { - black_box(to_cw_bytes(&k)); + black_box(to_cw_bytes(&k())); + black_box(to_cw_bytes(&-k())); }); }); @@ -48,11 +61,12 @@ fn bench_signed_int_key(c: &mut Criterion) { } assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); - assert_eq!(to_cw_bytes(&k), i32::to_cw_bytes(&k)); - assert_eq!(to_cw_bytes(&-k), i32::to_cw_bytes(&-k)); + assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check)); + assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); b.iter(|| { - black_box(to_cw_bytes(&k)); + black_box(to_cw_bytes(&k())); + black_box(to_cw_bytes(&-k())); }); }); @@ -67,11 +81,12 @@ fn bench_signed_int_key(c: &mut Criterion) { } assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); - assert_eq!(to_cw_bytes(&k), i32::to_cw_bytes(&k)); - assert_eq!(to_cw_bytes(&-k), i32::to_cw_bytes(&-k)); + assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check)); + assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); b.iter(|| { - black_box(to_cw_bytes(&k)); + black_box(to_cw_bytes(&k())); + black_box(to_cw_bytes(&-k())); }); }); @@ -81,8 +96,8 @@ fn bench_signed_int_key(c: &mut Criterion) { fn make_config() -> Criterion { Criterion::default() .without_plots() - .measurement_time(Duration::new(10, 0)) - .sample_size(12) + .measurement_time(Duration::new(5, 0)) + .sample_size(10) .configure_from_args() } From 384a929d08266a249c64cdda5dab2c5fdd389d1e Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 1 Jan 2022 15:00:15 +0100 Subject: [PATCH 128/352] Update lock file --- Cargo.lock | 516 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 515 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 63f146579..e241537d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,6 +32,17 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.0.1" @@ -59,6 +70,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "block-buffer" version = "0.9.0" @@ -68,6 +85,24 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" + [[package]] name = "byteorder" version = "1.4.3" @@ -80,6 +115,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +[[package]] +name = "cast" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" +dependencies = [ + "rustc_version", +] + [[package]] name = "cc" version = "1.0.72" @@ -92,6 +136,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "bitflags", + "textwrap", + "unicode-width", +] + [[package]] name = "const-oid" version = "0.6.2" @@ -165,6 +220,86 @@ dependencies = [ "libc", ] +[[package]] +name = "criterion" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" +dependencies = [ + "atty", + "cast", + "clap", + "criterion-plot", + "csv", + "itertools", + "lazy_static", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_cbor", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" +dependencies = [ + "cast", + "itertools", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +dependencies = [ + "cfg-if", + "lazy_static", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -193,6 +328,28 @@ dependencies = [ "subtle", ] +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa 0.4.8", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -240,6 +397,8 @@ name = "cw-storage-plus" version = "0.11.1" dependencies = [ "cosmwasm-std", + "criterion", + "rand", "schemars", "serde", ] @@ -632,6 +791,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hex" version = "0.4.3" @@ -657,12 +831,27 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + [[package]] name = "itoa" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +[[package]] +name = "js-sys" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "k256" version = "0.9.6" @@ -675,18 +864,42 @@ dependencies = [ "sha2", ] +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "libc" version = "0.2.112" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + [[package]] name = "memchr" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "miniz_oxide" version = "0.4.4" @@ -697,6 +910,25 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "object" version = "0.27.1" @@ -706,6 +938,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + [[package]] name = "opaque-debug" version = "0.3.0" @@ -722,6 +960,40 @@ dependencies = [ "spki", ] +[[package]] +name = "plotters" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" + +[[package]] +name = "plotters-svg" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + [[package]] name = "proc-macro2" version = "1.0.34" @@ -763,6 +1035,28 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.3", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.3", +] + [[package]] name = "rand_core" version = "0.5.1" @@ -781,18 +1075,91 @@ dependencies = [ "getrandom 0.2.3", ] +[[package]] +name = "rand_hc" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +dependencies = [ + "rand_core 0.6.3", +] + +[[package]] +name = "rayon" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + [[package]] name = "rustc-demangle" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "ryu" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schemars" version = "0.8.8" @@ -817,6 +1184,12 @@ dependencies = [ "syn", ] +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "semver" version = "1.0.4" @@ -841,6 +1214,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.132" @@ -869,7 +1252,7 @@ version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" dependencies = [ - "itoa", + "itoa 1.0.1", "ryu", "serde", ] @@ -929,6 +1312,15 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.30" @@ -949,6 +1341,16 @@ dependencies = [ "syn", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "typenum" version = "1.14.0" @@ -967,6 +1369,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicode-width" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" + [[package]] name = "unicode-xid" version = "0.2.2" @@ -979,6 +1387,17 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -991,6 +1410,101 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasm-bindgen" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" + +[[package]] +name = "web-sys" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "zeroize" version = "1.4.3" From 1c807cbbe19626d7917250dc4b2959742353169a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 1 Jan 2022 15:00:33 +0100 Subject: [PATCH 129/352] Add unsigned bench for reference Use same value for positive/negative calls --- packages/storage-plus/benches/main.rs | 60 +++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/packages/storage-plus/benches/main.rs b/packages/storage-plus/benches/main.rs index 9b4c41cc1..761bb7ce3 100644 --- a/packages/storage-plus/benches/main.rs +++ b/packages/storage-plus/benches/main.rs @@ -31,8 +31,9 @@ fn bench_signed_int_key(c: &mut Criterion) { assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); b.iter(|| { - black_box(to_cw_bytes(&k())); - black_box(to_cw_bytes(&-k())); + let k = k(); + black_box(to_cw_bytes(&k)); + black_box(to_cw_bytes(&-k)); }); }); @@ -47,8 +48,9 @@ fn bench_signed_int_key(c: &mut Criterion) { assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); b.iter(|| { - black_box(to_cw_bytes(&k())); - black_box(to_cw_bytes(&-k())); + let k = k(); + black_box(to_cw_bytes(&k)); + black_box(to_cw_bytes(&-k)); }); }); @@ -65,8 +67,9 @@ fn bench_signed_int_key(c: &mut Criterion) { assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); b.iter(|| { - black_box(to_cw_bytes(&k())); - black_box(to_cw_bytes(&-k())); + let k = k(); + black_box(to_cw_bytes(&k)); + black_box(to_cw_bytes(&-k)); }); }); @@ -85,8 +88,42 @@ fn bench_signed_int_key(c: &mut Criterion) { assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); b.iter(|| { - black_box(to_cw_bytes(&k())); - black_box(to_cw_bytes(&-k())); + let k = k(); + black_box(to_cw_bytes(&k)); + black_box(to_cw_bytes(&-k)); + }); + }); + + group.finish(); +} + +fn bench_unsigned_int_key(c: &mut Criterion) { + let mut group = c.benchmark_group("Unsigned int keys"); + + fn k() -> u32 { + // let k: u32 = 0x42434445; + // k + let r = rand::thread_rng().gen_range(u32::MIN..u32::MAX); + r + } + // For the asserts + let k_check = k(); + + type Buf = [u8; mem::size_of::()]; + + group.bench_function("u32 to_cw_bytes", |b| { + #[inline] + fn to_cw_bytes(value: &u32) -> Buf { + value.to_be_bytes() + } + + assert_eq!(to_cw_bytes(&0), u32::to_cw_bytes(&0)); + assert_eq!(to_cw_bytes(&k_check), u32::to_cw_bytes(&k_check)); + + b.iter(|| { + let k = k(); + black_box(to_cw_bytes(&k)); + black_box(to_cw_bytes(&k)); // twice for comparability }); }); @@ -106,4 +143,9 @@ criterion_group!( config = make_config(); targets = bench_signed_int_key ); -criterion_main!(signed_int_key); +criterion_group!( + name = unsigned_int_key; + config = make_config(); + targets = bench_unsigned_int_key +); +criterion_main!(signed_int_key, unsigned_int_key); From 24f7aad3eebc889ce36fab881c45f9493eee4b95 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 3 Jan 2022 08:36:48 +0100 Subject: [PATCH 130/352] Add benchmarking job to CI --- .circleci/config.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index b1ac2aa51..e0f17176b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,6 +25,18 @@ workflows: - package_storage_plus - lint - wasm-build + - benchmarking: + requires: + - package_storage_plus + filters: + branches: + only: + # Long living branches + - main + - /^[0-9]+\.[0-9]+$/ + # 👇Add your branch here if benchmarking matters to your work + - benchmarking + - signed-int-key-bench deploy: jobs: - build_and_upload_contracts: @@ -662,6 +674,29 @@ jobs: - target key: cargocache-v2-storage-plus:1.53.0-{{ checksum "~/project/Cargo.lock" }} + benchmarking: + docker: + - image: rust:1.53.0 + environment: + RUST_BACKTRACE: 1 + steps: + - checkout + - run: + name: Version information (default; stable) + command: rustc --version && cargo --version + - restore_cache: + keys: + - cargocache-v2-benchmarking-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - run: + name: Run storage-plus benchmarks + working_directory: ~/project/packages/storage-plus + command: cargo bench -- --color never --save-baseline + - save_cache: + paths: + - /usr/local/cargo/registry + - target + key: cargocache-v2-benchmarking-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + # This job roughly follows the instructions from https://circleci.com/blog/publishing-to-github-releases-via-circleci/ build_and_upload_contracts: docker: From d5d255cf09c26fa647f118db2864e8274fc75fe5 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 3 Jan 2022 08:39:48 +0100 Subject: [PATCH 131/352] Fix clippy warnings --- packages/storage-plus/benches/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/storage-plus/benches/main.rs b/packages/storage-plus/benches/main.rs index 761bb7ce3..cd02624c5 100644 --- a/packages/storage-plus/benches/main.rs +++ b/packages/storage-plus/benches/main.rs @@ -12,8 +12,7 @@ fn bench_signed_int_key(c: &mut Criterion) { fn k() -> i32 { // let k: i32 = 0x42434445; // k - let r = rand::thread_rng().gen_range(i32::MIN..i32::MAX); - r + rand::thread_rng().gen_range(i32::MIN..i32::MAX) } // For the asserts let k_check = k(); @@ -103,8 +102,7 @@ fn bench_unsigned_int_key(c: &mut Criterion) { fn k() -> u32 { // let k: u32 = 0x42434445; // k - let r = rand::thread_rng().gen_range(u32::MIN..u32::MAX); - r + rand::thread_rng().gen_range(u32::MIN..u32::MAX) } // For the asserts let k_check = k(); From a1cab57563ab0952c14e6e0dd0e17bc13ce08c8d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 3 Jan 2022 08:46:36 +0100 Subject: [PATCH 132/352] Fix checkout --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e0f17176b..3ecd7a00c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -680,7 +680,8 @@ jobs: environment: RUST_BACKTRACE: 1 steps: - - checkout + - checkout: + path: ~/project - run: name: Version information (default; stable) command: rustc --version && cargo --version From 6c22e89acd85c758ca81a1ec067479aee1bdce9f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 3 Jan 2022 11:23:47 +0100 Subject: [PATCH 133/352] Remove unneeded branches from benchmarking --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3ecd7a00c..bccf2c4b3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,10 +33,7 @@ workflows: only: # Long living branches - main - - /^[0-9]+\.[0-9]+$/ # 👇Add your branch here if benchmarking matters to your work - - benchmarking - - signed-int-key-bench deploy: jobs: - build_and_upload_contracts: From 6b595b524a1ee7a3c64deb6754727774e15e67e8 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Mon, 3 Jan 2022 13:29:55 +0100 Subject: [PATCH 134/352] Remove IntKey and TimestampKey with all surrounding implementations --- packages/storage-plus/src/de.rs | 127 +------------------ packages/storage-plus/src/keys.rs | 194 +----------------------------- packages/storage-plus/src/lib.rs | 9 +- 3 files changed, 7 insertions(+), 323 deletions(-) diff --git a/packages/storage-plus/src/de.rs b/packages/storage-plus/src/de.rs index 60f6fcb57..c1b13889f 100644 --- a/packages/storage-plus/src/de.rs +++ b/packages/storage-plus/src/de.rs @@ -1,13 +1,9 @@ -// TODO: Remove along with IntKey -#![allow(deprecated)] - use std::array::TryFromSliceError; use std::convert::TryInto; use cosmwasm_std::{Addr, StdError, StdResult}; use crate::int_key::CwIntKey; -use crate::keys::{IntKey, TimestampKey}; pub trait KeyDeserialize { type Output: Sized; @@ -116,31 +112,6 @@ macro_rules! integer_de { integer_de!(for i8, u8, i16, u16, i32, u32, i64, u64, i128, u128); -macro_rules! intkey_de { - (for $($t:ty),+) => { - $(impl KeyDeserialize for IntKey<$t> { - type Output = $t; - - #[inline(always)] - fn from_vec(value: Vec) -> StdResult { - Ok(<$t>::from_cw_bytes(value.as_slice().try_into() - .map_err(|err: TryFromSliceError| StdError::generic_err(err.to_string()))?)) - } - })* - } -} - -intkey_de!(for i8, u8, i16, u16, i32, u32, i64, u64, i128, u128); - -impl KeyDeserialize for TimestampKey { - type Output = u64; - - #[inline(always)] - fn from_vec(value: Vec) -> StdResult { - >::from_vec(value) - } -} - fn parse_length(value: &[u8]) -> StdResult { Ok(u16::from_be_bytes( value @@ -183,7 +154,7 @@ impl KeyDeserialize for #[cfg(test)] mod test { use super::*; - use crate::{PrimaryKey, U32Key}; + use crate::PrimaryKey; const BYTES: &[u8] = b"Hello"; const STRING: &str = "Hello"; @@ -278,96 +249,6 @@ mod test { ); } - #[test] - fn deserialize_integer_works() { - assert_eq!(>::from_slice(&[1]).unwrap(), 1u8); - assert_eq!(>::from_slice(&[127]).unwrap(), -1i8); - assert_eq!(>::from_slice(&[128]).unwrap(), 0i8); - - assert_eq!(>::from_slice(&[1, 0]).unwrap(), 256u16); - assert_eq!(>::from_slice(&[128, 0]).unwrap(), 0i16); - assert_eq!(>::from_slice(&[127, 255]).unwrap(), -1i16); - - assert_eq!( - >::from_slice(&[1, 0, 0, 0]).unwrap(), - 16777216u32 - ); - assert_eq!(>::from_slice(&[128, 0, 0, 0]).unwrap(), 0i32); - assert_eq!( - >::from_slice(&[127, 255, 255, 255]).unwrap(), - -1i32 - ); - - assert_eq!( - >::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0]).unwrap(), - 72057594037927936u64 - ); - assert_eq!( - >::from_slice(&[128, 0, 0, 0, 0, 0, 0, 0]).unwrap(), - 0i64 - ); - assert_eq!( - >::from_slice(&[127, 255, 255, 255, 255, 255, 255, 255]).unwrap(), - -1i64 - ); - - assert_eq!( - >::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).unwrap(), - 1329227995784915872903807060280344576u128 - ); - assert_eq!( - >::from_slice(&[128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) - .unwrap(), - 0i128 - ); - assert_eq!( - >::from_slice(&[ - 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 - ]) - .unwrap(), - -1i128 - ); - assert_eq!( - >::from_slice(&[ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 - ]) - .unwrap(), - 170141183460469231731687303715884105727i128, - ); - } - - #[test] - fn deserialize_broken_integer_errs() { - // One byte less fails - assert!(matches!( - >::from_slice(&[1]).err(), - Some(StdError::GenericErr { .. }) - )); - - // More bytes fails too - assert!(matches!( - >::from_slice(&[1, 2]).err(), - Some(StdError::GenericErr { .. }) - )); - } - - #[test] - fn deserialize_timestamp_works() { - assert_eq!( - ::from_slice(&[1, 0, 0, 0, 0, 0, 0, 0]).unwrap(), - 72057594037927936 - ); - } - - #[test] - fn deserialize_broken_timestamp_errs() { - // More bytes fails - assert!(matches!( - ::from_slice(&[1, 2, 3, 4, 5, 6, 7, 8, 9]).err(), - Some(StdError::GenericErr { .. }) - )); - } - #[test] fn deserialize_tuple_works() { assert_eq!( @@ -379,10 +260,8 @@ mod test { #[test] fn deserialize_triple_works() { assert_eq!( - <(&[u8], U32Key, &str)>::from_slice( - (BYTES, U32Key::new(1234), STRING).joined_key().as_slice() - ) - .unwrap(), + <(&[u8], u32, &str)>::from_slice((BYTES, 1234u32, STRING).joined_key().as_slice()) + .unwrap(), (BYTES.to_vec(), 1234, STRING.to_string()) ); } diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index 63bedba2e..e4240abb1 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -1,13 +1,8 @@ -// TODO: Remove along with IntKey -#![allow(deprecated)] - -use cosmwasm_std::{Addr, Timestamp}; -use std::marker::PhantomData; +use cosmwasm_std::Addr; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; use crate::int_key::CwIntKey; -use crate::Endian; #[derive(Debug)] pub enum Key<'a> { @@ -305,153 +300,10 @@ macro_rules! integer_prefix { integer_prefix!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64); -// this auto-implements PrimaryKey for all the IntKey types -impl<'a, T: Endian + Clone> PrimaryKey<'a> for IntKey -where - IntKey: KeyDeserialize, -{ - type Prefix = (); - type SubPrefix = (); - type Suffix = Self; - type SuperSuffix = Self; - - fn key(&self) -> Vec { - self.wrapped.key() - } -} - -// this auto-implements Prefixer for all the IntKey types -impl<'a, T: Endian> Prefixer<'a> for IntKey { - fn prefix(&self) -> Vec { - self.wrapped.prefix() - } -} - -#[deprecated(note = "It is suggested to use `u8` as key type instead of the `U8Key` wrapper")] -pub type U8Key = IntKey; -#[deprecated(note = "It is suggested to use `u16` as key type instead of the `U16Key` wrapper")] -pub type U16Key = IntKey; -#[deprecated(note = "It is suggested to use `u32` as key type instead of the `U32Key` wrapper")] -pub type U32Key = IntKey; -#[deprecated(note = "It is suggested to use `u64` as key type instead of the `U64Key` wrapper")] -pub type U64Key = IntKey; -#[deprecated(note = "Consider using 64-bit keys instead of the `U128Key` wrapper")] -pub type U128Key = IntKey; - -#[deprecated(note = "It is suggested to use `i8` as key type instead of the `I8Key` wrapper")] -pub type I8Key = IntKey; -#[deprecated(note = "It is suggested to use `i16` as key type instead of the `I16Key` wrapper")] -pub type I16Key = IntKey; -#[deprecated(note = "It is suggested to use `i32` as key type instead of the `I32Key` wrapper")] -pub type I32Key = IntKey; -#[deprecated(note = "It is suggested to use `i64` as key type instead of the `I64Key` wrapper")] -pub type I64Key = IntKey; -#[deprecated(note = "Consider using 64-bit keys instead of the `I128Key` wrapper")] -pub type I128Key = IntKey; - -/// It will cast one-particular int type into a Key via Vec, ensuring you don't mix up u32 and u64 -/// You can use new or the from/into pair to build a key from an int: -/// -/// let k = U64Key::new(12345); -/// let k = U32Key::from(12345); -/// let k: U16Key = 12345.into(); -#[deprecated(note = "It is suggested to use naked int types instead of IntKey wrapper")] -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct IntKey { - pub wrapped: Vec, - pub data: PhantomData, -} - -impl IntKey { - pub fn new(val: T) -> Self { - IntKey { - wrapped: val.to_cw_bytes().into(), - data: PhantomData, - } - } -} - -impl From for IntKey { - fn from(val: T) -> Self { - IntKey::new(val) - } -} - -impl From> for IntKey { - fn from(wrap: Vec) -> Self { - // TODO: Consider properly handling case, when `wrap` has length not conforming for the - // wrapped integer type. - IntKey { - wrapped: wrap, - data: PhantomData, - } - } -} - -impl From> for Vec { - fn from(k: IntKey) -> Vec { - k.wrapped - } -} - -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct TimestampKey(U64Key); - -impl TimestampKey { - pub fn new(ts: Timestamp) -> Self { - Self(ts.nanos().into()) - } -} - -impl<'a> PrimaryKey<'a> for TimestampKey { - type Prefix = (); - type SubPrefix = (); - type Suffix = Self; - type SuperSuffix = Self; - - fn key(&self) -> Vec { - self.0.key() - } -} - -impl<'a> Prefixer<'a> for TimestampKey { - fn prefix(&self) -> Vec { - self.0.prefix() - } -} - -impl From> for TimestampKey { - fn from(val: Vec) -> Self { - Self(val.into()) - } -} - -impl From for TimestampKey { - fn from(val: Timestamp) -> Self { - Self::new(val) - } -} - #[cfg(test)] mod test { use super::*; - #[test] - fn u64key_works() { - let k: U64Key = 134u64.into(); - let path = k.key(); - assert_eq!(1, path.len()); - assert_eq!(134u64.to_cw_bytes(), path[0].as_ref()); - } - - #[test] - fn u32key_works() { - let k: U32Key = 4242u32.into(); - let path = k.key(); - assert_eq!(1, path.len()); - assert_eq!(4242u32.to_cw_bytes(), path[0].as_ref()); - } - #[test] fn naked_8key_works() { let k: u8 = 42u8; @@ -549,22 +401,9 @@ mod test { assert_eq!(path, vec!["foo".as_bytes(), b"bar"],); } - #[test] - fn composite_int_key() { - // Note we don't spec the int types (u32, u64) on the right, - // just the keys they convert into - let k: (U32Key, U64Key) = (123.into(), 87654.into()); - let path = k.key(); - assert_eq!(2, path.len()); - assert_eq!(4, path[0].as_ref().len()); - assert_eq!(8, path[1].as_ref().len()); - assert_eq!(path[0].as_ref(), 123u32.to_cw_bytes()); - assert_eq!(path[1].as_ref(), 87654u64.to_cw_bytes()); - } - #[test] fn naked_composite_int_key() { - let k: (u32, U64Key) = (123, 87654.into()); + let k: (u32, u64) = (123, 87654); let path = k.key(); assert_eq!(2, path.len()); assert_eq!(4, path[0].as_ref().len()); @@ -589,35 +428,6 @@ mod test { assert_eq!(dir, vec![first, b"bar"]); } - #[test] - fn proper_prefixes() { - let simple: &str = "hello"; - assert_eq!(simple.prefix().len(), 1); - assert_eq!(simple.prefix()[0].as_ref(), b"hello"); - - let pair: (U32Key, &[u8]) = (12345.into(), b"random"); - let one: Vec = vec![0, 0, 48, 57]; - let two: Vec = b"random".to_vec(); - assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); - - let triple: (&str, U32Key, &[u8]) = ("begin", 12345.into(), b"end"); - let one: Vec = b"begin".to_vec(); - let two: Vec = vec![0, 0, 48, 57]; - let three: Vec = b"end".to_vec(); - assert_eq!( - triple.prefix(), - vec![one.as_slice(), two.as_slice(), three.as_slice()] - ); - - // same works with owned variants (&str -> String, &[u8] -> Vec) - let owned_triple: (String, U32Key, Vec) = - ("begin".to_string(), 12345.into(), b"end".to_vec()); - assert_eq!( - owned_triple.prefix(), - vec![one.as_slice(), two.as_slice(), three.as_slice()] - ); - } - #[test] fn naked_8bit_prefixes() { let pair: (u8, &[u8]) = (123, b"random"); diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 0bcbafce0..ff8e508b9 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -26,14 +26,9 @@ pub use indexes::MultiIndex; pub use indexes::UniqueIndex; #[cfg(feature = "iterator")] pub use indexes::{index_string, index_string_tuple, index_triple, index_tuple, Index}; -pub use item::Item; -// TODO: Remove along with `IntKey` -#[allow(deprecated)] -pub use keys::{I128Key, I16Key, I32Key, I64Key, I8Key}; -// TODO: Remove along with `IntKey` pub use int_key::CwIntKey; -#[allow(deprecated)] -pub use keys::{Key, Prefixer, PrimaryKey, U128Key, U16Key, U32Key, U64Key, U8Key}; +pub use item::Item; +pub use keys::{Key, Prefixer, PrimaryKey}; pub use keys_old::IntKeyOld; pub use map::Map; pub use path::Path; From ac89c423ed6f83246ae9197bdce19551e2122a20 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Mon, 3 Jan 2022 13:51:07 +0100 Subject: [PATCH 135/352] Rename CwIntKey into IntKey --- packages/storage-plus/benches/main.rs | 2 +- packages/storage-plus/src/de.rs | 2 +- packages/storage-plus/src/int_key.rs | 7 +++---- packages/storage-plus/src/keys.rs | 2 +- packages/storage-plus/src/lib.rs | 2 +- packages/storage-plus/src/map.rs | 2 +- packages/storage-plus/src/prefix.rs | 6 +++--- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/storage-plus/benches/main.rs b/packages/storage-plus/benches/main.rs index cd02624c5..021deac65 100644 --- a/packages/storage-plus/benches/main.rs +++ b/packages/storage-plus/benches/main.rs @@ -4,7 +4,7 @@ use rand::Rng; use std::mem; use std::time::Duration; -use cw_storage_plus::CwIntKey; +use cw_storage_plus::IntKey; fn bench_signed_int_key(c: &mut Criterion) { let mut group = c.benchmark_group("Signed int keys"); diff --git a/packages/storage-plus/src/de.rs b/packages/storage-plus/src/de.rs index c1b13889f..046d8b9cb 100644 --- a/packages/storage-plus/src/de.rs +++ b/packages/storage-plus/src/de.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; use cosmwasm_std::{Addr, StdError, StdResult}; -use crate::int_key::CwIntKey; +use crate::int_key::IntKey; pub trait KeyDeserialize { type Output: Sized; diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs index 7f7713369..0292674a2 100644 --- a/packages/storage-plus/src/int_key.rs +++ b/packages/storage-plus/src/int_key.rs @@ -4,8 +4,7 @@ use std::mem; /// but "sign-flipped" (xored msb) big-endian bytes for signed ints. /// /// So that the representation of signed integers is in the right lexicographical order. -// TODO: Rename to `IntKey` after deprecating current `IntKey` (https://github.com/CosmWasm/cw-plus/issues/570) -pub trait CwIntKey: Sized + Copy { +pub trait IntKey: Sized + Copy { type Buf: AsRef<[u8]> + AsMut<[u8]> + Into> + Default; fn to_cw_bytes(&self) -> Self::Buf; @@ -14,7 +13,7 @@ pub trait CwIntKey: Sized + Copy { macro_rules! cw_uint_keys { (for $($t:ty),+) => { - $(impl CwIntKey for $t { + $(impl IntKey for $t { type Buf = [u8; mem::size_of::<$t>()]; #[inline] @@ -34,7 +33,7 @@ cw_uint_keys!(for u8, u16, u32, u64, u128); macro_rules! cw_int_keys { (for $($t:ty, $ut:ty),+) => { - $(impl CwIntKey for $t { + $(impl IntKey for $t { type Buf = [u8; mem::size_of::<$t>()]; #[inline] diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index e4240abb1..2fd90e446 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -2,7 +2,7 @@ use cosmwasm_std::Addr; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; -use crate::int_key::CwIntKey; +use crate::int_key::IntKey; #[derive(Debug)] pub enum Key<'a> { diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index ff8e508b9..9b5714994 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -26,7 +26,7 @@ pub use indexes::MultiIndex; pub use indexes::UniqueIndex; #[cfg(feature = "iterator")] pub use indexes::{index_string, index_string_tuple, index_triple, index_tuple, Index}; -pub use int_key::CwIntKey; +pub use int_key::IntKey; pub use item::Item; pub use keys::{Key, Prefixer, PrimaryKey}; pub use keys_old::IntKeyOld; diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 94d78bdcd..cf784902a 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -254,7 +254,7 @@ mod test { #[cfg(feature = "iterator")] use cosmwasm_std::{Order, StdResult}; - use crate::int_key::CwIntKey; + use crate::int_key::IntKey; use crate::keys_old::IntKeyOld; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 38e4b7c78..4b48c69c2 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -8,7 +8,7 @@ use std::ops::Deref; use crate::de::KeyDeserialize; use crate::helpers::{namespaces_with_key, nested_namespaces_with_key}; -use crate::int_key::CwIntKey; +use crate::int_key::IntKey; use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim}; use crate::keys::Key; use crate::{Endian, Prefixer}; @@ -35,12 +35,12 @@ impl Bound { } /// Turns an int, like Option into an inclusive bound - pub fn inclusive_int(limit: T) -> Self { + pub fn inclusive_int(limit: T) -> Self { Bound::Inclusive(limit.to_cw_bytes().into()) } /// Turns an int, like Option into an exclusive bound - pub fn exclusive_int(limit: T) -> Self { + pub fn exclusive_int(limit: T) -> Self { Bound::Exclusive(limit.to_cw_bytes().into()) } } From 142ced5a7f9403830ee6bc2ee7891dde1fc8c5e5 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Mon, 3 Jan 2022 14:42:39 +0100 Subject: [PATCH 136/352] Revert "Rename CwIntKey into IntKey" This reverts commit ac89c423ed6f83246ae9197bdce19551e2122a20. --- packages/storage-plus/benches/main.rs | 2 +- packages/storage-plus/src/de.rs | 2 +- packages/storage-plus/src/int_key.rs | 7 ++++--- packages/storage-plus/src/keys.rs | 2 +- packages/storage-plus/src/lib.rs | 2 +- packages/storage-plus/src/map.rs | 2 +- packages/storage-plus/src/prefix.rs | 6 +++--- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/storage-plus/benches/main.rs b/packages/storage-plus/benches/main.rs index 021deac65..cd02624c5 100644 --- a/packages/storage-plus/benches/main.rs +++ b/packages/storage-plus/benches/main.rs @@ -4,7 +4,7 @@ use rand::Rng; use std::mem; use std::time::Duration; -use cw_storage_plus::IntKey; +use cw_storage_plus::CwIntKey; fn bench_signed_int_key(c: &mut Criterion) { let mut group = c.benchmark_group("Signed int keys"); diff --git a/packages/storage-plus/src/de.rs b/packages/storage-plus/src/de.rs index 046d8b9cb..c1b13889f 100644 --- a/packages/storage-plus/src/de.rs +++ b/packages/storage-plus/src/de.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; use cosmwasm_std::{Addr, StdError, StdResult}; -use crate::int_key::IntKey; +use crate::int_key::CwIntKey; pub trait KeyDeserialize { type Output: Sized; diff --git a/packages/storage-plus/src/int_key.rs b/packages/storage-plus/src/int_key.rs index 0292674a2..7f7713369 100644 --- a/packages/storage-plus/src/int_key.rs +++ b/packages/storage-plus/src/int_key.rs @@ -4,7 +4,8 @@ use std::mem; /// but "sign-flipped" (xored msb) big-endian bytes for signed ints. /// /// So that the representation of signed integers is in the right lexicographical order. -pub trait IntKey: Sized + Copy { +// TODO: Rename to `IntKey` after deprecating current `IntKey` (https://github.com/CosmWasm/cw-plus/issues/570) +pub trait CwIntKey: Sized + Copy { type Buf: AsRef<[u8]> + AsMut<[u8]> + Into> + Default; fn to_cw_bytes(&self) -> Self::Buf; @@ -13,7 +14,7 @@ pub trait IntKey: Sized + Copy { macro_rules! cw_uint_keys { (for $($t:ty),+) => { - $(impl IntKey for $t { + $(impl CwIntKey for $t { type Buf = [u8; mem::size_of::<$t>()]; #[inline] @@ -33,7 +34,7 @@ cw_uint_keys!(for u8, u16, u32, u64, u128); macro_rules! cw_int_keys { (for $($t:ty, $ut:ty),+) => { - $(impl IntKey for $t { + $(impl CwIntKey for $t { type Buf = [u8; mem::size_of::<$t>()]; #[inline] diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index 2fd90e446..e4240abb1 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -2,7 +2,7 @@ use cosmwasm_std::Addr; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; -use crate::int_key::IntKey; +use crate::int_key::CwIntKey; #[derive(Debug)] pub enum Key<'a> { diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 9b5714994..ff8e508b9 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -26,7 +26,7 @@ pub use indexes::MultiIndex; pub use indexes::UniqueIndex; #[cfg(feature = "iterator")] pub use indexes::{index_string, index_string_tuple, index_triple, index_tuple, Index}; -pub use int_key::IntKey; +pub use int_key::CwIntKey; pub use item::Item; pub use keys::{Key, Prefixer, PrimaryKey}; pub use keys_old::IntKeyOld; diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index cf784902a..94d78bdcd 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -254,7 +254,7 @@ mod test { #[cfg(feature = "iterator")] use cosmwasm_std::{Order, StdResult}; - use crate::int_key::IntKey; + use crate::int_key::CwIntKey; use crate::keys_old::IntKeyOld; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 4b48c69c2..38e4b7c78 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -8,7 +8,7 @@ use std::ops::Deref; use crate::de::KeyDeserialize; use crate::helpers::{namespaces_with_key, nested_namespaces_with_key}; -use crate::int_key::IntKey; +use crate::int_key::CwIntKey; use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim}; use crate::keys::Key; use crate::{Endian, Prefixer}; @@ -35,12 +35,12 @@ impl Bound { } /// Turns an int, like Option into an inclusive bound - pub fn inclusive_int(limit: T) -> Self { + pub fn inclusive_int(limit: T) -> Self { Bound::Inclusive(limit.to_cw_bytes().into()) } /// Turns an int, like Option into an exclusive bound - pub fn exclusive_int(limit: T) -> Self { + pub fn exclusive_int(limit: T) -> Self { Bound::Exclusive(limit.to_cw_bytes().into()) } } From 582e47e4a251b050e3de5977e90feafaa05ef5ca Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Mon, 3 Jan 2022 19:09:56 +0100 Subject: [PATCH 137/352] multitest: add a contract that tests WasmMsg calls --- packages/multi-test/src/contracts.rs | 2 +- .../multi-test/src/test_helpers/contracts.rs | 1 + .../src/test_helpers/contracts/caller.rs | 40 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 packages/multi-test/src/test_helpers/contracts/caller.rs diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index bf88b1158..8aca6173b 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -342,7 +342,7 @@ where (self.execute_fn)(deps, env, info.clone(), msg.clone()) .map_err(|err| anyhow!("{}", err)) .context(format!( - r#"Contract returned an error on execute + r#"aContract returned an error on execute Contract address: {} Message sender: {} Funds: {:?} diff --git a/packages/multi-test/src/test_helpers/contracts.rs b/packages/multi-test/src/test_helpers/contracts.rs index 8be3e8674..68babbf84 100644 --- a/packages/multi-test/src/test_helpers/contracts.rs +++ b/packages/multi-test/src/test_helpers/contracts.rs @@ -1,5 +1,6 @@ //! Module for simple contracts to be used in tests +pub mod caller; pub mod echo; pub mod error; pub mod hackatom; diff --git a/packages/multi-test/src/test_helpers/contracts/caller.rs b/packages/multi-test/src/test_helpers/contracts/caller.rs new file mode 100644 index 000000000..92367a3de --- /dev/null +++ b/packages/multi-test/src/test_helpers/contracts/caller.rs @@ -0,0 +1,40 @@ +use std::fmt; + +use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, SubMsg, WasmMsg}; +use schemars::JsonSchema; + +use crate::{test_helpers::EmptyMsg, Contract, ContractWrapper}; + +fn instantiate( + _deps: DepsMut, + _env: Env, + _info: MessageInfo, + _msg: EmptyMsg, +) -> Result { + Ok(Response::default()) +} + +fn execute( + _deps: DepsMut, + _env: Env, + _info: MessageInfo, + msg: WasmMsg, +) -> Result { + let message = SubMsg::new(msg); + + Ok(Response::new().add_submessage(message)) +} + +fn query(_deps: Deps, _env: Env, _msg: EmptyMsg) -> Result { + Err(StdError::generic_err( + "query not implemented for the `caller` contract", + )) +} + +pub fn contract() -> Box> +where + C: Clone + fmt::Debug + PartialEq + JsonSchema + 'static, +{ + let contract = ContractWrapper::new_with_empty(execute, instantiate, query); + Box::new(contract) +} From 0291e82f1ffde063cdbd1917fe8a392eab690755 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 4 Jan 2022 11:22:36 +0100 Subject: [PATCH 138/352] multitest: add tests for contract errors --- packages/multi-test/src/app.rs | 132 +++++++++++++++++- packages/multi-test/src/contracts.rs | 7 +- .../src/test_helpers/contracts/error.rs | 19 ++- packages/multi-test/src/wasm.rs | 2 +- 4 files changed, 152 insertions(+), 8 deletions(-) diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index 7af9792e2..01a1ddfa4 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -947,7 +947,7 @@ mod test { }; use crate::error::Error; - use crate::test_helpers::contracts::{echo, hackatom, payout, reflect}; + use crate::test_helpers::contracts::{caller, echo, error, hackatom, payout, reflect}; use crate::test_helpers::{CustomMsg, EmptyMsg}; use crate::transactions::StorageTransaction; @@ -2580,4 +2580,134 @@ mod test { assert_eq!(exec_res.data, Some(Binary::from(b"hello"))); } } + + mod errors { + use super::*; + + #[test] + fn simple_call() { + let owner = Addr::unchecked("owner"); + let mut app = App::default(); + + // set up contract + let code_id = app.store_code(error::contract(true)); + let msg = EmptyMsg {}; + let contract_addr = app + .instantiate_contract(code_id, owner, &msg, &[], "error", None) + .unwrap(); + + // execute should error + let err = app + .execute_contract(Addr::unchecked("random"), contract_addr.clone(), &msg, &[]) + .unwrap_err(); + let source: &StdError = err.downcast_ref().unwrap(); + if let StdError::GenericErr { msg } = source { + assert_eq!(msg, "Handle failed"); + } else { + panic!("wrong StdError variant"); + } + } + + // #[test] + // fn simple_call_gives_one_context_layer() { + // let owner = Addr::unchecked("owner"); + // let mut app = App::default(); + + // let error_code_id = app.store_code(error::contract(true)); + + // // set up contract + // let msg = EmptyMsg {}; + // let error_addr = app + // .instantiate_contract(error_code_id, owner, &msg, &[], "error", None) + // .unwrap(); + + // // execute should error + // let err = app + // .execute_contract(Addr::unchecked("random"), error_addr.clone(), &msg, &[]) + // .unwrap(); + // //let source = err.source().unwrap(); + // //let foo: &StdError = source.downcast_ref().unwrap(); + // //assert_eq!(source.to_string(), "aContract returned an error on execute\nContract address: Contract #0\nMessage sender: random\nFunds: []\nMessage dump:\nEmptyMsg\n"); + // } + + #[test] + fn nested_call() { + let owner = Addr::unchecked("owner"); + let mut app = App::default(); + + let error_code_id = app.store_code(error::contract(true)); + let caller_code_id = app.store_code(caller::contract()); + + // set up contracts + let msg = EmptyMsg {}; + let caller_addr = app + .instantiate_contract(caller_code_id, owner.clone(), &msg, &[], "caller", None) + .unwrap(); + let error_addr = app + .instantiate_contract(error_code_id, owner, &msg, &[], "error", None) + .unwrap(); + + // execute should error + let msg = WasmMsg::Execute { + contract_addr: error_addr.into(), + msg: to_binary(&EmptyMsg {}).unwrap(), + funds: vec![], + }; + let err = app + .execute_contract(Addr::unchecked("random"), caller_addr.clone(), &msg, &[]) + .unwrap_err(); + + // we can downcast to get the original error + let source: &StdError = err.downcast_ref().unwrap(); + if let StdError::GenericErr { msg } = source { + assert_eq!(msg, "Handle failed"); + } else { + panic!("wrong StdError variant"); + } + } + + #[test] + fn double_nested_call() { + let owner = Addr::unchecked("owner"); + let mut app = App::default(); + + let error_code_id = app.store_code(error::contract(true)); + let caller_code_id = app.store_code(caller::contract()); + + // set up contracts + let msg = EmptyMsg {}; + let caller_addr1 = app + .instantiate_contract(caller_code_id, owner.clone(), &msg, &[], "caller", None) + .unwrap(); + let caller_addr2 = app + .instantiate_contract(caller_code_id, owner.clone(), &msg, &[], "caller", None) + .unwrap(); + let error_addr = app + .instantiate_contract(error_code_id, owner, &msg, &[], "error", None) + .unwrap(); + + // caller1 calls caller2, caller2 calls error + let msg = WasmMsg::Execute { + contract_addr: caller_addr2.into(), + msg: to_binary(&WasmMsg::Execute { + contract_addr: error_addr.into(), + msg: to_binary(&EmptyMsg {}).unwrap(), + funds: vec![], + }) + .unwrap(), + funds: vec![], + }; + let err = app + .execute_contract(Addr::unchecked("random"), caller_addr1.clone(), &msg, &[]) + .unwrap_err(); + + // we can downcast to get the original error + let source: &StdError = err.downcast_ref().unwrap(); + if let StdError::GenericErr { msg } = source { + assert_eq!(msg, "Handle failed"); + } else { + panic!("wrong StdError variant"); + } + } + } } diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index 8aca6173b..39101245b 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -1,5 +1,6 @@ use schemars::JsonSchema; use serde::de::DeserializeOwned; +use std::error::Error; use std::fmt::{self, Debug, Display}; use cosmwasm_std::{ @@ -322,7 +323,7 @@ where T3: DeserializeOwned, T4: DeserializeOwned, T6: DeserializeOwned, - E1: Display + Debug + Send + Sync + 'static, + E1: Display + Debug + Send + Sync + Error + 'static, E2: Display + Debug + Send + Sync + 'static, E3: Display + Debug + Send + Sync + 'static, E4: Display + Debug + Send + Sync + 'static, @@ -340,9 +341,9 @@ where let msg: T1 = from_slice(&msg)?; let address = env.contract.address.clone(); (self.execute_fn)(deps, env, info.clone(), msg.clone()) - .map_err(|err| anyhow!("{}", err)) + .map_err(|err| anyhow::Error::from(err)) .context(format!( - r#"aContract returned an error on execute + r#"Contract returned an error on execute Contract address: {} Message sender: {} Funds: {:?} diff --git a/packages/multi-test/src/test_helpers/contracts/error.rs b/packages/multi-test/src/test_helpers/contracts/error.rs index 710484aca..e707e80d6 100644 --- a/packages/multi-test/src/test_helpers/contracts/error.rs +++ b/packages/multi-test/src/test_helpers/contracts/error.rs @@ -5,7 +5,7 @@ use schemars::JsonSchema; use crate::{test_helpers::EmptyMsg, Contract, ContractWrapper}; -fn instantiate( +fn instantiate_err( _deps: DepsMut, _env: Env, _info: MessageInfo, @@ -14,6 +14,15 @@ fn instantiate( Err(StdError::generic_err("Init failed")) } +fn instantiate_ok( + _deps: DepsMut, + _env: Env, + _info: MessageInfo, + _msg: EmptyMsg, +) -> Result { + Ok(Response::default()) +} + fn execute( _deps: DepsMut, _env: Env, @@ -27,10 +36,14 @@ fn query(_deps: Deps, _env: Env, _msg: EmptyMsg) -> Result { Err(StdError::generic_err("Query failed")) } -pub fn contract() -> Box> +pub fn contract(instantiable: bool) -> Box> where C: Clone + fmt::Debug + PartialEq + JsonSchema + 'static, { - let contract = ContractWrapper::new_with_empty(execute, instantiate, query); + let contract = if instantiable { + ContractWrapper::new_with_empty(execute, instantiate_ok, query) + } else { + ContractWrapper::new_with_empty(execute, instantiate_err, query) + }; Box::new(contract) } diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index 1e1ef5872..a0b7c66c6 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -946,7 +946,7 @@ mod test { let mut wasm_storage = MockStorage::new(); let mut keeper = WasmKeeper::new(); let block = mock_env().block; - let code_id = keeper.store_code(error::contract()); + let code_id = keeper.store_code(error::contract(false)); transactional(&mut wasm_storage, |cache, _| { // cannot register contract with unregistered codeId From 2c90217e59945eef0c6a6f8fa6f53e6904e529f4 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 4 Jan 2022 15:05:53 +0100 Subject: [PATCH 139/352] multitest: handle nested error contexts properly --- packages/multi-test/src/app.rs | 36 +++++++++++----------------- packages/multi-test/src/contracts.rs | 11 ++------- packages/multi-test/src/executor.rs | 15 ++---------- packages/multi-test/src/wasm.rs | 13 +++++++--- 4 files changed, 28 insertions(+), 47 deletions(-) diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index 01a1ddfa4..25c50d312 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -2600,35 +2600,19 @@ mod test { let err = app .execute_contract(Addr::unchecked("random"), contract_addr.clone(), &msg, &[]) .unwrap_err(); + + // we should be able to retrieve the original error by downcasting let source: &StdError = err.downcast_ref().unwrap(); if let StdError::GenericErr { msg } = source { assert_eq!(msg, "Handle failed"); } else { panic!("wrong StdError variant"); } - } - - // #[test] - // fn simple_call_gives_one_context_layer() { - // let owner = Addr::unchecked("owner"); - // let mut app = App::default(); - - // let error_code_id = app.store_code(error::contract(true)); - // // set up contract - // let msg = EmptyMsg {}; - // let error_addr = app - // .instantiate_contract(error_code_id, owner, &msg, &[], "error", None) - // .unwrap(); - - // // execute should error - // let err = app - // .execute_contract(Addr::unchecked("random"), error_addr.clone(), &msg, &[]) - // .unwrap(); - // //let source = err.source().unwrap(); - // //let foo: &StdError = source.downcast_ref().unwrap(); - // //assert_eq!(source.to_string(), "aContract returned an error on execute\nContract address: Contract #0\nMessage sender: random\nFunds: []\nMessage dump:\nEmptyMsg\n"); - // } + // we're expecting exactly 3 wrapped errors + // (the original error, execute msg context, WasmMsg context) + assert_eq!(err.chain().count(), 3); + } #[test] fn nested_call() { @@ -2664,6 +2648,10 @@ mod test { } else { panic!("wrong StdError variant"); } + + // we're expecting exactly 4 wrapped errors + // (the original error, execute msg context, 2 WasmMsg contexts) + assert_eq!(err.chain().count(), 4); } #[test] @@ -2708,6 +2696,10 @@ mod test { } else { panic!("wrong StdError variant"); } + + // we're expecting exactly 5 wrapped errors + // (the original error, execute msg context, 3 WasmMsg contexts) + assert_eq!(err.chain().count(), 5); } } } diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index 39101245b..1cb04509c 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -339,18 +339,11 @@ where msg: Vec, ) -> AnyResult> { let msg: T1 = from_slice(&msg)?; - let address = env.contract.address.clone(); (self.execute_fn)(deps, env, info.clone(), msg.clone()) .map_err(|err| anyhow::Error::from(err)) .context(format!( - r#"Contract returned an error on execute -Contract address: {} -Message sender: {} -Funds: {:?} -Message dump: -{:?} -"#, - address, info.sender, info.funds, msg, + "Contract returned an error on execute msg:\n{:?}", + msg, )) } diff --git a/packages/multi-test/src/executor.rs b/packages/multi-test/src/executor.rs index 31fe75ee5..0ab199413 100644 --- a/packages/multi-test/src/executor.rs +++ b/packages/multi-test/src/executor.rs @@ -8,7 +8,7 @@ use schemars::JsonSchema; use serde::Serialize; use utils::{parse_execute_response_data, parse_instantiate_response_data}; -use anyhow::{Context, Result as AnyResult}; +use anyhow::Result as AnyResult; #[derive(Default, Clone, Debug)] pub struct AppResponse { @@ -111,18 +111,7 @@ where msg: binary_msg, funds: send_funds.to_vec(), }; - let mut res = self - .execute(sender.clone(), wrapped_msg.into()) - .context(format!( - r#"Contract returned an error on execute -Contract address: {} -Message sender: {} -Funds: {:?} -Message dump: -{:?} -"#, - contract_addr, sender, send_funds, msg, - ))?; + let mut res = self.execute(sender.clone(), wrapped_msg.into())?; res.data = res .data .and_then(|d| parse_execute_response_data(d.as_slice()).unwrap().data); diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index a0b7c66c6..542c485d0 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -23,7 +23,7 @@ use crate::executor::AppResponse; use crate::transactions::transactional; use cosmwasm_std::testing::mock_wasmd_attr; -use anyhow::{bail, Result as AnyResult}; +use anyhow::{bail, Context, Result as AnyResult}; // TODO: we should import this from cosmwasm-std, but cannot due to non_exhaustive so copy here #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] @@ -174,7 +174,11 @@ where sender: Addr, msg: WasmMsg, ) -> AnyResult { - self.execute_wasm(api, storage, router, block, sender, msg) + self.execute_wasm(api, storage, router, block, sender.clone(), msg.clone()) + .context(format!( + "error executing WasmMsg:\nsender: {}\n{:?}", + sender, msg + )) } fn sudo( @@ -297,7 +301,10 @@ where )?; // then call the contract - let info = MessageInfo { sender, funds }; + let info = MessageInfo { + sender: sender.clone(), + funds: funds.clone(), + }; let res = self.call_execute( api, storage, From 05cf44454d4f7f9220fa1913a6488c8c751db8b8 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 4 Jan 2022 15:43:41 +0100 Subject: [PATCH 140/352] clippy --- packages/multi-test/src/app.rs | 6 +++--- packages/multi-test/src/contracts.rs | 4 ++-- packages/multi-test/src/executor.rs | 2 +- packages/multi-test/src/wasm.rs | 5 +---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index 25c50d312..0f72cd698 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -2598,7 +2598,7 @@ mod test { // execute should error let err = app - .execute_contract(Addr::unchecked("random"), contract_addr.clone(), &msg, &[]) + .execute_contract(Addr::unchecked("random"), contract_addr, &msg, &[]) .unwrap_err(); // we should be able to retrieve the original error by downcasting @@ -2638,7 +2638,7 @@ mod test { funds: vec![], }; let err = app - .execute_contract(Addr::unchecked("random"), caller_addr.clone(), &msg, &[]) + .execute_contract(Addr::unchecked("random"), caller_addr, &msg, &[]) .unwrap_err(); // we can downcast to get the original error @@ -2686,7 +2686,7 @@ mod test { funds: vec![], }; let err = app - .execute_contract(Addr::unchecked("random"), caller_addr1.clone(), &msg, &[]) + .execute_contract(Addr::unchecked("random"), caller_addr1, &msg, &[]) .unwrap_err(); // we can downcast to get the original error diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index 1cb04509c..6c190a81c 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -339,8 +339,8 @@ where msg: Vec, ) -> AnyResult> { let msg: T1 = from_slice(&msg)?; - (self.execute_fn)(deps, env, info.clone(), msg.clone()) - .map_err(|err| anyhow::Error::from(err)) + (self.execute_fn)(deps, env, info, msg.clone()) + .map_err(anyhow::Error::from) .context(format!( "Contract returned an error on execute msg:\n{:?}", msg, diff --git a/packages/multi-test/src/executor.rs b/packages/multi-test/src/executor.rs index 0ab199413..53653ba02 100644 --- a/packages/multi-test/src/executor.rs +++ b/packages/multi-test/src/executor.rs @@ -111,7 +111,7 @@ where msg: binary_msg, funds: send_funds.to_vec(), }; - let mut res = self.execute(sender.clone(), wrapped_msg.into())?; + let mut res = self.execute(sender, wrapped_msg.into())?; res.data = res .data .and_then(|d| parse_execute_response_data(d.as_slice()).unwrap().data); diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index 542c485d0..56279925b 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -301,10 +301,7 @@ where )?; // then call the contract - let info = MessageInfo { - sender: sender.clone(), - funds: funds.clone(), - }; + let info = MessageInfo { sender, funds }; let res = self.call_execute( api, storage, From 3eb5e2d013c6f8a2aee0cf4a18f36e10755236fb Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 4 Jan 2022 15:50:06 +0100 Subject: [PATCH 141/352] multitest: test comments --- packages/multi-test/src/app.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index 0f72cd698..8827c7c55 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -2609,7 +2609,7 @@ mod test { panic!("wrong StdError variant"); } - // we're expecting exactly 3 wrapped errors + // we're expecting exactly 3 nested error types // (the original error, execute msg context, WasmMsg context) assert_eq!(err.chain().count(), 3); } @@ -2649,7 +2649,7 @@ mod test { panic!("wrong StdError variant"); } - // we're expecting exactly 4 wrapped errors + // we're expecting exactly 4 nested error types // (the original error, execute msg context, 2 WasmMsg contexts) assert_eq!(err.chain().count(), 4); } @@ -2689,6 +2689,9 @@ mod test { .execute_contract(Addr::unchecked("random"), caller_addr1, &msg, &[]) .unwrap_err(); + // uncomment to have the test fail and see how the error stringifies + // panic!("{:?}", err); + // we can downcast to get the original error let source: &StdError = err.downcast_ref().unwrap(); if let StdError::GenericErr { msg } = source { @@ -2697,7 +2700,7 @@ mod test { panic!("wrong StdError variant"); } - // we're expecting exactly 5 wrapped errors + // we're expecting exactly 5 nested error types // (the original error, execute msg context, 3 WasmMsg contexts) assert_eq!(err.chain().count(), 5); } From 708e572e1e200bd6b60312747de7cf0c6790f49b Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 4 Jan 2022 21:02:58 +0100 Subject: [PATCH 142/352] multitest: style --- packages/multi-test/src/executor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/multi-test/src/executor.rs b/packages/multi-test/src/executor.rs index c756653d4..b6eb341e1 100644 --- a/packages/multi-test/src/executor.rs +++ b/packages/multi-test/src/executor.rs @@ -107,7 +107,7 @@ where ) -> AnyResult { let binary_msg = to_binary(msg)?; let wrapped_msg = WasmMsg::Execute { - contract_addr: contract_addr.to_string(), + contract_addr: contract_addr.into_string(), msg: binary_msg, funds: send_funds.to_vec(), }; From ef50e4b96e505e3ee0ea9352352325b3707edadf Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 4 Jan 2022 21:17:56 +0100 Subject: [PATCH 143/352] multitest: context for queries and instantiations --- packages/multi-test/src/app.rs | 25 +++++++++++++++++++++++++ packages/multi-test/src/contracts.rs | 26 ++++++++++++++++++-------- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index 34dec22e8..326d54587 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -2584,6 +2584,31 @@ mod test { mod errors { use super::*; + #[test] + fn simple_instantiation() { + let owner = Addr::unchecked("owner"); + let mut app = App::default(); + + // set up contract + let code_id = app.store_code(error::contract(false)); + let msg = EmptyMsg {}; + let err = app + .instantiate_contract(code_id, owner, &msg, &[], "error", None) + .unwrap_err(); + + // we should be able to retrieve the original error by downcasting + let source: &StdError = err.downcast_ref().unwrap(); + if let StdError::GenericErr { msg } = source { + assert_eq!(msg, "Init failed"); + } else { + panic!("wrong StdError variant"); + } + + // we're expecting exactly 3 nested error types + // (the original error, initiate msg context, WasmMsg context) + assert_eq!(err.chain().count(), 3); + } + #[test] fn simple_call() { let owner = Addr::unchecked("owner"); diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index 6c190a81c..e703b75a8 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -319,13 +319,13 @@ impl Contract for ContractWrapper where T1: DeserializeOwned + Debug + Clone, - T2: DeserializeOwned, - T3: DeserializeOwned, + T2: DeserializeOwned + Debug + Clone, + T3: DeserializeOwned + Debug + Clone, T4: DeserializeOwned, T6: DeserializeOwned, E1: Display + Debug + Send + Sync + Error + 'static, - E2: Display + Debug + Send + Sync + 'static, - E3: Display + Debug + Send + Sync + 'static, + E2: Display + Debug + Send + Sync + Error + 'static, + E3: Display + Debug + Send + Sync + Error + 'static, E4: Display + Debug + Send + Sync + 'static, E5: Display + Debug + Send + Sync + 'static, E6: Display + Debug + Send + Sync + 'static, @@ -354,13 +354,23 @@ where info: MessageInfo, msg: Vec, ) -> AnyResult> { - let msg = from_slice(&msg)?; - (self.instantiate_fn)(deps, env, info, msg).map_err(|err| anyhow!(err)) + let msg: T2 = from_slice(&msg)?; + (self.instantiate_fn)(deps, env, info, msg.clone()) + .map_err(anyhow::Error::from) + .context(format!( + "Contract returned an error on instantiate msg:\n{:?}", + msg, + )) } fn query(&self, deps: Deps, env: Env, msg: Vec) -> AnyResult { - let msg = from_slice(&msg)?; - (self.query_fn)(deps, env, msg).map_err(|err| anyhow!(err)) + let msg: T3 = from_slice(&msg)?; + (self.query_fn)(deps, env, msg.clone()) + .map_err(anyhow::Error::from) + .context(format!( + "Contract returned an error on query msg:\n{:?}", + msg, + )) } // this returns an error if the contract doesn't implement sudo From ede69a5714a0c0be6faf22867179fd577415d770 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 4 Jan 2022 21:33:44 +0100 Subject: [PATCH 144/352] cw1-whitelist: missing InstantiateMsg derives --- contracts/cw1-whitelist/src/msg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw1-whitelist/src/msg.rs b/contracts/cw1-whitelist/src/msg.rs index f0c4f04c1..bdfb6d2f5 100644 --- a/contracts/cw1-whitelist/src/msg.rs +++ b/contracts/cw1-whitelist/src/msg.rs @@ -4,7 +4,7 @@ use std::fmt; use cosmwasm_std::{CosmosMsg, Empty}; -#[derive(Serialize, Deserialize, JsonSchema)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct InstantiateMsg { pub admins: Vec, pub mutable: bool, From 4bba3a5fb7965a670c0928dee25d3243cb2a15c0 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 4 Jan 2022 10:12:08 +0100 Subject: [PATCH 145/352] Publish snapshot map changelog --- packages/storage-plus/src/snapshot/map.rs | 6 +++++- packages/storage-plus/src/snapshot/mod.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index ef1d572b4..e8365fa57 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -9,7 +9,7 @@ use crate::keys::PrimaryKey; use crate::map::Map; use crate::path::Path; use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound}; -use crate::snapshot::Snapshot; +use crate::snapshot::{ChangeSet, Snapshot}; use crate::{Bound, Prefixer, Strategy}; /// Map that maintains a snapshots of one or more checkpoints. @@ -44,6 +44,10 @@ impl<'a, K, T> SnapshotMap<'a, K, T> { snapshots: Snapshot::new(checkpoints, changelog, strategy), } } + + pub fn changelog(&self) -> &Map<'a, (K, u64), ChangeSet> { + &self.snapshots.changelog + } } impl<'a, K, T> SnapshotMap<'a, K, T> diff --git a/packages/storage-plus/src/snapshot/mod.rs b/packages/storage-plus/src/snapshot/mod.rs index c20fe2e8d..889f1fad6 100644 --- a/packages/storage-plus/src/snapshot/mod.rs +++ b/packages/storage-plus/src/snapshot/mod.rs @@ -172,7 +172,7 @@ pub enum Strategy { } #[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)] -pub(crate) struct ChangeSet { +pub struct ChangeSet { pub old: Option, } From 72a838d75eaec1738e66b43d4c72ed1b670d71e6 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 4 Jan 2022 12:18:34 +0100 Subject: [PATCH 146/352] Add changelog iterator tests --- packages/storage-plus/src/snapshot/map.rs | 64 +++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index e8365fa57..64a042da4 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -462,6 +462,70 @@ mod tests { ); } + #[test] + #[cfg(feature = "iterator")] + fn changelog_range_works() { + use cosmwasm_std::Order; + + let mut store = MockStorage::new(); + + // simple data for testing + EVERY.save(&mut store, "A", &5, 1).unwrap(); + EVERY.save(&mut store, "B", &7, 2).unwrap(); + EVERY + .update(&mut store, "A", 3, |_| -> StdResult { Ok(8) }) + .unwrap(); + EVERY.remove(&mut store, "B", 4).unwrap(); + + // let's try to iterate over the changelog + let all: StdResult> = EVERY + .changelog() + .range(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(4, all.len()); + assert_eq!( + all, + vec![ + (("A".into(), 1), ChangeSet { old: None }), + (("A".into(), 3), ChangeSet { old: Some(5) }), + (("B".into(), 2), ChangeSet { old: None }), + (("B".into(), 4), ChangeSet { old: Some(7) }) + ] + ); + + // let's try to iterate over a changelog key/prefix + let all: StdResult> = EVERY + .changelog() + .prefix("B") + .range(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(2, all.len()); + assert_eq!( + all, + vec![ + (2, ChangeSet { old: None }), + (4, ChangeSet { old: Some(7) }) + ] + ); + + // let's try to iterate over a changelog prefixed range + let all: StdResult> = EVERY + .changelog() + .prefix("A") + .range( + &store, + Some(Bound::inclusive_int(3u64)), + None, + Order::Ascending, + ) + .collect(); + let all = all.unwrap(); + assert_eq!(1, all.len()); + assert_eq!(all, vec![(3, ChangeSet { old: Some(5) }),]); + } + #[test] #[cfg(feature = "iterator")] fn range_simple_string_key() { From 1f7599cbf8ccb9e60456a268c2855be56f5b6d7e Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 4 Jan 2022 15:55:30 +0100 Subject: [PATCH 147/352] Move namespace() method to right trait (un)bounded scope --- packages/storage-plus/src/map.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 94d78bdcd..45a89c294 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -31,6 +31,10 @@ impl<'a, K, T> Map<'a, K, T> { key_type: PhantomData, } } + + pub fn namespace(&self) -> &'a [u8] { + self.namespace + } } impl<'a, K, T> Map<'a, K, T> @@ -38,10 +42,6 @@ where T: Serialize + DeserializeOwned, K: PrimaryKey<'a>, { - pub fn namespace(&self) -> &'a [u8] { - self.namespace - } - pub fn key(&self, k: K) -> Path { Path::new( self.namespace, From c5982901ce14f23a00f3a3fa8cad230f928606f4 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 4 Jan 2022 16:00:24 +0100 Subject: [PATCH 148/352] Publish snapshot item changelog --- packages/storage-plus/src/snapshot/item.rs | 58 +++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/snapshot/item.rs b/packages/storage-plus/src/snapshot/item.rs index 58dcf9707..6dfa12550 100644 --- a/packages/storage-plus/src/snapshot/item.rs +++ b/packages/storage-plus/src/snapshot/item.rs @@ -3,8 +3,9 @@ use serde::Serialize; use cosmwasm_std::{StdError, StdResult, Storage}; -use crate::snapshot::Snapshot; -use crate::{Item, Strategy}; +use crate::snapshot::{ChangeSet, Snapshot}; +use crate::{Item, Map, Strategy}; +use std::str::from_utf8_unchecked; /// Item that maintains a snapshot of one or more checkpoints. /// We can query historical data as well as current state. @@ -45,6 +46,11 @@ impl<'a, T> SnapshotItem<'a, T> { pub fn remove_checkpoint(&self, store: &mut dyn Storage, height: u64) -> StdResult<()> { self.snapshots.remove_checkpoint(store, height) } + + pub fn changelog(&self) -> Map> { + // Build and return a compatible Map with the proper key type + Map::new(unsafe { from_utf8_unchecked(self.snapshots.changelog.namespace()) }) + } } impl<'a, T> SnapshotItem<'a, T> @@ -272,4 +278,52 @@ mod tests { assert_eq!(None, EVERY.may_load_at_height(&storage, 5).unwrap()); assert_eq!(Some(2), EVERY.may_load_at_height(&storage, 6).unwrap()); } + + #[test] + #[cfg(feature = "iterator")] + fn changelog_range_works() { + use crate::Bound; + use cosmwasm_std::Order; + + let mut store = MockStorage::new(); + + // simple data for testing + EVERY.save(&mut store, &5, 1u64).unwrap(); + EVERY.save(&mut store, &7, 2u64).unwrap(); + EVERY + .update(&mut store, 3u64, |_| -> StdResult { Ok(8) }) + .unwrap(); + EVERY.remove(&mut store, 4u64).unwrap(); + + // let's try to iterate over the changelog + let all: StdResult> = EVERY + .changelog() + .range(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(4, all.len()); + assert_eq!( + all, + vec![ + (1, ChangeSet { old: None }), + (2, ChangeSet { old: Some(5) }), + (3, ChangeSet { old: Some(7) }), + (4, ChangeSet { old: Some(8) }) + ] + ); + + // let's try to iterate over a changelog range + let all: StdResult> = EVERY + .changelog() + .range( + &store, + Some(Bound::exclusive_int(3u64)), + None, + Order::Ascending, + ) + .collect(); + let all = all.unwrap(); + assert_eq!(1, all.len()); + assert_eq!(all, vec![(4, ChangeSet { old: Some(8) }),]); + } } From 164325328af104cda334f14c010616fe4564f390 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 4 Jan 2022 16:05:35 +0100 Subject: [PATCH 149/352] Publish indexed snapshot map changelog as well --- packages/storage-plus/src/indexed_snapshot.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 7b2eb7b82..5ed1d3dda 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -9,8 +9,8 @@ use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::keys::{Prefixer, PrimaryKey}; use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; -use crate::snapshot::SnapshotMap; -use crate::{IndexList, Path, Strategy}; +use crate::snapshot::{ChangeSet, SnapshotMap}; +use crate::{IndexList, Map, Path, Strategy}; /// `IndexedSnapshotMap` works like a `SnapshotMap` but has a secondary index pub struct IndexedSnapshotMap<'a, K, T, I> { @@ -56,6 +56,10 @@ impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I> { idx: indexes, } } + + pub fn changelog(&self) -> &Map<'a, (K, u64), ChangeSet> { + &self.primary.changelog() + } } impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I> From 9c8954be62395b636ae8cf8e4c1bfdbf4f912ced Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 4 Jan 2022 16:21:24 +0100 Subject: [PATCH 150/352] Add indexed snapshot map changelog tests --- packages/storage-plus/src/indexed_snapshot.rs | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 5ed1d3dda..8476572bd 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -611,6 +611,65 @@ mod test { assert_eq!(marias[1].1, data1); } + #[test] + fn changelog_range_works() { + let mut store = MockStorage::new(); + let map = build_snapshot_map(); + let mut height = 1; + + // simple data for testing + // EVERY.remove(&mut store, "B", 4).unwrap(); + let data1 = Data { + name: "Maria".to_string(), + last_name: "".to_string(), + age: 42, + }; + let pk_a = "A"; + map.save(&mut store, pk_a, &data1, height).unwrap(); + height += 1; + + let data2 = Data { + name: "Juan".to_string(), + last_name: "Perez".to_string(), + age: 13, + }; + let pk_b = "B"; + map.save(&mut store, pk_b, &data2, height).unwrap(); + height += 1; + + let data3 = Data { + name: "Maria".to_string(), + last_name: "Williams".to_string(), + age: 24, + }; + map.update(&mut store, pk_a, height, |_| -> StdResult { + Ok(data3) + }) + .unwrap(); + + height += 1; + map.remove(&mut store, pk_b, height).unwrap(); + + let changes: Vec<_> = map + .changelog() + .range(&store, None, None, Order::Ascending) + .collect::>() + .unwrap(); + let count = changes.len(); + assert_eq!(4, count); + + // sorted by ascending key, height + assert_eq!( + changes, + vec![ + (("A".into(), 1), ChangeSet { old: None }), + (("A".into(), 3), ChangeSet { old: Some(data1) }), + (("B".into(), 2), ChangeSet { old: None }), + (("B".into(), 4), ChangeSet { old: Some(data2) }) + ] + ); + } + #[test] fn range_raw_composite_key_by_multi_index() { let mut store = MockStorage::new(); From a797917dc01844f4c85c62f14ac83edc87e8c978 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 5 Jan 2022 08:33:15 +0100 Subject: [PATCH 151/352] Store changelog namespace ref to avoid re-conversion --- packages/storage-plus/src/snapshot/item.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/snapshot/item.rs b/packages/storage-plus/src/snapshot/item.rs index 6dfa12550..3cf9bfa0a 100644 --- a/packages/storage-plus/src/snapshot/item.rs +++ b/packages/storage-plus/src/snapshot/item.rs @@ -5,13 +5,13 @@ use cosmwasm_std::{StdError, StdResult, Storage}; use crate::snapshot::{ChangeSet, Snapshot}; use crate::{Item, Map, Strategy}; -use std::str::from_utf8_unchecked; /// Item that maintains a snapshot of one or more checkpoints. /// We can query historical data as well as current state. /// What data is snapshotted depends on the Strategy. pub struct SnapshotItem<'a, T> { primary: Item<'a, T>, + changelog_namespace: &'a str, snapshots: Snapshot<'a, (), T>, } @@ -35,6 +35,7 @@ impl<'a, T> SnapshotItem<'a, T> { ) -> Self { SnapshotItem { primary: Item::new(storage_key), + changelog_namespace: changelog, snapshots: Snapshot::new(checkpoints, changelog, strategy), } } @@ -49,7 +50,7 @@ impl<'a, T> SnapshotItem<'a, T> { pub fn changelog(&self) -> Map> { // Build and return a compatible Map with the proper key type - Map::new(unsafe { from_utf8_unchecked(self.snapshots.changelog.namespace()) }) + Map::new(self.changelog_namespace) } } From 19d7bd9f84aaca7e736aa3eaf1f6d8ac9cbf50ec Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 5 Jan 2022 11:02:37 +0100 Subject: [PATCH 152/352] New SECURITY.md refering to wasmd --- SECURITY.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..1b10ff8e5 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,18 @@ +# Security Policy + +## Supported Versions + +cw-plus is still pre v1.0. A best effort has been made that the contracts here are secure, and we have moved the more +experimental contracts into community repositories like [cw-nfts](https://github.com/CosmWasm/cw-nfts) and +[cw-tokens](https://github.com/CosmWasm/cw-tokens). That said, we have not done an audit on them (formal or informal) +and you can use them at your own risk. We highly suggest doing your own audit on any contract you plan to deploy +with significant token value, and please inform us if it detects any issues so we can upstream them. + +Until v1.0 APIs are subject to change. The contracts APIs are pretty much stable, most work is currently +in `storage-plus` and `multi-test`. + +## Reporting a Vulnerability + +We have a [unified security policy](https://github.com/CosmWasm/wasmd/blob/master/SECURITY.md) +for all CosmWasm-related repositories maintained by Confio. +You can [read it here](https://github.com/CosmWasm/wasmd/blob/master/SECURITY.md) From f9f87dbefa1e9a5ff236329c642e74487fb64c94 Mon Sep 17 00:00:00 2001 From: Josef Richter Date: Mon, 17 Jan 2022 15:02:01 +0100 Subject: [PATCH 153/352] Create README.md fix a typo "sue" -> "use" (or maybe it was supposed to be "see"?) --- packages/storage-plus/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/README.md b/packages/storage-plus/README.md index 8fe31abff..214228bd5 100644 --- a/packages/storage-plus/README.md +++ b/packages/storage-plus/README.md @@ -409,7 +409,7 @@ fn demo() -> StdResult<()> { ## IndexedMap -Let's sue one example of `IndexedMap` definition and usage, originally taken from the `cw721-base` contract. +Let's use one example of `IndexedMap` definition and usage, originally taken from the `cw721-base` contract. ### Definition From 2c0f9851f123004139d5fb1f1a843a1f4c77b525 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sat, 15 Jan 2022 15:12:45 +0100 Subject: [PATCH 154/352] Add allowlist and govcontract to init --- contracts/cw20-ics20/src/contract.rs | 26 +++++++++++++++++++++--- contracts/cw20-ics20/src/msg.rs | 12 +++++++++++ contracts/cw20-ics20/src/state.rs | 17 ++++++++++++---- contracts/cw20-ics20/src/test_helpers.rs | 2 ++ 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index fc4ffb7e6..ecc35fb2b 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -12,10 +12,10 @@ use crate::amount::Amount; use crate::error::ContractError; use crate::ibc::Ics20Packet; use crate::msg::{ - ChannelResponse, ExecuteMsg, InitMsg, ListChannelsResponse, MigrateMsg, PortResponse, QueryMsg, - TransferMsg, + AllowMsg, ChannelResponse, ExecuteMsg, InitMsg, ListChannelsResponse, MigrateMsg, PortResponse, + QueryMsg, TransferMsg, }; -use crate::state::{Config, CHANNEL_INFO, CHANNEL_STATE, CONFIG}; +use crate::state::{AllowInfo, Config, ALLOW_LIST, CHANNEL_INFO, CHANNEL_STATE, CONFIG}; use cw_utils::{nonpayable, one_coin}; // version info for migration info @@ -32,8 +32,18 @@ pub fn instantiate( set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; let cfg = Config { default_timeout: msg.default_timeout, + gov_contract: deps.api.addr_validate(&msg.gov_contract)?, }; CONFIG.save(deps.storage, &cfg)?; + + // add all allows + for allowed in msg.allowlist { + let contract = deps.api.addr_validate(&allowed.contract)?; + let info = AllowInfo { + gas_limit: allowed.gas_limit, + }; + ALLOW_LIST.save(deps.storage, &contract, &info)?; + } Ok(Response::default()) } @@ -50,6 +60,7 @@ pub fn execute( let coin = one_coin(&info)?; execute_transfer(deps, env, msg, Amount::Native(coin), info.sender) } + ExecuteMsg::Allow(allow) => execute_allow(deps, env, info, allow), } } @@ -124,6 +135,15 @@ pub fn execute_transfer( Ok(res) } +pub fn execute_allow( + _deps: DepsMut, + _env: Env, + _info: MessageInfo, + _allow: AllowMsg, +) -> Result { + unimplemented!() +} + #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { let version = get_contract_version(deps.storage)?; diff --git a/contracts/cw20-ics20/src/msg.rs b/contracts/cw20-ics20/src/msg.rs index afa0c6259..39fa6fdd8 100644 --- a/contracts/cw20-ics20/src/msg.rs +++ b/contracts/cw20-ics20/src/msg.rs @@ -10,6 +10,16 @@ use crate::state::ChannelInfo; pub struct InitMsg { /// Default timeout for ics20 packets, specified in seconds pub default_timeout: u64, + /// who can allow more contracts + pub gov_contract: String, + /// initial allowlist - all cw20 tokens we will send must be previously allowed by governance + pub allowlist: Vec, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct AllowMsg { + pub contract: String, + pub gas_limit: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)] @@ -22,6 +32,8 @@ pub enum ExecuteMsg { Receive(Cw20ReceiveMsg), /// This allows us to transfer *exactly one* native token Transfer(TransferMsg), + /// This must be called by gov_contract, will allow a new cw20 token to be sent + Allow(AllowMsg), } /// This is the message we accept via Receive diff --git a/contracts/cw20-ics20/src/state.rs b/contracts/cw20-ics20/src/state.rs index 1b1af2b52..b87307a65 100644 --- a/contracts/cw20-ics20/src/state.rs +++ b/contracts/cw20-ics20/src/state.rs @@ -1,26 +1,30 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{IbcEndpoint, Uint128}; +use cosmwasm_std::{Addr, IbcEndpoint, Uint128}; use cw_storage_plus::{Item, Map}; pub const CONFIG: Item = Item::new("ics20_config"); -// static info on one channel that doesn't change +/// static info on one channel that doesn't change pub const CHANNEL_INFO: Map<&str, ChannelInfo> = Map::new("channel_info"); -// indexed by (channel_id, denom) maintaining the balance of the channel in that currency +/// indexed by (channel_id, denom) maintaining the balance of the channel in that currency pub const CHANNEL_STATE: Map<(&str, &str), ChannelState> = Map::new("channel_state"); +/// Every cw20 contract we allow to be sent is stored here, possibly with a gas_limit +pub const ALLOW_LIST: Map<&Addr, AllowInfo> = Map::new("allow_list"); + #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] pub struct ChannelState { pub outstanding: Uint128, pub total_sent: Uint128, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { pub default_timeout: u64, + pub gov_contract: Addr, } #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] @@ -32,3 +36,8 @@ pub struct ChannelInfo { /// the connection this exists on (you can use to query client/consensus info) pub connection_id: String, } + +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct AllowInfo { + pub gas_limit: Option, +} diff --git a/contracts/cw20-ics20/src/test_helpers.rs b/contracts/cw20-ics20/src/test_helpers.rs index 501d6af0b..1dad4a7ca 100644 --- a/contracts/cw20-ics20/src/test_helpers.rs +++ b/contracts/cw20-ics20/src/test_helpers.rs @@ -60,6 +60,8 @@ pub fn setup(channels: &[&str]) -> OwnedDeps // instantiate an empty contract let instantiate_msg = InitMsg { default_timeout: DEFAULT_TIMEOUT, + gov_contract: "gov".to_string(), + allowlist: vec![], }; let info = mock_info(&String::from("anyone"), &[]); let res = instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); From ba811c0b42028591e926389665624fc7c6f60889 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sat, 15 Jan 2022 15:24:54 +0100 Subject: [PATCH 155/352] Implement execute_allow --- contracts/cw20-ics20/src/contract.rs | 45 ++++++++++++++++++++++++---- contracts/cw20-ics20/src/error.rs | 6 ++++ 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index ecc35fb2b..2ffdfcd2b 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -1,8 +1,8 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_binary, to_binary, Addr, Binary, Deps, DepsMut, Env, IbcMsg, IbcQuery, MessageInfo, Order, - PortIdResponse, Response, StdResult, + ensure_eq, from_binary, to_binary, Addr, Binary, Deps, DepsMut, Env, IbcMsg, IbcQuery, + MessageInfo, Order, PortIdResponse, Response, StdResult, }; use cw2::{get_contract_version, set_contract_version}; @@ -135,13 +135,46 @@ pub fn execute_transfer( Ok(res) } +/// The gov contract can allow new contracts, or increase the gas limit on existing contracts. +/// It cannot block or reduce the limit to avoid forcible sticking tokens in the channel. pub fn execute_allow( - _deps: DepsMut, + deps: DepsMut, _env: Env, - _info: MessageInfo, - _allow: AllowMsg, + info: MessageInfo, + allow: AllowMsg, ) -> Result { - unimplemented!() + let cfg = CONFIG.load(deps.storage)?; + ensure_eq!(info.sender, cfg.gov_contract, ContractError::Unauthorized); + + let contract = deps.api.addr_validate(&allow.contract)?; + let set = AllowInfo { + gas_limit: allow.gas_limit, + }; + ALLOW_LIST.update(deps.storage, &contract, |old| { + if let Some(old) = old { + // we must ensure it increases the limit + match (old.gas_limit, set.gas_limit) { + (None, Some(_)) => return Err(ContractError::CannotLowerGas), + (Some(old), Some(new)) if new < old => return Err(ContractError::CannotLowerGas), + _ => {} + }; + } + Ok(AllowInfo { + gas_limit: allow.gas_limit, + }) + })?; + + let gas = if let Some(gas) = allow.gas_limit { + gas.to_string() + } else { + "None".to_string() + }; + + let res = Response::new() + .add_attribute("action", "allow") + .add_attribute("contract", allow.contract) + .add_attribute("gas_limit", gas); + Ok(res) } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/cw20-ics20/src/error.rs b/contracts/cw20-ics20/src/error.rs index c20a0b4d5..78b11ac75 100644 --- a/contracts/cw20-ics20/src/error.rs +++ b/contracts/cw20-ics20/src/error.rs @@ -49,6 +49,12 @@ pub enum ContractError { #[error("Got a submessage reply with unknown id: {id}")] UnknownReplyId { id: u64 }, + + #[error("You cannot lower the gas limit for a contract on the allow list")] + CannotLowerGas, + + #[error("Only the governance contract can do this")] + Unauthorized, } impl From for ContractError { From 523770b1dfc50b52382c079907cb57e57582dfa6 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sat, 15 Jan 2022 17:45:24 +0100 Subject: [PATCH 156/352] Add queries for allowances --- contracts/cw20-ics20/src/contract.rs | 63 +++++++++++++++++++++++++++- contracts/cw20-ics20/src/msg.rs | 33 +++++++++++++++ 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 2ffdfcd2b..c0c2f3c07 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -7,13 +7,14 @@ use cosmwasm_std::{ use cw2::{get_contract_version, set_contract_version}; use cw20::{Cw20Coin, Cw20ReceiveMsg}; +use cw_storage_plus::Bound; use crate::amount::Amount; use crate::error::ContractError; use crate::ibc::Ics20Packet; use crate::msg::{ - AllowMsg, ChannelResponse, ExecuteMsg, InitMsg, ListChannelsResponse, MigrateMsg, PortResponse, - QueryMsg, TransferMsg, + AllowMsg, AllowedInfo, AllowedResponse, ChannelResponse, ConfigResponse, ExecuteMsg, InitMsg, + ListAllowedResponse, ListChannelsResponse, MigrateMsg, PortResponse, QueryMsg, TransferMsg, }; use crate::state::{AllowInfo, Config, ALLOW_LIST, CHANNEL_INFO, CHANNEL_STATE, CONFIG}; use cw_utils::{nonpayable, one_coin}; @@ -194,6 +195,11 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { QueryMsg::Port {} => to_binary(&query_port(deps)?), QueryMsg::ListChannels {} => to_binary(&query_list(deps)?), QueryMsg::Channel { id } => to_binary(&query_channel(deps, id)?), + QueryMsg::Config {} => to_binary(&query_config(deps)?), + QueryMsg::Allowed { contract } => to_binary(&query_allowed(deps, contract)?), + QueryMsg::ListAllowed { start_after, limit } => { + to_binary(&list_allowed(deps, start_after, limit)?) + } } } @@ -236,6 +242,59 @@ pub fn query_channel(deps: Deps, id: String) -> StdResult { }) } +fn query_config(deps: Deps) -> StdResult { + let cfg = CONFIG.load(deps.storage)?; + let res = ConfigResponse { + default_timeout: cfg.default_timeout, + gov_contract: cfg.gov_contract.into(), + }; + Ok(res) +} + +fn query_allowed(deps: Deps, contract: String) -> StdResult { + let addr = deps.api.addr_validate(&contract)?; + let info = ALLOW_LIST.may_load(deps.storage, &addr)?; + let res = match info { + None => AllowedResponse { + is_allowed: false, + gas_limit: None, + }, + Some(a) => AllowedResponse { + is_allowed: true, + gas_limit: a.gas_limit, + }, + }; + Ok(res) +} + +// settings for pagination +const MAX_LIMIT: u32 = 30; +const DEFAULT_LIMIT: u32 = 10; + +fn list_allowed( + deps: Deps, + start_after: Option, + limit: Option, +) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = match start_after { + Some(x) => Some(Bound::exclusive(deps.api.addr_validate(&x)?.into_string())), + None => None, + }; + + let allow = ALLOW_LIST + .range(deps.storage, start, None, Order::Ascending) + .take(limit) + .map(|item| { + item.map(|(addr, allow)| AllowedInfo { + contract: addr.into(), + gas_limit: allow.gas_limit, + }) + }) + .collect::>()?; + Ok(ListAllowedResponse { allow }) +} + #[cfg(test)] mod test { use super::*; diff --git a/contracts/cw20-ics20/src/msg.rs b/contracts/cw20-ics20/src/msg.rs index 39fa6fdd8..ddaade744 100644 --- a/contracts/cw20-ics20/src/msg.rs +++ b/contracts/cw20-ics20/src/msg.rs @@ -49,6 +49,7 @@ pub struct TransferMsg { pub timeout: Option, } +// TODO: query config, query allow list #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { @@ -59,6 +60,15 @@ pub enum QueryMsg { /// Returns the details of the name channel, error if not created. /// Return type: ChannelResponse. Channel { id: String }, + /// Show the Config. Returns ConfigResponse + Config {}, + /// Query if a given cw20 contract is allowed. Returns AllowedResponse + Allowed { contract: String }, + /// List all allowed cw20 contracts. Returns ListAllowedResponse + ListAllowed { + start_after: Option, + limit: Option, + }, } #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] @@ -81,3 +91,26 @@ pub struct ChannelResponse { pub struct PortResponse { pub port_id: String, } + +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct ConfigResponse { + pub default_timeout: u64, + pub gov_contract: String, +} + +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct AllowedResponse { + pub is_allowed: bool, + pub gas_limit: Option, +} + +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct ListAllowedResponse { + pub allow: Vec, +} + +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct AllowedInfo { + pub contract: String, + pub gas_limit: Option, +} From 48f29d3e398dc0277a1f1fb0ea0c9b2a2a8eea7f Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sat, 15 Jan 2022 17:54:51 +0100 Subject: [PATCH 157/352] Add whitelist check to transfer --- contracts/cw20-ics20/src/contract.rs | 25 ++++++++++++++++++------- contracts/cw20-ics20/src/error.rs | 3 +++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index c0c2f3c07..c5cd7b7fd 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -2,7 +2,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ ensure_eq, from_binary, to_binary, Addr, Binary, Deps, DepsMut, Env, IbcMsg, IbcQuery, - MessageInfo, Order, PortIdResponse, Response, StdResult, + MessageInfo, Order, PortIdResponse, Response, StdResult, SubMsg, }; use cw2::{get_contract_version, set_contract_version}; @@ -93,11 +93,21 @@ pub fn execute_transfer( return Err(ContractError::NoFunds {}); } // ensure the requested channel is registered - // FIXME: add a .has method to map to make this faster - if CHANNEL_INFO.may_load(deps.storage, &msg.channel)?.is_none() { + if CHANNEL_INFO.has(deps.storage, &msg.channel) { return Err(ContractError::NoSuchChannel { id: msg.channel }); } + // if cw20 token, ensure it is whitelisted, and use the registered gas limit + let gas_limit = if let Amount::Cw20(coin) = &amount { + let addr = deps.api.addr_validate(&coin.address)?; + let allow = ALLOW_LIST + .may_load(deps.storage, &addr)? + .ok_or(ContractError::NotOnAllowList)?; + allow.gas_limit + } else { + None + }; + // delta from user is in seconds let timeout_delta = match msg.timeout { Some(t) => t, @@ -115,19 +125,20 @@ pub fn execute_transfer( ); packet.validate()?; - // prepare message - let msg = IbcMsg::SendPacket { + // prepare message and set proper gas limit + let mut msg = SubMsg::new(IbcMsg::SendPacket { channel_id: msg.channel, data: to_binary(&packet)?, timeout: timeout.into(), - }; + }); + msg.gas_limit = gas_limit; // Note: we update local state when we get ack - do not count this transfer towards anything until acked // similar event messages like ibctransfer module // send response let res = Response::new() - .add_message(msg) + .add_submessage(msg) .add_attribute("action", "transfer") .add_attribute("sender", &packet.sender) .add_attribute("receiver", &packet.receiver) diff --git a/contracts/cw20-ics20/src/error.rs b/contracts/cw20-ics20/src/error.rs index 78b11ac75..cdd3b0574 100644 --- a/contracts/cw20-ics20/src/error.rs +++ b/contracts/cw20-ics20/src/error.rs @@ -55,6 +55,9 @@ pub enum ContractError { #[error("Only the governance contract can do this")] Unauthorized, + + #[error("You can only send cw20 tokens that have been explicitly allowed by governance")] + NotOnAllowList, } impl From for ContractError { From 0aff8cda83d6f86c3f621a7813544808edc0934c Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sat, 15 Jan 2022 18:03:10 +0100 Subject: [PATCH 158/352] Enforce cw20 whitelist on transfers --- contracts/cw20-ics20/src/contract.rs | 36 ++++++++++++++++++++---- contracts/cw20-ics20/src/ibc.rs | 8 ++++-- contracts/cw20-ics20/src/test_helpers.rs | 17 +++++++++-- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index c5cd7b7fd..d28d3a6de 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -93,7 +93,7 @@ pub fn execute_transfer( return Err(ContractError::NoFunds {}); } // ensure the requested channel is registered - if CHANNEL_INFO.has(deps.storage, &msg.channel) { + if !CHANNEL_INFO.has(deps.storage, &msg.channel) { return Err(ContractError::NoSuchChannel { id: msg.channel }); } @@ -318,7 +318,7 @@ mod test { #[test] fn setup_and_query() { - let deps = setup(&["channel-3", "channel-7"]); + let deps = setup(&["channel-3", "channel-7"], &[]); let raw_list = query(deps.as_ref(), mock_env(), QueryMsg::ListChannels {}).unwrap(); let list_res: ListChannelsResponse = from_binary(&raw_list).unwrap(); @@ -353,7 +353,7 @@ mod test { #[test] fn proper_checks_on_execute_native() { let send_channel = "channel-5"; - let mut deps = setup(&[send_channel, "channel-10"]); + let mut deps = setup(&[send_channel, "channel-10"], &[]); let mut transfer = TransferMsg { channel: send_channel.to_string(), @@ -365,6 +365,7 @@ mod test { let msg = ExecuteMsg::Transfer(transfer.clone()); let info = mock_info("foobar", &coins(1234567, "ucosm")); let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); + assert_eq!(res.messages[0].gas_limit, None); assert_eq!(1, res.messages.len()); if let CosmosMsg::Ibc(IbcMsg::SendPacket { channel_id, @@ -412,9 +413,10 @@ mod test { #[test] fn proper_checks_on_execute_cw20() { let send_channel = "channel-15"; - let mut deps = setup(&["channel-3", send_channel]); - let cw20_addr = "my-token"; + let gas_limit = 123456; + let mut deps = setup(&["channel-3", send_channel], &[(cw20_addr, gas_limit)]); + let transfer = TransferMsg { channel: send_channel.to_string(), remote_address: "foreign-address".to_string(), @@ -430,6 +432,7 @@ mod test { let info = mock_info(cw20_addr, &[]); let res = execute(deps.as_mut(), mock_env(), info, msg.clone()).unwrap(); assert_eq!(1, res.messages.len()); + assert_eq!(res.messages[0].gas_limit, Some(gas_limit)); if let CosmosMsg::Ibc(IbcMsg::SendPacket { channel_id, data, @@ -453,4 +456,27 @@ mod test { let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); assert_eq!(err, ContractError::Payment(PaymentError::NonPayable {})); } + + #[test] + fn execute_cw20_fails_if_not_whitelisted() { + let send_channel = "channel-15"; + let mut deps = setup(&["channel-3", send_channel], &[]); + + let cw20_addr = "my-token"; + let transfer = TransferMsg { + channel: send_channel.to_string(), + remote_address: "foreign-address".to_string(), + timeout: Some(7777), + }; + let msg = ExecuteMsg::Receive(Cw20ReceiveMsg { + sender: "my-account".into(), + amount: Uint128::new(888777666), + msg: to_binary(&transfer).unwrap(), + }); + + // works with proper funds + let info = mock_info(cw20_addr, &[]); + let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); + assert_eq!(err, ContractError::NotOnAllowList); + } } diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index 3fe4711af..d851973b6 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -465,10 +465,12 @@ mod test { #[test] fn send_receive_cw20() { let send_channel = "channel-9"; - let mut deps = setup(&["channel-1", "channel-7", send_channel]); - let cw20_addr = "token-addr"; let cw20_denom = "cw20:token-addr"; + let mut deps = setup( + &["channel-1", "channel-7", send_channel], + &[(cw20_addr, 1234567)], + ); // prepare some mock packets let sent_packet = mock_sent_packet(send_channel, 987654321, cw20_denom, "local-sender"); @@ -521,7 +523,7 @@ mod test { #[test] fn send_receive_native() { let send_channel = "channel-9"; - let mut deps = setup(&["channel-1", "channel-7", send_channel]); + let mut deps = setup(&["channel-1", "channel-7", send_channel], &[]); let denom = "uatom"; diff --git a/contracts/cw20-ics20/src/test_helpers.rs b/contracts/cw20-ics20/src/test_helpers.rs index 1dad4a7ca..27106d66f 100644 --- a/contracts/cw20-ics20/src/test_helpers.rs +++ b/contracts/cw20-ics20/src/test_helpers.rs @@ -11,7 +11,7 @@ use cosmwasm_std::{ DepsMut, IbcChannel, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcEndpoint, OwnedDeps, }; -use crate::msg::InitMsg; +use crate::msg::{AllowMsg, InitMsg}; pub const DEFAULT_TIMEOUT: u64 = 3600; // 1 hour, pub const CONTRACT_PORT: &str = "ibc:wasm1234567890abcdef"; @@ -54,14 +54,25 @@ pub fn add_channel(mut deps: DepsMut, channel_id: &str) { ibc_channel_connect(deps.branch(), mock_env(), connect_msg).unwrap(); } -pub fn setup(channels: &[&str]) -> OwnedDeps { +pub fn setup( + channels: &[&str], + allow: &[(&str, u64)], +) -> OwnedDeps { let mut deps = mock_dependencies(); + let allowlist = allow + .iter() + .map(|(contract, gas)| AllowMsg { + contract: contract.to_string(), + gas_limit: Some(*gas), + }) + .collect(); + // instantiate an empty contract let instantiate_msg = InitMsg { default_timeout: DEFAULT_TIMEOUT, gov_contract: "gov".to_string(), - allowlist: vec![], + allowlist, }; let info = mock_info(&String::from("anyone"), &[]); let res = instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); From 0cc42b95e51be59938758e5749bf1fc2455fad96 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sat, 15 Jan 2022 18:07:39 +0100 Subject: [PATCH 159/352] Remove mistaken gas limit on ibc packet send --- contracts/cw20-ics20/src/contract.rs | 23 +++++++++-------------- contracts/cw20-ics20/src/ibc.rs | 12 ++++++++++++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index d28d3a6de..22428f878 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -2,7 +2,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ ensure_eq, from_binary, to_binary, Addr, Binary, Deps, DepsMut, Env, IbcMsg, IbcQuery, - MessageInfo, Order, PortIdResponse, Response, StdResult, SubMsg, + MessageInfo, Order, PortIdResponse, Response, StdResult, }; use cw2::{get_contract_version, set_contract_version}; @@ -97,15 +97,12 @@ pub fn execute_transfer( return Err(ContractError::NoSuchChannel { id: msg.channel }); } - // if cw20 token, ensure it is whitelisted, and use the registered gas limit - let gas_limit = if let Amount::Cw20(coin) = &amount { + // if cw20 token, ensure it is whitelisted + if let Amount::Cw20(coin) = &amount { let addr = deps.api.addr_validate(&coin.address)?; - let allow = ALLOW_LIST + ALLOW_LIST .may_load(deps.storage, &addr)? .ok_or(ContractError::NotOnAllowList)?; - allow.gas_limit - } else { - None }; // delta from user is in seconds @@ -126,19 +123,18 @@ pub fn execute_transfer( packet.validate()?; // prepare message and set proper gas limit - let mut msg = SubMsg::new(IbcMsg::SendPacket { + let msg = IbcMsg::SendPacket { channel_id: msg.channel, data: to_binary(&packet)?, timeout: timeout.into(), - }); - msg.gas_limit = gas_limit; + }; // Note: we update local state when we get ack - do not count this transfer towards anything until acked // similar event messages like ibctransfer module // send response let res = Response::new() - .add_submessage(msg) + .add_message(msg) .add_attribute("action", "transfer") .add_attribute("sender", &packet.sender) .add_attribute("receiver", &packet.receiver) @@ -414,8 +410,7 @@ mod test { fn proper_checks_on_execute_cw20() { let send_channel = "channel-15"; let cw20_addr = "my-token"; - let gas_limit = 123456; - let mut deps = setup(&["channel-3", send_channel], &[(cw20_addr, gas_limit)]); + let mut deps = setup(&["channel-3", send_channel], &[(cw20_addr, 123456)]); let transfer = TransferMsg { channel: send_channel.to_string(), @@ -432,7 +427,7 @@ mod test { let info = mock_info(cw20_addr, &[]); let res = execute(deps.as_mut(), mock_env(), info, msg.clone()).unwrap(); assert_eq!(1, res.messages.len()); - assert_eq!(res.messages[0].gas_limit, Some(gas_limit)); + assert_eq!(res.messages[0].gas_limit, None); if let CosmosMsg::Ibc(IbcMsg::SendPacket { channel_id, data, diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index d851973b6..26aad11bf 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -181,6 +181,18 @@ pub fn ibc_packet_receive( attr("success", "true"), ]; let to_send = Amount::from_parts(denom.into(), msg.amount); + + // TODO: add check.. + // if cw20 token, ensure it is whitelisted, and use the registered gas limit + // let gas_limit = if let Amount::Cw20(coin) = &amount { + // let addr = deps.api.addr_validate(&coin.address)?; + // let allow = ALLOW_LIST + // .may_load(deps.storage, &addr)? + // .ok_or(ContractError::NotOnAllowList)?; + // allow.gas_limit + // } else { + // None + // }; let msg = send_amount(to_send, msg.receiver); IbcReceiveResponse::new() .set_ack(ack_success()) From 3b5954e9358c565d7bd4fc2c42c34d2bd2f75df2 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sat, 15 Jan 2022 23:24:58 +0100 Subject: [PATCH 160/352] Clean up receive handler, limit gas on releasing cw20 tokens --- contracts/cw20-ics20/src/ibc.rs | 122 ++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 55 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index 26aad11bf..6435dc589 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -2,7 +2,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{ - attr, entry_point, from_binary, to_binary, BankMsg, Binary, ContractResult, DepsMut, Env, + attr, entry_point, from_binary, to_binary, BankMsg, Binary, ContractResult, Deps, DepsMut, Env, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, Reply, Response, StdResult, SubMsg, Uint128, WasmMsg, @@ -10,7 +10,7 @@ use cosmwasm_std::{ use crate::amount::Amount; use crate::error::{ContractError, Never}; -use crate::state::{ChannelInfo, CHANNEL_INFO, CHANNEL_STATE}; +use crate::state::{ChannelInfo, ALLOW_LIST, CHANNEL_INFO, CHANNEL_STATE}; use cw20::Cw20ExecuteMsg; pub const ICS20_VERSION: &str = "ics20-1"; @@ -164,52 +164,15 @@ pub fn ibc_packet_receive( ) -> Result { let packet = msg.packet; - let res = match do_ibc_packet_receive(deps, &packet) { - Ok(msg) => { - // build attributes first so we don't have to clone msg below - // similar event messages like ibctransfer module - - // This cannot fail as we parse it in do_ibc_packet_receive. Best to pass the data somehow? - let denom = parse_voucher_denom(&msg.denom, &packet.src).unwrap(); - - let attributes = vec![ - attr("action", "receive"), - attr("sender", &msg.sender), - attr("receiver", &msg.receiver), - attr("denom", denom), - attr("amount", msg.amount), - attr("success", "true"), - ]; - let to_send = Amount::from_parts(denom.into(), msg.amount); - - // TODO: add check.. - // if cw20 token, ensure it is whitelisted, and use the registered gas limit - // let gas_limit = if let Amount::Cw20(coin) = &amount { - // let addr = deps.api.addr_validate(&coin.address)?; - // let allow = ALLOW_LIST - // .may_load(deps.storage, &addr)? - // .ok_or(ContractError::NotOnAllowList)?; - // allow.gas_limit - // } else { - // None - // }; - let msg = send_amount(to_send, msg.receiver); - IbcReceiveResponse::new() - .set_ack(ack_success()) - .add_submessage(msg) - .add_attributes(attributes) - } - Err(err) => IbcReceiveResponse::new() + do_ibc_packet_receive(deps, &packet).or_else(|err| { + Ok(IbcReceiveResponse::new() .set_ack(ack_fail(err.to_string())) .add_attributes(vec![ attr("action", "receive"), attr("success", "false"), attr("error", err.to_string()), - ]), - }; - - // if we have funds, now send the tokens to the requested recipient - Ok(res) + ])) + }) } // Returns local denom if the denom is an encoded voucher from the expected endpoint @@ -238,7 +201,10 @@ fn parse_voucher_denom<'a>( } // this does the work of ibc_packet_receive, we wrap it to turn errors into acknowledgements -fn do_ibc_packet_receive(deps: DepsMut, packet: &IbcPacket) -> Result { +fn do_ibc_packet_receive( + deps: DepsMut, + packet: &IbcPacket, +) -> Result { let msg: Ics20Packet = from_binary(&packet.data)?; let channel = packet.dest.channel_id.clone(); @@ -246,7 +212,6 @@ fn do_ibc_packet_receive(deps: DepsMut, packet: &IbcPacket) -> Result Result Result, ContractError> { + match amount { + Amount::Cw20(coin) => { + // if cw20 token, use the registered gas limit, or error if not whitelisted + let addr = deps.api.addr_validate(&coin.address)?; + Ok(ALLOW_LIST + .may_load(deps.storage, &addr)? + .ok_or(ContractError::NotOnAllowList)? + .gas_limit) + } + _ => Ok(None), + } } #[cfg_attr(not(feature = "library"), entry_point)] @@ -318,7 +319,7 @@ fn on_packet_success(deps: DepsMut, packet: IbcPacket) -> Result Result { @@ -335,13 +336,14 @@ fn on_packet_failure( ]; let amount = Amount::from_parts(msg.denom, msg.amount); - let msg = send_amount(amount, msg.sender); + let gas_limit = check_gas_limit(deps.as_ref(), &amount)?; + let msg = send_amount(amount, msg.sender, gas_limit); Ok(IbcBasicResponse::new() .add_attributes(attributes) .add_submessage(msg)) } -fn send_amount(amount: Amount, recipient: String) -> SubMsg { +fn send_amount(amount: Amount, recipient: String, gas_limit: Option) -> SubMsg { match amount { Amount::Native(coin) => SubMsg::reply_on_error( BankMsg::Send { @@ -360,7 +362,9 @@ fn send_amount(amount: Amount, recipient: String) -> SubMsg { msg: to_binary(&msg).unwrap(), funds: vec![], }; - SubMsg::reply_on_error(exec, SEND_TOKEN_ID) + let mut sub = SubMsg::reply_on_error(exec, SEND_TOKEN_ID); + sub.gas_limit = gas_limit; + sub } } } @@ -401,7 +405,12 @@ mod test { assert_eq!(expected, encdoded.as_str()); } - fn cw20_payment(amount: u128, address: &str, recipient: &str) -> SubMsg { + fn cw20_payment( + amount: u128, + address: &str, + recipient: &str, + gas_limit: Option, + ) -> SubMsg { let msg = Cw20ExecuteMsg::Transfer { recipient: recipient.into(), amount: Uint128::new(amount), @@ -411,7 +420,9 @@ mod test { msg: to_binary(&msg).unwrap(), funds: vec![], }; - SubMsg::reply_on_error(exec, SEND_TOKEN_ID) + let mut msg = SubMsg::reply_on_error(exec, SEND_TOKEN_ID); + msg.gas_limit = gas_limit; + msg } fn native_payment(amount: u128, denom: &str, recipient: &str) -> SubMsg { @@ -479,9 +490,10 @@ mod test { let send_channel = "channel-9"; let cw20_addr = "token-addr"; let cw20_denom = "cw20:token-addr"; + let gas_limit = 1234567; let mut deps = setup( &["channel-1", "channel-7", send_channel], - &[(cw20_addr, 1234567)], + &[(cw20_addr, gas_limit)], ); // prepare some mock packets @@ -520,7 +532,7 @@ mod test { let res = ibc_packet_receive(deps.as_mut(), mock_env(), msg).unwrap(); assert_eq!(1, res.messages.len()); assert_eq!( - cw20_payment(876543210, cw20_addr, "local-rcpt"), + cw20_payment(876543210, cw20_addr, "local-rcpt", Some(gas_limit)), res.messages[0] ); let ack: Ics20Ack = from_binary(&res.acknowledgement).unwrap(); From 65fcbf56d5372eac4f0047e01daab95af0ec2ce1 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sat, 15 Jan 2022 23:29:27 +0100 Subject: [PATCH 161/352] Cleanup --- contracts/cw20-ics20/src/ibc.rs | 53 ++++++++++++++------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index 6435dc589..136337456 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -228,24 +228,17 @@ fn do_ibc_packet_receive( let to_send = Amount::from_parts(denom.to_string(), msg.amount); let gas_limit = check_gas_limit(deps.as_ref(), &to_send)?; + let send = send_amount(to_send, msg.receiver.clone(), gas_limit); - // build attributes first so we don't have to clone msg below - // similar event messages like ibctransfer module - - let attributes = vec![ - attr("action", "receive"), - attr("sender", &msg.sender), - attr("receiver", &msg.receiver), - attr("denom", denom), - attr("amount", msg.amount), - attr("success", "true"), - ]; - - let msg = send_amount(to_send, msg.receiver, gas_limit); let res = IbcReceiveResponse::new() .set_ack(ack_success()) - .add_submessage(msg) - .add_attributes(attributes); + .add_submessage(send) + .add_attribute("action", "receive") + .add_attribute("sender", msg.sender) + .add_attribute("receiver", msg.receiver) + .add_attribute("denom", denom) + .add_attribute("amount", msg.amount) + .add_attribute("success", "true"); Ok(res) } @@ -324,23 +317,23 @@ fn on_packet_failure( err: String, ) -> Result { let msg: Ics20Packet = from_binary(&packet.data)?; + + let to_send = Amount::from_parts(msg.denom.clone(), msg.amount); + let gas_limit = check_gas_limit(deps.as_ref(), &to_send)?; + let send = send_amount(to_send, msg.sender.clone(), gas_limit); + // similar event messages like ibctransfer module - let attributes = vec![ - attr("action", "acknowledge"), - attr("sender", &msg.sender), - attr("receiver", &msg.receiver), - attr("denom", &msg.denom), - attr("amount", &msg.amount.to_string()), - attr("success", "false"), - attr("error", err), - ]; + let res = IbcBasicResponse::new() + .add_submessage(send) + .add_attribute("action", "acknowledge") + .add_attribute("sender", msg.sender) + .add_attribute("receiver", msg.receiver) + .add_attribute("denom", msg.denom) + .add_attribute("amount", msg.amount.to_string()) + .add_attribute("success", "false") + .add_attribute("error", err); - let amount = Amount::from_parts(msg.denom, msg.amount); - let gas_limit = check_gas_limit(deps.as_ref(), &amount)?; - let msg = send_amount(amount, msg.sender, gas_limit); - Ok(IbcBasicResponse::new() - .add_attributes(attributes) - .add_submessage(msg)) + Ok(res) } fn send_amount(amount: Amount, recipient: String, gas_limit: Option) -> SubMsg { From 383963319589cd9d9ba923e380939abd7146f548 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 17 Jan 2022 22:08:50 +0100 Subject: [PATCH 162/352] PR comments --- contracts/cw20-ics20/src/contract.rs | 2 +- contracts/cw20-ics20/src/msg.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 22428f878..8c705bd1f 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -122,7 +122,7 @@ pub fn execute_transfer( ); packet.validate()?; - // prepare message and set proper gas limit + // prepare ibc message let msg = IbcMsg::SendPacket { channel_id: msg.channel, data: to_binary(&packet)?, diff --git a/contracts/cw20-ics20/src/msg.rs b/contracts/cw20-ics20/src/msg.rs index ddaade744..044cbf2f6 100644 --- a/contracts/cw20-ics20/src/msg.rs +++ b/contracts/cw20-ics20/src/msg.rs @@ -49,7 +49,6 @@ pub struct TransferMsg { pub timeout: Option, } -// TODO: query config, query allow list #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { From 759ccc0695feb9e71138a1c30145f0b094a0753d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 21 Jan 2022 13:14:54 +0100 Subject: [PATCH 163/352] Fix tag consolidation for matching CHANGELOG entries --- scripts/update_changelog.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_changelog.sh b/scripts/update_changelog.sh index 09331e61e..6b2900615 100755 --- a/scripts/update_changelog.sh +++ b/scripts/update_changelog.sh @@ -44,7 +44,7 @@ echo "Git version tag: $TAG" cp CHANGELOG.md /tmp/CHANGELOG.md.$$ # Consolidate tag for matching changelog entries -TAG=$(echo "$TAG" | sed 's/-\([A-Za-z]*\)[^A-Za-z]*/-\1/') +TAG=$(echo "$TAG" | sed -e 's/-\([A-Za-z]*\)[^A-Za-z]*/-\1/' -e 's/-$//') echo "Consolidated tag: $TAG" sed -i -n "/^## \\[${TAG}[^]]*\\]/,\$p" CHANGELOG.md From 3ae535969ab4125adf811eee6b74a8690950ac73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20K=C3=BCl=C3=A7e?= Date: Tue, 25 Jan 2022 20:14:28 +0300 Subject: [PATCH 164/352] Refactor cw2 spec readme I think removing migration reference cw2 spec makes sense. This spec is used for code inspection and verification too. Migration name in the title makes it hard for someone to find this. --- packages/cw2/README.md | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/cw2/README.md b/packages/cw2/README.md index dec9f09ef..3d1e31781 100644 --- a/packages/cw2/README.md +++ b/packages/cw2/README.md @@ -1,21 +1,28 @@ -# CW2 Spec: Contract Info for Migration +# CW2 Spec: Contract Info Most of the CW* specs are focused on the *public interfaces* of the contract. The APIs used for `ExecuteMsg` or `QueryMsg`. -However, when we wish to migrate from contract A to contract B, -contract B needs to be aware somehow of how the *state was encoded*. +However, when we wish to migrate or inspect smart contract info, +we need some form of smart contract information embedded on state. -Generally we use Singletons and Buckets to store the state, but -if I upgrade to a `cw20-with-bonding-curve` contract, it will only -work properly if I am migrating from a `cw20-base` contract. But how -can the new contract know what format the data was stored. +This is where CW2 comes in. It specifies on special Item to +be stored on disk by all contracts on `instantiate`. -This is where CW2 comes in. It specifies on special Singleton to -be stored on disk by all contracts on `instantiate`. When the `migrate` -function is called, then the new contract can read that data and -see if this is an expected contract we can migrate from. And also -contain extra version information if we support multiple migrate -paths. +`ContractInfo` is must be stored under `"contract_info"` key which translates +to `"636F6E74726163745F696E666F"` in hex format. +Since the state is well defined, we do not need to support any "smart queries". +We do provide a helper to construct a "raw query" to read the ContractInfo +of any CW2-compliant contract. + +You can query using: +```shell +wasmd query wasm contract-state raw [contract_addr] 636F6E74726163745F696E666F --node $RPC +``` + +When the `migrate` function is called, then the new contract +can read that data andsee if this is an expected contract we can +migrate from. And also contain extra version information if we +support multiple migrate paths. ### Data structures @@ -49,9 +56,3 @@ Thus, an serialized example may looks like: "version": "v0.1.0" } ``` - -### Queries - -Since the state is well defined, we do not need to support any "smart queries". -We do provide a helper to construct a "raw query" to read the ContractInfo -of any CW2-compliant contract. From 7cdf2d127b2b50c148282a6712b6e72edea5813d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 27 Jan 2022 10:10:32 +0100 Subject: [PATCH 165/352] Update rust to v0.44.0 in CI --- .circleci/config.yml | 140 +++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bccf2c4b3..79b005986 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,7 +52,7 @@ workflows: jobs: contract_cw1_subkeys: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/contracts/cw1-subkeys steps: - checkout: @@ -62,7 +62,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw1-subkeys-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw1-subkeys-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -75,11 +75,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw1-subkeys-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw1-subkeys-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} contract_cw1_whitelist: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/contracts/cw1-whitelist steps: - checkout: @@ -89,7 +89,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw1-whitelist-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw1-whitelist-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -102,11 +102,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw1-whitelist-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw1-whitelist-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} contract_cw1_whitelist_ng: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/contracts/cw1-whitelist-ng steps: - checkout: @@ -116,7 +116,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw1-whitelist-ng-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw1-whitelist-ng-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -129,11 +129,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw1-whitelist-ng-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw1-whitelist-ng-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} contract_cw3_fixed_multisig: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/contracts/cw3-fixed-multisig steps: - checkout: @@ -143,7 +143,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw3-fixed-multisig-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw3-fixed-multisig-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -156,11 +156,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw3-fixed-multisig-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw3-fixed-multisig-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} contract_cw3_flex_multisig: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/contracts/cw3-flex-multisig steps: - checkout: @@ -170,7 +170,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw3-flex-multisig-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw3-flex-multisig-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -183,11 +183,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw3-flex-multisig-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw3-flex-multisig-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} contract_cw4_group: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/contracts/cw4-group steps: - checkout: @@ -197,7 +197,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw4-group-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw4-group-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -210,11 +210,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw4-group-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw4-group-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} contract_cw4_stake: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/contracts/cw4-stake steps: - checkout: @@ -224,7 +224,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw4-stake-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw4-stake-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -237,11 +237,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw4-stake-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw4-stake-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} contract_cw20_base: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/contracts/cw20-base steps: - checkout: @@ -251,7 +251,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw20-base-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw20-base-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -264,11 +264,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw20-base-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw20-base-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} contract_cw20_ics20: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/contracts/cw20-ics20 steps: - checkout: @@ -278,7 +278,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw20-ics20-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw20-ics20-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -291,11 +291,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw20-ics20-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw20-ics20-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} contract_cw1155_base: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/contracts/cw1155-base steps: - checkout: @@ -305,7 +305,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw1155-base-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw1155-base-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -318,11 +318,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw1155-base-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw1155-base-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} package_controllers: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/packages/controllers steps: - checkout: @@ -332,7 +332,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-controllers:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-controllers:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -343,11 +343,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-controllers:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-controllers:1.54.0-{{ checksum "~/project/Cargo.lock" }} package_utils: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/packages/utils steps: - checkout: @@ -357,7 +357,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-utils:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-utils:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -368,11 +368,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-utils:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-utils:1.54.0-{{ checksum "~/project/Cargo.lock" }} package_cw1: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/packages/cw1 steps: - checkout: @@ -382,7 +382,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw1:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw1:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -396,11 +396,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw1:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw1:1.54.0-{{ checksum "~/project/Cargo.lock" }} package_cw2: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/packages/cw2 steps: - checkout: @@ -410,7 +410,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw2:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw2:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -422,11 +422,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw2:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw2:1.54.0-{{ checksum "~/project/Cargo.lock" }} package_cw3: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/packages/cw3 steps: - checkout: @@ -436,7 +436,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw3:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw3:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -450,11 +450,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw3:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw3:1.54.0-{{ checksum "~/project/Cargo.lock" }} package_cw4: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/packages/cw4 steps: - checkout: @@ -464,7 +464,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw4:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw4:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -478,11 +478,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw4:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw4:1.54.0-{{ checksum "~/project/Cargo.lock" }} package_cw20: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/packages/cw20 steps: - checkout: @@ -492,7 +492,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw20:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw20:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -506,11 +506,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw20:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw20:1.54.0-{{ checksum "~/project/Cargo.lock" }} package_cw1155: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/packages/cw1155 steps: - checkout: @@ -520,7 +520,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw1155:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw1155:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -534,11 +534,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw1155:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw1155:1.54.0-{{ checksum "~/project/Cargo.lock" }} lint: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 steps: - checkout - run: @@ -546,7 +546,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-lint-rust:1.53.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-lint-rust:1.54.0-{{ checksum "Cargo.lock" }} - run: name: Add rustfmt component command: rustup component add rustfmt @@ -565,7 +565,7 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-lint-rust:1.53.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-lint-rust:1.54.0-{{ checksum "Cargo.lock" }} # This runs one time on the top level to ensure all contracts compile properly into wasm. # We don't run the wasm build per contract build, and then reuse a lot of the same dependencies, so this speeds up CI time @@ -573,7 +573,7 @@ jobs: # We also sanity-check the resultant wasm files. wasm-build: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 steps: - checkout: path: ~/project @@ -582,7 +582,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-wasm-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-wasm-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Add wasm32 target command: rustup target add wasm32-unknown-unknown @@ -602,7 +602,7 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-wasm-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-wasm-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Check wasm contracts command: | @@ -614,7 +614,7 @@ jobs: package_multi_test: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/packages/multi-test steps: - checkout: @@ -624,7 +624,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-multi-test:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-multi-test:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -638,11 +638,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-multi-test:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-multi-test:1.54.0-{{ checksum "~/project/Cargo.lock" }} package_storage_plus: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project/packages/storage-plus steps: - checkout: @@ -652,7 +652,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-storage-plus:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-storage-plus:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target (no iterator) command: cargo build --locked --no-default-features @@ -669,11 +669,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-storage-plus:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-storage-plus:1.54.0-{{ checksum "~/project/Cargo.lock" }} benchmarking: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 environment: RUST_BACKTRACE: 1 steps: @@ -684,7 +684,7 @@ jobs: command: rustc --version && cargo --version - restore_cache: keys: - - cargocache-v2-benchmarking-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-benchmarking-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Run storage-plus benchmarks working_directory: ~/project/packages/storage-plus @@ -693,7 +693,7 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-benchmarking-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-benchmarking-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} # This job roughly follows the instructions from https://circleci.com/blog/publishing-to-github-releases-via-circleci/ build_and_upload_contracts: @@ -743,7 +743,7 @@ jobs: build_and_upload_schemas: docker: - - image: rust:1.53.0 + - image: rust:1.54.0 working_directory: ~/project steps: - checkout: From 0431c3056fc02ec332d6ffcb26c59dd703932fe4 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Thu, 27 Jan 2022 10:27:26 +0100 Subject: [PATCH 166/352] Remove needless borrow after rust update --- contracts/cw1-whitelist-ng/src/contract.rs | 24 +++++++++---------- contracts/cw1-whitelist/src/contract.rs | 20 ++++++++-------- contracts/cw4-stake/src/contract.rs | 2 +- packages/multi-test/src/app.rs | 2 +- packages/multi-test/src/wasm.rs | 2 +- packages/storage-plus/src/indexed_snapshot.rs | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/contracts/cw1-whitelist-ng/src/contract.rs b/contracts/cw1-whitelist-ng/src/contract.rs index 301b20c96..177b30034 100644 --- a/contracts/cw1-whitelist-ng/src/contract.rs +++ b/contracts/cw1-whitelist-ng/src/contract.rs @@ -223,7 +223,7 @@ mod tests { // instantiate the contract let admins = vec![alice.to_owned(), bob.to_owned(), carl.to_owned()]; - let info = mock_info(&anyone, &[]); + let info = mock_info(anyone, &[]); contract .instantiate(deps.as_mut(), mock_env(), info, admins, true) .unwrap(); @@ -239,7 +239,7 @@ mod tests { ); // anyone cannot modify the contract - let info = mock_info(&anyone, &[]); + let info = mock_info(anyone, &[]); let err = contract .update_admins(deps.as_mut(), mock_env(), info, vec![anyone.to_owned()]) .unwrap_err(); @@ -247,7 +247,7 @@ mod tests { // but alice can kick out carl let admins = vec![alice.to_owned(), bob.to_owned()]; - let info = mock_info(&alice, &[]); + let info = mock_info(alice, &[]); contract .update_admins(deps.as_mut(), mock_env(), info, admins) .unwrap(); @@ -263,14 +263,14 @@ mod tests { ); // carl cannot freeze it - let info = mock_info(&carl, &[]); + let info = mock_info(carl, &[]); let err = contract .freeze(deps.as_mut(), mock_env(), info) .unwrap_err(); assert_eq!(err, ContractError::Unauthorized {}); // but bob can - let info = mock_info(&bob, &[]); + let info = mock_info(bob, &[]); contract.freeze(deps.as_mut(), mock_env(), info).unwrap(); let expected = AdminListResponse { admins: vec![alice.to_owned(), bob.to_owned()], @@ -282,7 +282,7 @@ mod tests { ); // and now alice cannot change it again - let info = mock_info(&alice, &[]); + let info = mock_info(alice, &[]); let err = contract .update_admins(deps.as_mut(), mock_env(), info, vec![alice.to_owned()]) .unwrap_err(); @@ -300,7 +300,7 @@ mod tests { // instantiate the contract let admins = vec![alice.to_owned(), carl.to_owned()]; - let info = mock_info(&bob, &[]); + let info = mock_info(bob, &[]); contract .instantiate(deps.as_mut(), mock_env(), info, admins, false) .unwrap(); @@ -321,14 +321,14 @@ mod tests { ]; // bob cannot execute them - let info = mock_info(&bob, &[]); + let info = mock_info(bob, &[]); let err = contract .execute(deps.as_mut(), mock_env(), info, msgs.clone()) .unwrap_err(); assert_eq!(err, ContractError::Unauthorized {}); // but carl can - let info = mock_info(&carl, &[]); + let info = mock_info(carl, &[]); let res = contract .execute(deps.as_mut(), mock_env(), info, msgs.clone()) .unwrap(); @@ -346,7 +346,7 @@ mod tests { let alice = "alice"; let admins = vec![alice.to_owned()]; - let info = mock_info(&alice, &[]); + let info = mock_info(alice, &[]); contract .instantiate(deps.as_mut(), mock_env(), info, admins, false) .unwrap(); @@ -357,7 +357,7 @@ mod tests { .execute( deps.as_mut(), mock_env(), - mock_info(&alice, &[]), + mock_info(alice, &[]), msgs.clone(), ) .unwrap(); @@ -380,7 +380,7 @@ mod tests { // instantiate the contract let admins = vec![alice.to_owned(), bob.to_owned()]; - let info = mock_info(&anyone, &[]); + let info = mock_info(anyone, &[]); contract .instantiate(deps.as_mut(), mock_env(), info, admins, false) .unwrap(); diff --git a/contracts/cw1-whitelist/src/contract.rs b/contracts/cw1-whitelist/src/contract.rs index c7c8784fb..77f2b7ef7 100644 --- a/contracts/cw1-whitelist/src/contract.rs +++ b/contracts/cw1-whitelist/src/contract.rs @@ -162,7 +162,7 @@ mod tests { admins: vec![alice.to_string(), bob.to_string(), carl.to_string()], mutable: true, }; - let info = mock_info(&anyone, &[]); + let info = mock_info(anyone, &[]); instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); // ensure expected config @@ -176,7 +176,7 @@ mod tests { let msg = ExecuteMsg::UpdateAdmins { admins: vec![anyone.to_string()], }; - let info = mock_info(&anyone, &[]); + let info = mock_info(anyone, &[]); let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); assert_eq!(err, ContractError::Unauthorized {}); @@ -184,7 +184,7 @@ mod tests { let msg = ExecuteMsg::UpdateAdmins { admins: vec![alice.to_string(), bob.to_string()], }; - let info = mock_info(&alice, &[]); + let info = mock_info(alice, &[]); execute(deps.as_mut(), mock_env(), info, msg).unwrap(); // ensure expected config @@ -195,12 +195,12 @@ mod tests { assert_eq!(query_admin_list(deps.as_ref()).unwrap(), expected); // carl cannot freeze it - let info = mock_info(&carl, &[]); + let info = mock_info(carl, &[]); let err = execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Freeze {}).unwrap_err(); assert_eq!(err, ContractError::Unauthorized {}); // but bob can - let info = mock_info(&bob, &[]); + let info = mock_info(bob, &[]); execute(deps.as_mut(), mock_env(), info, ExecuteMsg::Freeze {}).unwrap(); let expected = AdminListResponse { admins: vec![alice.to_string(), bob.to_string()], @@ -212,7 +212,7 @@ mod tests { let msg = ExecuteMsg::UpdateAdmins { admins: vec![alice.to_string()], }; - let info = mock_info(&alice, &[]); + let info = mock_info(alice, &[]); let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); assert_eq!(err, ContractError::Unauthorized {}); } @@ -230,7 +230,7 @@ mod tests { admins: vec![alice.to_string(), carl.to_string()], mutable: false, }; - let info = mock_info(&bob, &[]); + let info = mock_info(bob, &[]); instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); let freeze: ExecuteMsg = ExecuteMsg::Freeze {}; @@ -252,12 +252,12 @@ mod tests { let execute_msg = ExecuteMsg::Execute { msgs: msgs.clone() }; // bob cannot execute them - let info = mock_info(&bob, &[]); + let info = mock_info(bob, &[]); let err = execute(deps.as_mut(), mock_env(), info, execute_msg.clone()).unwrap_err(); assert_eq!(err, ContractError::Unauthorized {}); // but carl can - let info = mock_info(&carl, &[]); + let info = mock_info(carl, &[]); let res = execute(deps.as_mut(), mock_env(), info, execute_msg).unwrap(); assert_eq!( res.messages, @@ -280,7 +280,7 @@ mod tests { admins: vec![alice.to_string(), bob.to_string()], mutable: false, }; - let info = mock_info(&anyone, &[]); + let info = mock_info(anyone, &[]); instantiate(deps.as_mut(), mock_env(), info, instantiate_msg).unwrap(); // let us make some queries... different msg types by owner and by other diff --git a/contracts/cw4-stake/src/contract.rs b/contracts/cw4-stake/src/contract.rs index e1d372083..f57be9b9b 100644 --- a/contracts/cw4-stake/src/contract.rs +++ b/contracts/cw4-stake/src/contract.rs @@ -669,7 +669,7 @@ mod tests { }) => { assert_eq!(contract_addr.as_str(), CW20_ADDRESS); assert_eq!(funds.len(), 0); - let parsed: Cw20ExecuteMsg = from_slice(&msg).unwrap(); + let parsed: Cw20ExecuteMsg = from_slice(msg).unwrap(); assert_eq!( parsed, Cw20ExecuteMsg::Transfer { diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index 326d54587..c23e6873a 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -924,7 +924,7 @@ where Ok(v) => v, Err(e) => { return SystemResult::Err(SystemError::InvalidRequest { - error: format!("Parsing query request: {}", e.to_string()), + error: format!("Parsing query request: {}", e), request: bin_request.into(), }) } diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index 56279925b..49646d876 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -798,7 +798,7 @@ where .range_raw(storage, None, None, Order::Ascending) .count(); // we make this longer so it is not rejected by tests - Addr::unchecked(format!("Contract #{}", count.to_string())) + Addr::unchecked(format!("Contract #{}", count)) } fn contract_namespace(&self, contract: &Addr) -> Vec { diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 8476572bd..e5f45bfa2 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -58,7 +58,7 @@ impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I> { } pub fn changelog(&self) -> &Map<'a, (K, u64), ChangeSet> { - &self.primary.changelog() + self.primary.changelog() } } From a1c4642a7f4af10861d12c154f2007efe6e86164 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Thu, 27 Jan 2022 10:49:28 +0100 Subject: [PATCH 167/352] Update check contract's job cosmwasm to beta4 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 79b005986..c991d2dd6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -597,7 +597,7 @@ jobs: - run: name: Install check_contract # Uses --debug for compilation speed - command: cargo install --debug --version 1.0.0-beta --features iterator --example check_contract -- cosmwasm-vm + command: cargo install --debug --version 1.0.0-beta4 --features iterator --example check_contract -- cosmwasm-vm - save_cache: paths: - /usr/local/cargo/registry From 1d7a0a17cd82c03c0c03ff27ef737de8a3583005 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sat, 15 Jan 2022 23:40:46 +0100 Subject: [PATCH 168/352] Start handling rollback on submessage error --- contracts/cw20-ics20/src/ibc.rs | 41 +++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index 136337456..de633b9fb 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -72,21 +72,25 @@ fn ack_fail(err: String) -> Binary { to_binary(&res).unwrap() } -const SEND_TOKEN_ID: u64 = 1337; +const RECEIVE_ID: u64 = 1337; +const ACK_FAILURE_ID: u64 = 0xfa17; #[cfg_attr(not(feature = "library"), entry_point)] pub fn reply(_deps: DepsMut, _env: Env, reply: Reply) -> Result { - if reply.id != SEND_TOKEN_ID { - return Err(ContractError::UnknownReplyId { id: reply.id }); - } - let res = match reply.result { - ContractResult::Ok(_) => Response::new(), + match reply.result { + ContractResult::Ok(_) => Ok(Response::new()), ContractResult::Err(err) => { - // encode an acknowledgement error - Response::new().set_data(ack_fail(err)) + let res = Response::new().set_data(ack_fail(err)); + match reply.id { + RECEIVE_ID => { + // TODO: revert state change + Ok(res) + } + ACK_FAILURE_ID => Ok(res), + _ => Err(ContractError::UnknownReplyId { id: reply.id }), + } } - }; - Ok(res) + } } #[cfg_attr(not(feature = "library"), entry_point)] @@ -212,6 +216,9 @@ fn do_ibc_packet_receive( // If it originated on our chain, it looks like "port/channel/ucosm". let denom = parse_voucher_denom(&msg.denom, &packet.src)?; + // Important design note: with ibcv2 and wasmd 0.22 we should return error so this gets reverted + // If we need compatibility with Juno (Jan 2022), we need to ensure that this state change gets reverted + // in the case of the submessage (transfer) erroring CHANNEL_STATE.update( deps.storage, (&channel, denom), @@ -228,7 +235,7 @@ fn do_ibc_packet_receive( let to_send = Amount::from_parts(denom.to_string(), msg.amount); let gas_limit = check_gas_limit(deps.as_ref(), &to_send)?; - let send = send_amount(to_send, msg.receiver.clone(), gas_limit); + let send = send_amount(to_send, msg.receiver.clone(), gas_limit, RECEIVE_ID); let res = IbcReceiveResponse::new() .set_ack(ack_success()) @@ -320,7 +327,7 @@ fn on_packet_failure( let to_send = Amount::from_parts(msg.denom.clone(), msg.amount); let gas_limit = check_gas_limit(deps.as_ref(), &to_send)?; - let send = send_amount(to_send, msg.sender.clone(), gas_limit); + let send = send_amount(to_send, msg.sender.clone(), gas_limit, ACK_FAILURE_ID); // similar event messages like ibctransfer module let res = IbcBasicResponse::new() @@ -336,14 +343,14 @@ fn on_packet_failure( Ok(res) } -fn send_amount(amount: Amount, recipient: String, gas_limit: Option) -> SubMsg { +fn send_amount(amount: Amount, recipient: String, gas_limit: Option, reply_id: u64) -> SubMsg { match amount { Amount::Native(coin) => SubMsg::reply_on_error( BankMsg::Send { to_address: recipient, amount: vec![coin], }, - SEND_TOKEN_ID, + reply_id, ), Amount::Cw20(coin) => { let msg = Cw20ExecuteMsg::Transfer { @@ -355,7 +362,7 @@ fn send_amount(amount: Amount, recipient: String, gas_limit: Option) -> Sub msg: to_binary(&msg).unwrap(), funds: vec![], }; - let mut sub = SubMsg::reply_on_error(exec, SEND_TOKEN_ID); + let mut sub = SubMsg::reply_on_error(exec, reply_id); sub.gas_limit = gas_limit; sub } @@ -413,7 +420,7 @@ mod test { msg: to_binary(&msg).unwrap(), funds: vec![], }; - let mut msg = SubMsg::reply_on_error(exec, SEND_TOKEN_ID); + let mut msg = SubMsg::reply_on_error(exec, RECEIVE_ID); msg.gas_limit = gas_limit; msg } @@ -424,7 +431,7 @@ mod test { to_address: recipient.into(), amount: coins(amount, denom), }, - SEND_TOKEN_ID, + RECEIVE_ID, ) } From 2803a9806b26df651f390d9462f5decb877f8352 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sun, 16 Jan 2022 00:10:59 +0100 Subject: [PATCH 169/352] Only make state changes when submessages pass --- contracts/cw20-ics20/src/ibc.rs | 132 ++++++++++++++++-------------- contracts/cw20-ics20/src/state.rs | 50 ++++++++++- 2 files changed, 119 insertions(+), 63 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index de633b9fb..cf69993b7 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -2,15 +2,18 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{ - attr, entry_point, from_binary, to_binary, BankMsg, Binary, ContractResult, Deps, DepsMut, Env, - IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, - IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, - IbcReceiveResponse, Reply, Response, StdResult, SubMsg, Uint128, WasmMsg, + attr, entry_point, from_binary, to_binary, BankMsg, Binary, ContractResult, CosmosMsg, Deps, + DepsMut, Env, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, + IbcChannelOpenMsg, IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, + IbcPacketTimeoutMsg, IbcReceiveResponse, Reply, Response, SubMsg, Uint128, WasmMsg, }; use crate::amount::Amount; use crate::error::{ContractError, Never}; -use crate::state::{ChannelInfo, ALLOW_LIST, CHANNEL_INFO, CHANNEL_STATE}; +use crate::state::{ + increase_channel_balance, reduce_channel_balance, ChannelInfo, ReplyArgs, ALLOW_LIST, + CHANNEL_INFO, REPLY_ARGS, +}; use cw20::Cw20ExecuteMsg; pub const ICS20_VERSION: &str = "ics20-1"; @@ -76,20 +79,39 @@ const RECEIVE_ID: u64 = 1337; const ACK_FAILURE_ID: u64 = 0xfa17; #[cfg_attr(not(feature = "library"), entry_point)] -pub fn reply(_deps: DepsMut, _env: Env, reply: Reply) -> Result { - match reply.result { - ContractResult::Ok(_) => Ok(Response::new()), - ContractResult::Err(err) => { - let res = Response::new().set_data(ack_fail(err)); - match reply.id { - RECEIVE_ID => { - // TODO: revert state change - Ok(res) - } - ACK_FAILURE_ID => Ok(res), - _ => Err(ContractError::UnknownReplyId { id: reply.id }), +pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> Result { + match reply.id { + RECEIVE_ID => match reply.result { + ContractResult::Ok(_) => { + // Important design note: with ibcv2 and wasmd 0.22 we can implement this all much easier. + // No reply needed... the receive function and submessage should return error on failure and all + // state gets reverted with a proper app-level message auto-generated + + // Since we need compatibility with Juno (Jan 2022), we need to ensure that no state gets written + // if the receive processing succeeds, but the submesage fails, so we can only write after we are + // sure all submessages succeeded. + + // However, this requires passing some state between the ibc_packet_receive function and + // the reply handler. We do this with a singleton, with is "okay" for IBC as there is no + // reentrancy on these functions (cannot be called by another contract). This pattern + // should not be used for ExecuteMsg handlers + let reply_args = REPLY_ARGS.load(deps.storage)?; + reduce_channel_balance( + deps.storage, + &reply_args.channel, + &reply_args.denom, + reply_args.amount, + )?; + + Ok(Response::new()) } - } + ContractResult::Err(err) => Ok(Response::new().set_data(ack_fail(err))), + }, + ACK_FAILURE_ID => match reply.result { + ContractResult::Ok(_) => Ok(Response::new()), + ContractResult::Err(err) => Ok(Response::new().set_data(ack_fail(err))), + }, + _ => Err(ContractError::UnknownReplyId { id: reply.id }), } } @@ -216,30 +238,23 @@ fn do_ibc_packet_receive( // If it originated on our chain, it looks like "port/channel/ucosm". let denom = parse_voucher_denom(&msg.denom, &packet.src)?; - // Important design note: with ibcv2 and wasmd 0.22 we should return error so this gets reverted - // If we need compatibility with Juno (Jan 2022), we need to ensure that this state change gets reverted - // in the case of the submessage (transfer) erroring - CHANNEL_STATE.update( - deps.storage, - (&channel, denom), - |orig| -> Result<_, ContractError> { - // this will return error if we don't have the funds there to cover the request (or no denom registered) - let mut cur = orig.ok_or(ContractError::InsufficientFunds {})?; - cur.outstanding = cur - .outstanding - .checked_sub(msg.amount) - .or(Err(ContractError::InsufficientFunds {}))?; - Ok(cur) - }, - )?; + // we need to save the data to update the balances in reply + let reply_args = ReplyArgs { + channel, + denom: denom.to_string(), + amount: msg.amount, + }; + REPLY_ARGS.save(deps.storage, &reply_args)?; let to_send = Amount::from_parts(denom.to_string(), msg.amount); let gas_limit = check_gas_limit(deps.as_ref(), &to_send)?; - let send = send_amount(to_send, msg.receiver.clone(), gas_limit, RECEIVE_ID); + let send = send_amount(to_send, msg.receiver.clone()); + let mut submsg = SubMsg::reply_always(send, RECEIVE_ID); + submsg.gas_limit = gas_limit; let res = IbcReceiveResponse::new() .set_ack(ack_success()) - .add_submessage(send) + .add_submessage(submsg) .add_attribute("action", "receive") .add_attribute("sender", msg.sender) .add_attribute("receiver", msg.receiver) @@ -271,7 +286,9 @@ pub fn ibc_packet_ack( _env: Env, msg: IbcPacketAckMsg, ) -> Result { - // TODO: trap error like in receive? + // Design decision: should we trap error like in receive? + // TODO: unsure... as it is now a failed ack handling would revert the tx and would be + // retried again and again. is that good? let ics20msg: Ics20Ack = from_binary(&msg.acknowledgement.data)?; match ics20msg { Ics20Ack::Result(_) => on_packet_success(deps, msg.original_packet), @@ -286,7 +303,7 @@ pub fn ibc_packet_timeout( _env: Env, msg: IbcPacketTimeoutMsg, ) -> Result { - // TODO: trap error like in receive? + // TODO: trap error like in receive? (same question as ack above) let packet = msg.packet; on_packet_failure(deps, packet, "timeout".to_string()) } @@ -304,15 +321,8 @@ fn on_packet_success(deps: DepsMut, packet: IbcPacket) -> Result StdResult<_> { - let mut state = orig.unwrap_or_default(); - state.outstanding += amount; - state.total_sent += amount; - Ok(state) - })?; + // we have made a proper transfer, record this + increase_channel_balance(deps.storage, &packet.src.channel_id, &msg.denom, msg.amount)?; Ok(IbcBasicResponse::new().add_attributes(attributes)) } @@ -327,11 +337,13 @@ fn on_packet_failure( let to_send = Amount::from_parts(msg.denom.clone(), msg.amount); let gas_limit = check_gas_limit(deps.as_ref(), &to_send)?; - let send = send_amount(to_send, msg.sender.clone(), gas_limit, ACK_FAILURE_ID); + let send = send_amount(to_send, msg.sender.clone()); + let mut submsg = SubMsg::reply_on_error(send, ACK_FAILURE_ID); + submsg.gas_limit = gas_limit; // similar event messages like ibctransfer module let res = IbcBasicResponse::new() - .add_submessage(send) + .add_submessage(submsg) .add_attribute("action", "acknowledge") .add_attribute("sender", msg.sender) .add_attribute("receiver", msg.receiver) @@ -343,28 +355,24 @@ fn on_packet_failure( Ok(res) } -fn send_amount(amount: Amount, recipient: String, gas_limit: Option, reply_id: u64) -> SubMsg { +fn send_amount(amount: Amount, recipient: String) -> CosmosMsg { match amount { - Amount::Native(coin) => SubMsg::reply_on_error( - BankMsg::Send { - to_address: recipient, - amount: vec![coin], - }, - reply_id, - ), + Amount::Native(coin) => BankMsg::Send { + to_address: recipient, + amount: vec![coin], + } + .into(), Amount::Cw20(coin) => { let msg = Cw20ExecuteMsg::Transfer { recipient, amount: coin.amount, }; - let exec = WasmMsg::Execute { + WasmMsg::Execute { contract_addr: coin.address, msg: to_binary(&msg).unwrap(), funds: vec![], - }; - let mut sub = SubMsg::reply_on_error(exec, reply_id); - sub.gas_limit = gas_limit; - sub + } + .into() } } } diff --git a/contracts/cw20-ics20/src/state.rs b/contracts/cw20-ics20/src/state.rs index b87307a65..37e8874b3 100644 --- a/contracts/cw20-ics20/src/state.rs +++ b/contracts/cw20-ics20/src/state.rs @@ -1,11 +1,15 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{Addr, IbcEndpoint, Uint128}; +use crate::ContractError; +use cosmwasm_std::{Addr, IbcEndpoint, StdResult, Storage, Uint128}; use cw_storage_plus::{Item, Map}; pub const CONFIG: Item = Item::new("ics20_config"); +// Used to pass info from the ibc_packet_receive to the reply handler +pub const REPLY_ARGS: Item = Item::new("reply_args"); + /// static info on one channel that doesn't change pub const CHANNEL_INFO: Map<&str, ChannelInfo> = Map::new("channel_info"); @@ -41,3 +45,47 @@ pub struct ChannelInfo { pub struct AllowInfo { pub gas_limit: Option, } + +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub struct ReplyArgs { + pub channel: String, + pub denom: String, + pub amount: Uint128, +} + +pub fn reduce_channel_balance( + storage: &mut dyn Storage, + channel: &str, + denom: &str, + amount: Uint128, +) -> Result<(), ContractError> { + CHANNEL_STATE.update( + storage, + (channel, denom), + |orig| -> Result<_, ContractError> { + // this will return error if we don't have the funds there to cover the request (or no denom registered) + let mut cur = orig.ok_or(ContractError::InsufficientFunds {})?; + cur.outstanding = cur + .outstanding + .checked_sub(amount) + .or(Err(ContractError::InsufficientFunds {}))?; + Ok(cur) + }, + )?; + Ok(()) +} + +pub fn increase_channel_balance( + storage: &mut dyn Storage, + channel: &str, + denom: &str, + amount: Uint128, +) -> Result<(), ContractError> { + CHANNEL_STATE.update(storage, (channel, denom), |orig| -> StdResult<_> { + let mut state = orig.unwrap_or_default(); + state.outstanding += amount; + state.total_sent += amount; + Ok(state) + })?; + Ok(()) +} From 978afcd88ccc25d9c35eee140722d54c4d0e3d5d Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sun, 16 Jan 2022 00:18:52 +0100 Subject: [PATCH 170/352] Logic should be properly implemented, need to call reply in mock tests --- contracts/cw20-ics20/src/ibc.rs | 15 +++++++++++---- contracts/cw20-ics20/src/state.rs | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index cf69993b7..fc993beff 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -11,8 +11,8 @@ use cosmwasm_std::{ use crate::amount::Amount; use crate::error::{ContractError, Never}; use crate::state::{ - increase_channel_balance, reduce_channel_balance, ChannelInfo, ReplyArgs, ALLOW_LIST, - CHANNEL_INFO, REPLY_ARGS, + ensure_channel_balance, increase_channel_balance, reduce_channel_balance, ChannelInfo, + ReplyArgs, ALLOW_LIST, CHANNEL_INFO, REPLY_ARGS, }; use cw20::Cw20ExecuteMsg; @@ -238,6 +238,9 @@ fn do_ibc_packet_receive( // If it originated on our chain, it looks like "port/channel/ucosm". let denom = parse_voucher_denom(&msg.denom, &packet.src)?; + // make sure we have enough balance for this (that is, the later reduction in the reply handler should succeed) + ensure_channel_balance(deps.storage, &channel, denom, msg.amount)?; + // we need to save the data to update the balances in reply let reply_args = ReplyArgs { channel, @@ -428,13 +431,13 @@ mod test { msg: to_binary(&msg).unwrap(), funds: vec![], }; - let mut msg = SubMsg::reply_on_error(exec, RECEIVE_ID); + let mut msg = SubMsg::reply_always(exec, RECEIVE_ID); msg.gas_limit = gas_limit; msg } fn native_payment(amount: u128, denom: &str, recipient: &str) -> SubMsg { - SubMsg::reply_on_error( + SubMsg::reply_always( BankMsg::Send { to_address: recipient.into(), amount: coins(amount, denom), @@ -546,6 +549,8 @@ mod test { let ack: Ics20Ack = from_binary(&res.acknowledgement).unwrap(); matches!(ack, Ics20Ack::Result(_)); + // TODO: we need to call the reply block + // query channel state let state = query_channel(deps.as_ref(), send_channel.to_string()).unwrap(); assert_eq!(state.balances, vec![Amount::cw20(111111111, cw20_addr)]); @@ -600,6 +605,8 @@ mod test { let ack: Ics20Ack = from_binary(&res.acknowledgement).unwrap(); matches!(ack, Ics20Ack::Result(_)); + // TODO: we must call the reply block + // query channel state let state = query_channel(deps.as_ref(), send_channel.to_string()).unwrap(); assert_eq!(state.balances, vec![Amount::native(111111111, denom)]); diff --git a/contracts/cw20-ics20/src/state.rs b/contracts/cw20-ics20/src/state.rs index 37e8874b3..7f455beca 100644 --- a/contracts/cw20-ics20/src/state.rs +++ b/contracts/cw20-ics20/src/state.rs @@ -53,6 +53,23 @@ pub struct ReplyArgs { pub amount: Uint128, } +// this is like reduce_channel_balance, but doesn't change the state +// it returns an error IFF reduce_channel_balance would return an error +pub fn ensure_channel_balance( + storage: &dyn Storage, + channel: &str, + denom: &str, + amount: Uint128, +) -> Result<(), ContractError> { + CHANNEL_STATE + .may_load(storage, (channel, denom))? + .ok_or(ContractError::InsufficientFunds {})? + .outstanding + .checked_sub(amount) + .map_err(|_| ContractError::InsufficientFunds {})?; + Ok(()) +} + pub fn reduce_channel_balance( storage: &mut dyn Storage, channel: &str, From 315be1af1e8da84692fec49e5cfaa9fc4f4e9c1e Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 27 Jan 2022 20:35:53 +0100 Subject: [PATCH 171/352] Update state on receive, undo on submessage error --- contracts/cw20-ics20/src/ibc.rs | 18 +++++++++--------- contracts/cw20-ics20/src/state.rs | 23 +++++++++++------------ 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index fc993beff..a05fc0023 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -11,7 +11,7 @@ use cosmwasm_std::{ use crate::amount::Amount; use crate::error::{ContractError, Never}; use crate::state::{ - ensure_channel_balance, increase_channel_balance, reduce_channel_balance, ChannelInfo, + increase_channel_balance, reduce_channel_balance, undo_reduce_channel_balance, ChannelInfo, ReplyArgs, ALLOW_LIST, CHANNEL_INFO, REPLY_ARGS, }; use cw20::Cw20ExecuteMsg; @@ -82,30 +82,30 @@ const ACK_FAILURE_ID: u64 = 0xfa17; pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> Result { match reply.id { RECEIVE_ID => match reply.result { - ContractResult::Ok(_) => { + ContractResult::Ok(_) => Ok(Response::new()), + ContractResult::Err(err) => { // Important design note: with ibcv2 and wasmd 0.22 we can implement this all much easier. // No reply needed... the receive function and submessage should return error on failure and all // state gets reverted with a proper app-level message auto-generated - // Since we need compatibility with Juno (Jan 2022), we need to ensure that no state gets written - // if the receive processing succeeds, but the submesage fails, so we can only write after we are - // sure all submessages succeeded. + // Since we need compatibility with Juno (Jan 2022), we need to ensure that optimisitic + // state updates in ibc_packet_receive get reverted in the (unlikely) chance of an + // error while sending the token // However, this requires passing some state between the ibc_packet_receive function and // the reply handler. We do this with a singleton, with is "okay" for IBC as there is no // reentrancy on these functions (cannot be called by another contract). This pattern // should not be used for ExecuteMsg handlers let reply_args = REPLY_ARGS.load(deps.storage)?; - reduce_channel_balance( + undo_reduce_channel_balance( deps.storage, &reply_args.channel, &reply_args.denom, reply_args.amount, )?; - Ok(Response::new()) + Ok(Response::new().set_data(ack_fail(err))) } - ContractResult::Err(err) => Ok(Response::new().set_data(ack_fail(err))), }, ACK_FAILURE_ID => match reply.result { ContractResult::Ok(_) => Ok(Response::new()), @@ -239,7 +239,7 @@ fn do_ibc_packet_receive( let denom = parse_voucher_denom(&msg.denom, &packet.src)?; // make sure we have enough balance for this (that is, the later reduction in the reply handler should succeed) - ensure_channel_balance(deps.storage, &channel, denom, msg.amount)?; + reduce_channel_balance(deps.storage, &channel, denom, msg.amount)?; // we need to save the data to update the balances in reply let reply_args = ReplyArgs { diff --git a/contracts/cw20-ics20/src/state.rs b/contracts/cw20-ics20/src/state.rs index 7f455beca..79c127d8c 100644 --- a/contracts/cw20-ics20/src/state.rs +++ b/contracts/cw20-ics20/src/state.rs @@ -53,20 +53,18 @@ pub struct ReplyArgs { pub amount: Uint128, } -// this is like reduce_channel_balance, but doesn't change the state -// it returns an error IFF reduce_channel_balance would return an error -pub fn ensure_channel_balance( - storage: &dyn Storage, +pub fn increase_channel_balance( + storage: &mut dyn Storage, channel: &str, denom: &str, amount: Uint128, ) -> Result<(), ContractError> { - CHANNEL_STATE - .may_load(storage, (channel, denom))? - .ok_or(ContractError::InsufficientFunds {})? - .outstanding - .checked_sub(amount) - .map_err(|_| ContractError::InsufficientFunds {})?; + CHANNEL_STATE.update(storage, (channel, denom), |orig| -> StdResult<_> { + let mut state = orig.unwrap_or_default(); + state.outstanding += amount; + state.total_sent += amount; + Ok(state) + })?; Ok(()) } @@ -92,7 +90,9 @@ pub fn reduce_channel_balance( Ok(()) } -pub fn increase_channel_balance( +// this is like increase, but it only "un-subtracts" (= adds) outstanding, not total_sent +// calling `reduce_channel_balance` and then `undo_reduce_channel_balance` should leave state unchanged. +pub fn undo_reduce_channel_balance( storage: &mut dyn Storage, channel: &str, denom: &str, @@ -101,7 +101,6 @@ pub fn increase_channel_balance( CHANNEL_STATE.update(storage, (channel, denom), |orig| -> StdResult<_> { let mut state = orig.unwrap_or_default(); state.outstanding += amount; - state.total_sent += amount; Ok(state) })?; Ok(()) From a0ca1dcc4bb8d8a06a9e4b788a30f261a659b16b Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 27 Jan 2022 20:40:43 +0100 Subject: [PATCH 172/352] reply_on_error not always --- contracts/cw20-ics20/src/ibc.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index a05fc0023..ebc3139cb 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -238,7 +238,7 @@ fn do_ibc_packet_receive( // If it originated on our chain, it looks like "port/channel/ucosm". let denom = parse_voucher_denom(&msg.denom, &packet.src)?; - // make sure we have enough balance for this (that is, the later reduction in the reply handler should succeed) + // make sure we have enough balance for this reduce_channel_balance(deps.storage, &channel, denom, msg.amount)?; // we need to save the data to update the balances in reply @@ -252,7 +252,7 @@ fn do_ibc_packet_receive( let to_send = Amount::from_parts(denom.to_string(), msg.amount); let gas_limit = check_gas_limit(deps.as_ref(), &to_send)?; let send = send_amount(to_send, msg.receiver.clone()); - let mut submsg = SubMsg::reply_always(send, RECEIVE_ID); + let mut submsg = SubMsg::reply_on_error(send, RECEIVE_ID); submsg.gas_limit = gas_limit; let res = IbcReceiveResponse::new() @@ -431,13 +431,13 @@ mod test { msg: to_binary(&msg).unwrap(), funds: vec![], }; - let mut msg = SubMsg::reply_always(exec, RECEIVE_ID); + let mut msg = SubMsg::reply_on_error(exec, RECEIVE_ID); msg.gas_limit = gas_limit; msg } fn native_payment(amount: u128, denom: &str, recipient: &str) -> SubMsg { - SubMsg::reply_always( + SubMsg::reply_on_error( BankMsg::Send { to_address: recipient.into(), amount: coins(amount, denom), From b84dc61f9dce166f4ea3ccbd096a52ad3c73d843 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jan 2022 08:23:28 +0100 Subject: [PATCH 173/352] Fix remove_hook helper --- packages/cw4/src/helpers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cw4/src/helpers.rs b/packages/cw4/src/helpers.rs index 93514a36c..c692f29e7 100644 --- a/packages/cw4/src/helpers.rs +++ b/packages/cw4/src/helpers.rs @@ -43,7 +43,7 @@ impl Cw4Contract { } pub fn remove_hook>(&self, addr: T) -> StdResult { - let msg = Cw4ExecuteMsg::AddHook { addr: addr.into() }; + let msg = Cw4ExecuteMsg::RemoveHook { addr: addr.into() }; self.encode_msg(msg) } From 95593735b7bad451e029e885f46538d9c219bec6 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 6 Jan 2022 15:06:55 +0100 Subject: [PATCH 174/352] Add Bounder trait Implement bounder for primitive types --- packages/storage-plus/src/keys.rs | 84 +++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index e4240abb1..89677c934 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -3,6 +3,7 @@ use cosmwasm_std::Addr; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; use crate::int_key::CwIntKey; +use crate::Bound; #[derive(Debug)] pub enum Key<'a> { @@ -300,6 +301,89 @@ macro_rules! integer_prefix { integer_prefix!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64); +pub trait Bounder<'a> { + fn inclusive_bound(&self) -> Option; + fn exclusive_bound(&self) -> Option; +} + +impl<'a> Bounder<'a> for () { + fn inclusive_bound(&self) -> Option { + None + } + fn exclusive_bound(&self) -> Option { + None + } +} + +impl<'a> Bounder<'a> for &'a [u8] { + fn inclusive_bound(&self) -> Option { + Some(Bound::inclusive(self.to_vec())) + } + fn exclusive_bound(&self) -> Option { + Some(Bound::exclusive(self.to_vec())) + } +} + +impl<'a> Bounder<'a> for &'a str { + fn inclusive_bound(&self) -> Option { + Some(Bound::inclusive(self.as_bytes().to_vec())) + } + fn exclusive_bound(&self) -> Option { + Some(Bound::exclusive(self.as_bytes().to_vec())) + } +} + +impl<'a> Bounder<'a> for String { + fn inclusive_bound(&self) -> Option { + Some(Bound::inclusive(self.as_bytes().to_vec())) + } + fn exclusive_bound(&self) -> Option { + Some(Bound::exclusive(self.as_bytes().to_vec())) + } +} + +impl<'a> Bounder<'a> for Vec { + fn inclusive_bound(&self) -> Option { + Some(Bound::inclusive(self.clone())) + } + fn exclusive_bound(&self) -> Option { + Some(Bound::exclusive(self.clone())) + } +} + +impl<'a> Bounder<'a> for &'a Addr { + fn inclusive_bound(&self) -> Option { + Some(Bound::Inclusive(self.as_ref().into())) + } + fn exclusive_bound(&self) -> Option { + Some(Bound::Exclusive(self.as_ref().into())) + } +} + +impl<'a> Bounder<'a> for Addr { + fn inclusive_bound(&self) -> Option { + Some(Bound::Inclusive(self.as_ref().into())) + } + fn exclusive_bound(&self) -> Option { + Some(Bound::Exclusive(self.as_ref().into())) + } +} + +macro_rules! integer_bound { + (for $($t:ty),+) => { + $(impl<'a> Bounder<'a> for $t { + fn inclusive_bound(&self) -> Option { + Some(Bound::inclusive_int(*self)) + } + fn exclusive_bound(&self) -> Option { + Some(Bound::exclusive_int(*self)) + } + })* + } +} + +integer_bound!(for i8, u8, i16, u16, i32, u32, i64, u64); + #[cfg(test)] mod test { use super::*; From 3a57e4fdaa5e1212299a509633ba32616dbb9dd5 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 6 Jan 2022 15:12:02 +0100 Subject: [PATCH 175/352] Implement Bounder for composite types --- packages/storage-plus/src/keys.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index 89677c934..2a1adf991 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -324,6 +324,24 @@ impl<'a> Bounder<'a> for &'a [u8] { } } +impl<'a, T: Prefixer<'a>, U: Prefixer<'a>> Bounder<'a> for (T, U) { + fn inclusive_bound(&self) -> Option { + Some(Bound::Inclusive(self.joined_prefix())) + } + fn exclusive_bound(&self) -> Option { + Some(Bound::Exclusive(self.joined_prefix())) + } +} + +impl<'a, T: Prefixer<'a>, U: Prefixer<'a>, V: Prefixer<'a>> Bounder<'a> for (T, U, V) { + fn inclusive_bound(&self) -> Option { + Some(Bound::Inclusive(self.joined_prefix())) + } + fn exclusive_bound(&self) -> Option { + Some(Bound::Exclusive(self.joined_prefix())) + } +} + impl<'a> Bounder<'a> for &'a str { fn inclusive_bound(&self) -> Option { Some(Bound::inclusive(self.as_bytes().to_vec())) From 60c42b6572e6e01d124b98fd4e94f85ff04c9b63 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 08:20:39 +0100 Subject: [PATCH 176/352] Implement type safe bounds for range --- packages/storage-plus/src/keys.rs | 2 +- packages/storage-plus/src/map.rs | 24 ++++++++++++- packages/storage-plus/src/prefix.rs | 55 ++++++++++++++++++++++++++++- 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index 2a1adf991..7a361c46d 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -301,7 +301,7 @@ macro_rules! integer_prefix { integer_prefix!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64); -pub trait Bounder<'a> { +pub trait Bounder<'a>: Prefixer<'a> { fn inclusive_bound(&self) -> Option; fn exclusive_bound(&self) -> Option; } diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 45a89c294..4352baf24 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -9,8 +9,9 @@ use crate::helpers::query_raw; use crate::iter_helpers::{deserialize_kv, deserialize_v}; #[cfg(feature = "iterator")] use crate::keys::Prefixer; -use crate::keys::{Key, PrimaryKey}; +use crate::keys::{Bounder, Key, PrimaryKey}; use crate::path::Path; +use crate::prefix::Bound2; #[cfg(feature = "iterator")] use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; use cosmwasm_std::{from_slice, Addr, QuerierWrapper, StdError, StdResult, Storage}; @@ -244,6 +245,27 @@ where } } +#[cfg(feature = "iterator")] +impl<'a, K, T> Map<'a, K, T> +where + T: Serialize + DeserializeOwned, + K: PrimaryKey<'a> + KeyDeserialize + Bounder<'a>, +{ + pub fn range2<'c>( + &self, + store: &'c dyn Storage, + min: Option>, + max: Option>, + order: cosmwasm_std::Order, + ) -> Box> + 'c> + where + T: 'c, + K::Output: 'static, + { + self.no_prefix().range2(store, min, max, order) + } +} + #[cfg(test)] mod test { use super::*; diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 38e4b7c78..bfc5b47cc 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -10,7 +10,7 @@ use crate::de::KeyDeserialize; use crate::helpers::{namespaces_with_key, nested_namespaces_with_key}; use crate::int_key::CwIntKey; use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim}; -use crate::keys::Key; +use crate::keys::{Bounder, Key}; use crate::{Endian, Prefixer}; /// Bound is used to defines the two ends of a range, more explicit than Option @@ -45,6 +45,29 @@ impl Bound { } } +#[derive(Clone, Debug)] +pub enum Bound2<'a, K: Bounder<'a>> { + Inclusive((K, PhantomData<&'a bool>)), + Exclusive((K, PhantomData<&'a bool>)), +} + +impl<'a, K: Bounder<'a>> Bound2<'a, K> { + pub fn inclusive>(k: T) -> Self { + Self::Inclusive((k.into(), PhantomData)) + } + + pub fn exclusive>(k: T) -> Self { + Self::Exclusive((k.into(), PhantomData)) + } + + pub fn to_bound(&self) -> Bound { + match self { + Bound2::Exclusive((k, _)) => Bound::Exclusive(k.joined_prefix()), + Bound2::Inclusive((k, _)) => Bound::Inclusive(k.joined_prefix()), + } + } +} + #[derive(Clone, Debug)] pub enum PrefixBound<'a, K: Prefixer<'a>> { Inclusive((K, PhantomData<&'a bool>)), @@ -215,6 +238,36 @@ where } } +impl<'p, K, T> Prefix +where + K: KeyDeserialize + Bounder<'p>, + T: Serialize + DeserializeOwned, +{ + pub fn range2<'a>( + &self, + store: &'a dyn Storage, + min: Option>, + max: Option>, + order: Order, + ) -> Box> + 'a> + where + T: 'a, + K::Output: 'static, + { + let de_fn = self.de_fn_kv; + let pk_name = self.pk_name.clone(); + let mapped = range_with_prefix( + store, + &self.storage_prefix, + min.map(|b| b.to_bound()), + max.map(|b| b.to_bound()), + order, + ) + .map(move |kv| (de_fn)(store, &pk_name, kv)); + Box::new(mapped) + } +} + pub fn range_with_prefix<'a>( storage: &'a dyn Storage, namespace: &[u8], From f362fdf512a085ca68ae04067fe4a5734cce1d6f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 08:23:27 +0100 Subject: [PATCH 177/352] Move Bounder impls to experimental Bound2 --- packages/storage-plus/src/keys.rs | 90 ++++++++++++++++--------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index 7a361c46d..b84bb4ffa 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -3,7 +3,7 @@ use cosmwasm_std::Addr; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; use crate::int_key::CwIntKey; -use crate::Bound; +use crate::prefix::Bound2; #[derive(Debug)] pub enum Key<'a> { @@ -301,100 +301,102 @@ macro_rules! integer_prefix { integer_prefix!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64); -pub trait Bounder<'a>: Prefixer<'a> { - fn inclusive_bound(&self) -> Option; - fn exclusive_bound(&self) -> Option; +pub trait Bounder<'a>: Prefixer<'a> + Sized { + fn inclusive_bound(&self) -> Option>; + fn exclusive_bound(&self) -> Option>; } impl<'a> Bounder<'a> for () { - fn inclusive_bound(&self) -> Option { + fn inclusive_bound(&self) -> Option> { None } - fn exclusive_bound(&self) -> Option { + fn exclusive_bound(&self) -> Option> { None } } impl<'a> Bounder<'a> for &'a [u8] { - fn inclusive_bound(&self) -> Option { - Some(Bound::inclusive(self.to_vec())) + fn inclusive_bound(&self) -> Option> { + Some(Bound2::inclusive(*self)) } - fn exclusive_bound(&self) -> Option { - Some(Bound::exclusive(self.to_vec())) + fn exclusive_bound(&self) -> Option> { + Some(Bound2::exclusive(*self)) } } -impl<'a, T: Prefixer<'a>, U: Prefixer<'a>> Bounder<'a> for (T, U) { - fn inclusive_bound(&self) -> Option { - Some(Bound::Inclusive(self.joined_prefix())) +impl<'a, T: Prefixer<'a> + Clone, U: Prefixer<'a> + Clone> Bounder<'a> for (T, U) { + fn inclusive_bound(&self) -> Option> { + Some(Bound2::inclusive(self.clone())) } - fn exclusive_bound(&self) -> Option { - Some(Bound::Exclusive(self.joined_prefix())) + fn exclusive_bound(&self) -> Option> { + Some(Bound2::exclusive(self.clone())) } } -impl<'a, T: Prefixer<'a>, U: Prefixer<'a>, V: Prefixer<'a>> Bounder<'a> for (T, U, V) { - fn inclusive_bound(&self) -> Option { - Some(Bound::Inclusive(self.joined_prefix())) +impl<'a, T: Prefixer<'a> + Clone, U: Prefixer<'a> + Clone, V: Prefixer<'a> + Clone> Bounder<'a> + for (T, U, V) +{ + fn inclusive_bound(&self) -> Option> { + Some(Bound2::inclusive(self.clone())) } - fn exclusive_bound(&self) -> Option { - Some(Bound::Exclusive(self.joined_prefix())) + fn exclusive_bound(&self) -> Option> { + Some(Bound2::exclusive(self.clone())) } } impl<'a> Bounder<'a> for &'a str { - fn inclusive_bound(&self) -> Option { - Some(Bound::inclusive(self.as_bytes().to_vec())) + fn inclusive_bound(&self) -> Option> { + Some(Bound2::inclusive(*self)) } - fn exclusive_bound(&self) -> Option { - Some(Bound::exclusive(self.as_bytes().to_vec())) + fn exclusive_bound(&self) -> Option> { + Some(Bound2::exclusive(*self)) } } impl<'a> Bounder<'a> for String { - fn inclusive_bound(&self) -> Option { - Some(Bound::inclusive(self.as_bytes().to_vec())) + fn inclusive_bound(&self) -> Option> { + Some(Bound2::inclusive(self.clone())) } - fn exclusive_bound(&self) -> Option { - Some(Bound::exclusive(self.as_bytes().to_vec())) + fn exclusive_bound(&self) -> Option> { + Some(Bound2::exclusive(self.clone())) } } impl<'a> Bounder<'a> for Vec { - fn inclusive_bound(&self) -> Option { - Some(Bound::inclusive(self.clone())) + fn inclusive_bound(&self) -> Option> { + Some(Bound2::inclusive(self.clone())) } - fn exclusive_bound(&self) -> Option { - Some(Bound::exclusive(self.clone())) + fn exclusive_bound(&self) -> Option> { + Some(Bound2::exclusive(self.clone())) } } impl<'a> Bounder<'a> for &'a Addr { - fn inclusive_bound(&self) -> Option { - Some(Bound::Inclusive(self.as_ref().into())) + fn inclusive_bound(&self) -> Option> { + Some(Bound2::inclusive(*self)) } - fn exclusive_bound(&self) -> Option { - Some(Bound::Exclusive(self.as_ref().into())) + fn exclusive_bound(&self) -> Option> { + Some(Bound2::exclusive(*self)) } } impl<'a> Bounder<'a> for Addr { - fn inclusive_bound(&self) -> Option { - Some(Bound::Inclusive(self.as_ref().into())) + fn inclusive_bound(&self) -> Option> { + Some(Bound2::inclusive(self.clone())) } - fn exclusive_bound(&self) -> Option { - Some(Bound::Exclusive(self.as_ref().into())) + fn exclusive_bound(&self) -> Option> { + Some(Bound2::exclusive(self.clone())) } } macro_rules! integer_bound { (for $($t:ty),+) => { $(impl<'a> Bounder<'a> for $t { - fn inclusive_bound(&self) -> Option { - Some(Bound::inclusive_int(*self)) + fn inclusive_bound(&self) -> Option> { + Some(Bound2::inclusive(*self)) } - fn exclusive_bound(&self) -> Option { - Some(Bound::exclusive_int(*self)) + fn exclusive_bound(&self) -> Option> { + Some(Bound2::exclusive(*self)) } })* } From b70b387123b957fd04c4b8ad888048388c69b08a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 09:32:20 +0100 Subject: [PATCH 178/352] Use proper joined key for bounds --- packages/storage-plus/src/keys.rs | 17 +++++++++++++---- packages/storage-plus/src/prefix.rs | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index b84bb4ffa..b6e9fc9ad 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -301,7 +301,7 @@ macro_rules! integer_prefix { integer_prefix!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64); -pub trait Bounder<'a>: Prefixer<'a> + Sized { +pub trait Bounder<'a>: PrimaryKey<'a> + Sized { fn inclusive_bound(&self) -> Option>; fn exclusive_bound(&self) -> Option>; } @@ -324,7 +324,12 @@ impl<'a> Bounder<'a> for &'a [u8] { } } -impl<'a, T: Prefixer<'a> + Clone, U: Prefixer<'a> + Clone> Bounder<'a> for (T, U) { +impl< + 'a, + T: PrimaryKey<'a> + KeyDeserialize + Prefixer<'a> + Clone, + U: PrimaryKey<'a> + KeyDeserialize + Clone, + > Bounder<'a> for (T, U) +{ fn inclusive_bound(&self) -> Option> { Some(Bound2::inclusive(self.clone())) } @@ -333,8 +338,12 @@ impl<'a, T: Prefixer<'a> + Clone, U: Prefixer<'a> + Clone> Bounder<'a> for (T, U } } -impl<'a, T: Prefixer<'a> + Clone, U: Prefixer<'a> + Clone, V: Prefixer<'a> + Clone> Bounder<'a> - for (T, U, V) +impl< + 'a, + T: PrimaryKey<'a> + Prefixer<'a> + Clone, + U: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize + Clone, + V: PrimaryKey<'a> + KeyDeserialize + Clone, + > Bounder<'a> for (T, U, V) { fn inclusive_bound(&self) -> Option> { Some(Bound2::inclusive(self.clone())) diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index bfc5b47cc..234b20ce3 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -62,8 +62,8 @@ impl<'a, K: Bounder<'a>> Bound2<'a, K> { pub fn to_bound(&self) -> Bound { match self { - Bound2::Exclusive((k, _)) => Bound::Exclusive(k.joined_prefix()), - Bound2::Inclusive((k, _)) => Bound::Inclusive(k.joined_prefix()), + Bound2::Exclusive((k, _)) => Bound::Exclusive(k.joined_key()), + Bound2::Inclusive((k, _)) => Bound::Inclusive(k.joined_key()), } } } From ae80d8306497b02ce8b04cc6069fa9bd2811b930 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 09:56:31 +0100 Subject: [PATCH 179/352] Remove self reference --- packages/storage-plus/src/keys.rs | 80 +++++++++++++++---------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index b6e9fc9ad..e10e1b02a 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -302,25 +302,25 @@ macro_rules! integer_prefix { integer_prefix!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64); pub trait Bounder<'a>: PrimaryKey<'a> + Sized { - fn inclusive_bound(&self) -> Option>; - fn exclusive_bound(&self) -> Option>; + fn inclusive_bound(self) -> Option>; + fn exclusive_bound(self) -> Option>; } impl<'a> Bounder<'a> for () { - fn inclusive_bound(&self) -> Option> { + fn inclusive_bound(self) -> Option> { None } - fn exclusive_bound(&self) -> Option> { + fn exclusive_bound(self) -> Option> { None } } impl<'a> Bounder<'a> for &'a [u8] { - fn inclusive_bound(&self) -> Option> { - Some(Bound2::inclusive(*self)) + fn inclusive_bound(self) -> Option> { + Some(Bound2::inclusive(self)) } - fn exclusive_bound(&self) -> Option> { - Some(Bound2::exclusive(*self)) + fn exclusive_bound(self) -> Option> { + Some(Bound2::exclusive(self)) } } @@ -330,11 +330,11 @@ impl< U: PrimaryKey<'a> + KeyDeserialize + Clone, > Bounder<'a> for (T, U) { - fn inclusive_bound(&self) -> Option> { - Some(Bound2::inclusive(self.clone())) + fn inclusive_bound(self) -> Option> { + Some(Bound2::inclusive(self)) } - fn exclusive_bound(&self) -> Option> { - Some(Bound2::exclusive(self.clone())) + fn exclusive_bound(self) -> Option> { + Some(Bound2::exclusive(self)) } } @@ -345,67 +345,67 @@ impl< V: PrimaryKey<'a> + KeyDeserialize + Clone, > Bounder<'a> for (T, U, V) { - fn inclusive_bound(&self) -> Option> { - Some(Bound2::inclusive(self.clone())) + fn inclusive_bound(self) -> Option> { + Some(Bound2::inclusive(self)) } - fn exclusive_bound(&self) -> Option> { - Some(Bound2::exclusive(self.clone())) + fn exclusive_bound(self) -> Option> { + Some(Bound2::exclusive(self)) } } impl<'a> Bounder<'a> for &'a str { - fn inclusive_bound(&self) -> Option> { - Some(Bound2::inclusive(*self)) + fn inclusive_bound(self) -> Option> { + Some(Bound2::inclusive(self)) } - fn exclusive_bound(&self) -> Option> { - Some(Bound2::exclusive(*self)) + fn exclusive_bound(self) -> Option> { + Some(Bound2::exclusive(self)) } } impl<'a> Bounder<'a> for String { - fn inclusive_bound(&self) -> Option> { - Some(Bound2::inclusive(self.clone())) + fn inclusive_bound(self) -> Option> { + Some(Bound2::inclusive(self)) } - fn exclusive_bound(&self) -> Option> { - Some(Bound2::exclusive(self.clone())) + fn exclusive_bound(self) -> Option> { + Some(Bound2::exclusive(self)) } } impl<'a> Bounder<'a> for Vec { - fn inclusive_bound(&self) -> Option> { - Some(Bound2::inclusive(self.clone())) + fn inclusive_bound(self) -> Option> { + Some(Bound2::inclusive(self)) } - fn exclusive_bound(&self) -> Option> { - Some(Bound2::exclusive(self.clone())) + fn exclusive_bound(self) -> Option> { + Some(Bound2::exclusive(self)) } } impl<'a> Bounder<'a> for &'a Addr { - fn inclusive_bound(&self) -> Option> { - Some(Bound2::inclusive(*self)) + fn inclusive_bound(self) -> Option> { + Some(Bound2::inclusive(self)) } - fn exclusive_bound(&self) -> Option> { - Some(Bound2::exclusive(*self)) + fn exclusive_bound(self) -> Option> { + Some(Bound2::exclusive(self)) } } impl<'a> Bounder<'a> for Addr { - fn inclusive_bound(&self) -> Option> { - Some(Bound2::inclusive(self.clone())) + fn inclusive_bound(self) -> Option> { + Some(Bound2::inclusive(self)) } - fn exclusive_bound(&self) -> Option> { - Some(Bound2::exclusive(self.clone())) + fn exclusive_bound(self) -> Option> { + Some(Bound2::exclusive(self)) } } macro_rules! integer_bound { (for $($t:ty),+) => { $(impl<'a> Bounder<'a> for $t { - fn inclusive_bound(&self) -> Option> { - Some(Bound2::inclusive(*self)) + fn inclusive_bound(self) -> Option> { + Some(Bound2::inclusive(self)) } - fn exclusive_bound(&self) -> Option> { - Some(Bound2::exclusive(*self)) + fn exclusive_bound(self) -> Option> { + Some(Bound2::exclusive(self)) } })* } From 7d61cfdc133aeb68ecfebfa0cd88d96674797d61 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 09:57:15 +0100 Subject: [PATCH 180/352] Add range2 simple key tests --- packages/storage-plus/src/map.rs | 159 +++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 4352baf24..91f8f2132 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -544,6 +544,65 @@ mod test { assert_eq!(all, vec![(b"john".to_vec(), data)]); } + #[test] + #[cfg(feature = "iterator")] + fn range2_simple_string_key() { + let mut store = MockStorage::new(); + + // save and load on three keys + let data = Data { + name: "John".to_string(), + age: 32, + }; + PEOPLE.save(&mut store, b"john", &data).unwrap(); + + let data2 = Data { + name: "Jim".to_string(), + age: 44, + }; + PEOPLE.save(&mut store, b"jim", &data2).unwrap(); + + let data3 = Data { + name: "Ada".to_string(), + age: 23, + }; + PEOPLE.save(&mut store, b"ada", &data3).unwrap(); + + // let's try to iterate! + let all: StdResult> = PEOPLE + .range2(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(3, all.len()); + assert_eq!( + all, + vec![ + (b"ada".to_vec(), data3), + (b"jim".to_vec(), data2.clone()), + (b"john".to_vec(), data.clone()) + ] + ); + + // let's try to iterate over a range + let all: StdResult> = PEOPLE + .range2(&store, b"j".inclusive_bound(), None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(2, all.len()); + assert_eq!( + all, + vec![(b"jim".to_vec(), data2), (b"john".to_vec(), data.clone())] + ); + + // let's try to iterate over a more restrictive range + let all: StdResult> = PEOPLE + .range2(&store, b"jo".inclusive_bound(), None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(1, all.len()); + assert_eq!(all, vec![(b"john".to_vec(), data)]); + } + #[test] #[cfg(feature = "iterator")] fn range_simple_integer_key() { @@ -596,6 +655,48 @@ mod test { assert_eq!(1, all.len()); assert_eq!(all, vec![(1234, data)]); } + #[test] + #[cfg(feature = "iterator")] + fn range2_simple_integer_key() { + let mut store = MockStorage::new(); + + // save and load on two keys + let data = Data { + name: "John".to_string(), + age: 32, + }; + PEOPLE_ID.save(&mut store, 1234, &data).unwrap(); + + let data2 = Data { + name: "Jim".to_string(), + age: 44, + }; + PEOPLE_ID.save(&mut store, 56, &data2).unwrap(); + + // let's try to iterate! + let all: StdResult> = PEOPLE_ID + .range2(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(2, all.len()); + assert_eq!(all, vec![(56, data2.clone()), (1234, data.clone())]); + + // let's try to iterate over a range + let all: StdResult> = PEOPLE_ID + .range2(&store, 56u32.inclusive_bound(), None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(2, all.len()); + assert_eq!(all, vec![(56, data2), (1234, data.clone())]); + + // let's try to iterate over a more restrictive range + let all: StdResult> = PEOPLE_ID + .range2(&store, 57u32.inclusive_bound(), None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(1, all.len()); + assert_eq!(all, vec![(1234, data)]); + } #[test] #[cfg(feature = "iterator")] @@ -660,6 +761,64 @@ mod test { assert_eq!(all, vec![(50, data3)]); } + #[test] + #[cfg(feature = "iterator")] + fn range2_simple_signed_integer_key() { + let mut store = MockStorage::new(); + + // save and load on three keys + let data = Data { + name: "John".to_string(), + age: 32, + }; + SIGNED_ID.save(&mut store, -1234, &data).unwrap(); + + let data2 = Data { + name: "Jim".to_string(), + age: 44, + }; + SIGNED_ID.save(&mut store, -56, &data2).unwrap(); + + let data3 = Data { + name: "Jules".to_string(), + age: 55, + }; + SIGNED_ID.save(&mut store, 50, &data3).unwrap(); + + // let's try to iterate! + let all: StdResult> = SIGNED_ID + .range2(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(3, all.len()); + // order is correct + assert_eq!( + all, + vec![(-1234, data), (-56, data2.clone()), (50, data3.clone())] + ); + + // let's try to iterate over a range + let all: StdResult> = SIGNED_ID + .range2(&store, (-56i32).inclusive_bound(), None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(2, all.len()); + assert_eq!(all, vec![(-56, data2), (50, data3.clone())]); + + // let's try to iterate over a more restrictive range + let all: StdResult> = SIGNED_ID + .range2( + &store, + (-55i32).inclusive_bound(), + 50i32.inclusive_bound(), + Order::Descending, + ) + .collect(); + let all = all.unwrap(); + assert_eq!(1, all.len()); + assert_eq!(all, vec![(50, data3)]); + } + #[test] #[cfg(feature = "iterator")] fn range_signed_integer_key_migration() { From 25c340b4c5f12f12a2d35cf6fcb22867486d7b17 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 13:24:36 +0100 Subject: [PATCH 181/352] Add range2 composite key tests --- packages/storage-plus/src/map.rs | 166 +++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 91f8f2132..28a7d89dd 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -977,6 +977,71 @@ mod test { ); } + #[test] + #[cfg(feature = "iterator")] + fn range2_composite_key() { + let mut store = MockStorage::new(); + + // save and load on three keys, one under different owner + ALLOWANCE + .save(&mut store, (b"owner", b"spender"), &1000) + .unwrap(); + ALLOWANCE + .save(&mut store, (b"owner", b"spender2"), &3000) + .unwrap(); + ALLOWANCE + .save(&mut store, (b"owner2", b"spender"), &5000) + .unwrap(); + + // let's try to iterate! + let all: StdResult> = ALLOWANCE + .range2(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(3, all.len()); + assert_eq!( + all, + vec![ + ((b"owner".to_vec(), b"spender".to_vec()), 1000), + ((b"owner".to_vec(), b"spender2".to_vec()), 3000), + ((b"owner2".to_vec(), b"spender".to_vec()), 5000) + ] + ); + + // let's try to iterate over a prefix + let all: StdResult> = ALLOWANCE + .prefix(b"owner") + .range2(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(2, all.len()); + assert_eq!( + all, + vec![(b"spender".to_vec(), 1000), (b"spender2".to_vec(), 3000),] + ); + + // let's try to iterate over a prefixed restricted inclusive range + let all: StdResult> = ALLOWANCE + .prefix(b"owner") + .range2(&store, b"spender".inclusive_bound(), None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(2, all.len()); + assert_eq!( + all, + vec![(b"spender".to_vec(), 1000), (b"spender2".to_vec(), 3000),] + ); + + // let's try to iterate over a prefixed restricted exclusive range + let all: StdResult> = ALLOWANCE + .prefix(b"owner") + .range2(&store, b"spender".exclusive_bound(), None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(1, all.len()); + assert_eq!(all, vec![(b"spender2".to_vec(), 3000),]); + } + #[test] #[cfg(feature = "iterator")] fn range_raw_triple_key() { @@ -1122,6 +1187,107 @@ mod test { ); } + #[test] + #[cfg(feature = "iterator")] + fn range2_triple_key() { + let mut store = MockStorage::new(); + + // save and load on three keys, one under different owner + TRIPLE + .save(&mut store, (b"owner", 9u8, "recipient"), &1000) + .unwrap(); + TRIPLE + .save(&mut store, (b"owner", 9u8, "recipient2"), &3000) + .unwrap(); + TRIPLE + .save(&mut store, (b"owner", 10u8, "recipient3"), &3000) + .unwrap(); + TRIPLE + .save(&mut store, (b"owner2", 9u8, "recipient"), &5000) + .unwrap(); + + // let's try to iterate! + let all: StdResult> = TRIPLE + .range2(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(4, all.len()); + assert_eq!( + all, + vec![ + ((b"owner".to_vec(), 9, "recipient".to_string()), 1000), + ((b"owner".to_vec(), 9, "recipient2".to_string()), 3000), + ((b"owner".to_vec(), 10, "recipient3".to_string()), 3000), + ((b"owner2".to_vec(), 9, "recipient".to_string()), 5000) + ] + ); + + // let's iterate over a sub_prefix + let all: StdResult> = TRIPLE + .sub_prefix(b"owner") + .range2(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(3, all.len()); + assert_eq!( + all, + vec![ + ((9, "recipient".to_string()), 1000), + ((9, "recipient2".to_string()), 3000), + ((10, "recipient3".to_string()), 3000), + ] + ); + + // let's iterate over a prefix + let all: StdResult> = TRIPLE + .prefix((b"owner", 9)) + .range2(&store, None, None, Order::Ascending) + .collect(); + let all = all.unwrap(); + assert_eq!(2, all.len()); + assert_eq!( + all, + vec![ + ("recipient".to_string(), 1000), + ("recipient2".to_string(), 3000), + ] + ); + + // let's try to iterate over a prefixed restricted inclusive range + let all: StdResult> = TRIPLE + .prefix((b"owner", 9)) + .range2( + &store, + "recipient".inclusive_bound(), + None, + Order::Ascending, + ) + .collect(); + let all = all.unwrap(); + assert_eq!(2, all.len()); + assert_eq!( + all, + vec![ + ("recipient".to_string(), 1000), + ("recipient2".to_string(), 3000), + ] + ); + + // let's try to iterate over a prefixed restricted exclusive range + let all: StdResult> = TRIPLE + .prefix((b"owner", 9)) + .range2( + &store, + "recipient".exclusive_bound(), + None, + Order::Ascending, + ) + .collect(); + let all = all.unwrap(); + assert_eq!(1, all.len()); + assert_eq!(all, vec![("recipient2".to_string(), 3000),]); + } + #[test] fn basic_update() { let mut store = MockStorage::new(); From 73f1d654aaec1847414c609008c20cffed814203 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 15:59:30 +0100 Subject: [PATCH 182/352] Simplify Bound2 traits --- packages/storage-plus/src/prefix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 234b20ce3..e3f7b618a 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -11,7 +11,7 @@ use crate::helpers::{namespaces_with_key, nested_namespaces_with_key}; use crate::int_key::CwIntKey; use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim}; use crate::keys::{Bounder, Key}; -use crate::{Endian, Prefixer}; +use crate::{Endian, Prefixer, PrimaryKey}; /// Bound is used to defines the two ends of a range, more explicit than Option /// None means that we don't limit that side of the range at all. @@ -46,7 +46,7 @@ impl Bound { } #[derive(Clone, Debug)] -pub enum Bound2<'a, K: Bounder<'a>> { +pub enum Bound2<'a, K: PrimaryKey<'a>> { Inclusive((K, PhantomData<&'a bool>)), Exclusive((K, PhantomData<&'a bool>)), } From 2385b9da601527ad90aba8f1386ce696386c1c90 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 18:18:48 +0100 Subject: [PATCH 183/352] rename lifetime for clarity --- packages/storage-plus/src/prefix.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index e3f7b618a..0f78911bf 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -238,16 +238,16 @@ where } } -impl<'p, K, T> Prefix +impl<'b, K, T> Prefix where - K: KeyDeserialize + Bounder<'p>, + K: KeyDeserialize + Bounder<'b>, T: Serialize + DeserializeOwned, { pub fn range2<'a>( &self, store: &'a dyn Storage, - min: Option>, - max: Option>, + min: Option>, + max: Option>, order: Order, ) -> Box> + 'a> where From 1634af15d642ef4e39b27f5a558860637ed2b51e Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 19:32:27 +0100 Subject: [PATCH 184/352] Add specific type parameter for Prefix bound --- packages/storage-plus/src/map.rs | 6 +++--- packages/storage-plus/src/prefix.rs | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 28a7d89dd..7b686ccc4 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -116,11 +116,11 @@ where T: Serialize + DeserializeOwned, K: PrimaryKey<'a>, { - pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { + pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { Prefix::new(self.namespace, &p.prefix()) } - pub fn prefix(&self, p: K::Prefix) -> Prefix { + pub fn prefix(&self, p: K::Prefix) -> Prefix { Prefix::new(self.namespace, &p.prefix()) } } @@ -240,7 +240,7 @@ where self.no_prefix().keys(store, min, max, order) } - fn no_prefix(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::new(self.namespace, &[]) } } diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 0f78911bf..74c97fd52 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -113,7 +113,7 @@ pub fn default_deserializer_kv( } #[derive(Clone)] -pub struct Prefix +pub struct Prefix> where K: KeyDeserialize, T: Serialize + DeserializeOwned, @@ -121,7 +121,7 @@ where /// all namespaces prefixes and concatenated with the key storage_prefix: Vec, // see https://doc.rust-lang.org/std/marker/struct.PhantomData.html#unused-type-parameters for why this is needed - data: PhantomData, + data: PhantomData<(T, B)>, pk_name: Vec, de_fn_kv: DeserializeKvFn, de_fn_v: DeserializeVFn, @@ -139,7 +139,7 @@ where } } -impl Prefix +impl Prefix where K: KeyDeserialize, T: Serialize + DeserializeOwned, @@ -238,16 +238,17 @@ where } } -impl<'b, K, T> Prefix +impl<'b, K, T, B> Prefix where - K: KeyDeserialize + Bounder<'b>, + B: Bounder<'b>, + K: KeyDeserialize, T: Serialize + DeserializeOwned, { pub fn range2<'a>( &self, store: &'a dyn Storage, - min: Option>, - max: Option>, + min: Option>, + max: Option>, order: Order, ) -> Box> + 'a> where @@ -382,7 +383,7 @@ mod test { // manually create this - not testing nested prefixes here let prefix: Prefix, u64> = Prefix { storage_prefix: b"foo".to_vec(), - data: PhantomData::, + data: PhantomData::<(u64, _)>, pk_name: vec![], de_fn_kv: |_, _, kv| deserialize_kv::, u64>(kv), de_fn_v: |_, _, kv| deserialize_v(kv), From 3e06bee4c622ab460ae1b7be285baa6c756f5353 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 19:47:11 +0100 Subject: [PATCH 185/352] Implement type safe bounds for range_raw --- packages/storage-plus/src/map.rs | 15 ++++++++++++++- packages/storage-plus/src/prefix.rs | 23 +++++++++++++++++++++++ packages/storage-plus/src/snapshot/map.rs | 2 +- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 7b686ccc4..50be17dab 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -51,7 +51,7 @@ where } #[cfg(feature = "iterator")] - pub(crate) fn no_prefix_raw(&self) -> Prefix, T> { + pub(crate) fn no_prefix_raw(&self) -> Prefix, T, K> { Prefix::new(self.namespace, &[]) } @@ -251,6 +251,19 @@ where T: Serialize + DeserializeOwned, K: PrimaryKey<'a> + KeyDeserialize + Bounder<'a>, { + pub fn range2_raw<'c>( + &self, + store: &'c dyn Storage, + min: Option>, + max: Option>, + order: cosmwasm_std::Order, + ) -> Box>> + 'c> + where + T: 'c, + { + self.no_prefix_raw().range2_raw(store, min, max, order) + } + pub fn range2<'c>( &self, store: &'c dyn Storage, diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 74c97fd52..3adb20420 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -244,6 +244,29 @@ where K: KeyDeserialize, T: Serialize + DeserializeOwned, { + pub fn range2_raw<'a>( + &self, + store: &'a dyn Storage, + min: Option>, + max: Option>, + order: Order, + ) -> Box>> + 'a> + where + T: 'a, + { + let de_fn = self.de_fn_v; + let pk_name = self.pk_name.clone(); + let mapped = range_with_prefix( + store, + &self.storage_prefix, + min.map(|b| b.to_bound()), + max.map(|b| b.to_bound()), + order, + ) + .map(move |kv| (de_fn)(store, &pk_name, kv)); + Box::new(mapped) + } + pub fn range2<'a>( &self, store: &'a dyn Storage, diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index 64a042da4..6536099f6 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -73,7 +73,7 @@ where self.primary.key(k) } - fn no_prefix_raw(&self) -> Prefix, T> { + fn no_prefix_raw(&self) -> Prefix, T, K> { self.primary.no_prefix_raw() } From 98d01706edb53c1678c02c3be2d7255eec833582 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 19:48:01 +0100 Subject: [PATCH 186/352] Fix: proper trait bounds for Bound2 --- packages/storage-plus/src/prefix.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 3adb20420..cf53e6fd8 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -10,7 +10,7 @@ use crate::de::KeyDeserialize; use crate::helpers::{namespaces_with_key, nested_namespaces_with_key}; use crate::int_key::CwIntKey; use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim}; -use crate::keys::{Bounder, Key}; +use crate::keys::Key; use crate::{Endian, Prefixer, PrimaryKey}; /// Bound is used to defines the two ends of a range, more explicit than Option @@ -51,7 +51,7 @@ pub enum Bound2<'a, K: PrimaryKey<'a>> { Exclusive((K, PhantomData<&'a bool>)), } -impl<'a, K: Bounder<'a>> Bound2<'a, K> { +impl<'a, K: PrimaryKey<'a>> Bound2<'a, K> { pub fn inclusive>(k: T) -> Self { Self::Inclusive((k.into(), PhantomData)) } @@ -240,7 +240,7 @@ where impl<'b, K, T, B> Prefix where - B: Bounder<'b>, + B: PrimaryKey<'b>, K: KeyDeserialize, T: Serialize + DeserializeOwned, { From 8596074d17e15403b5c975a00f217937cf1dc23a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 21:25:11 +0100 Subject: [PATCH 187/352] Rename Bound to RawBound --- contracts/cw1-subkeys/src/contract.rs | 6 +- contracts/cw1155-base/src/contract.rs | 8 +- contracts/cw20-base/src/enumerable.rs | 6 +- contracts/cw3-fixed-multisig/src/contract.rs | 10 +- contracts/cw3-flex-multisig/src/contract.rs | 8 +- contracts/cw4-group/src/contract.rs | 4 +- contracts/cw4-stake/src/contract.rs | 4 +- packages/storage-plus/src/indexed_map.rs | 36 ++++-- packages/storage-plus/src/indexed_snapshot.rs | 20 +-- packages/storage-plus/src/indexes/multi.rs | 18 +-- packages/storage-plus/src/indexes/unique.rs | 18 +-- packages/storage-plus/src/keys.rs | 82 ++++++------- packages/storage-plus/src/lib.rs | 2 +- packages/storage-plus/src/map.rs | 52 ++++---- packages/storage-plus/src/prefix.rs | 116 +++++++++--------- packages/storage-plus/src/snapshot/item.rs | 4 +- packages/storage-plus/src/snapshot/map.rs | 24 ++-- packages/storage-plus/src/snapshot/mod.rs | 6 +- packages/utils/src/pagination.rs | 6 +- 19 files changed, 220 insertions(+), 210 deletions(-) diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/contract.rs index 1d0f2bbb9..e6535ae2f 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs @@ -18,7 +18,7 @@ use cw1_whitelist::{ state::ADMIN_LIST, }; use cw2::{get_contract_version, set_contract_version}; -use cw_storage_plus::Bound; +use cw_storage_plus::RawBound; use cw_utils::Expiration; use semver::Version; @@ -407,7 +407,7 @@ pub fn query_all_allowances( ) -> StdResult { let limit = calc_limit(limit); // we use raw addresses here.... - let start = start_after.map(Bound::exclusive); + let start = start_after.map(RawBound::exclusive); let allowances = ALLOWANCES .range(deps.storage, start, None, Order::Ascending) @@ -437,7 +437,7 @@ pub fn query_all_permissions( limit: Option, ) -> StdResult { let limit = calc_limit(limit); - let start = start_after.map(Bound::exclusive); + let start = start_after.map(RawBound::exclusive); let permissions = PERMISSIONS .range(deps.storage, start, None, Order::Ascending) diff --git a/contracts/cw1155-base/src/contract.rs b/contracts/cw1155-base/src/contract.rs index 761b34094..4f254a144 100644 --- a/contracts/cw1155-base/src/contract.rs +++ b/contracts/cw1155-base/src/contract.rs @@ -3,7 +3,7 @@ use cosmwasm_std::{ to_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Order, Response, StdResult, SubMsg, Uint128, }; -use cw_storage_plus::Bound; +use cw_storage_plus::RawBound; use cw1155::{ ApproveAllEvent, ApprovedForAllResponse, BalanceResponse, BatchBalanceResponse, @@ -494,7 +494,7 @@ fn query_all_approvals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(|addr| Bound::exclusive(addr.as_ref())); + let start = start_after.map(|addr| RawBound::exclusive(addr.as_ref())); let operators = APPROVES .prefix(&owner) @@ -513,7 +513,7 @@ fn query_tokens( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); + let start = start_after.map(RawBound::exclusive); let tokens = BALANCES .prefix(&owner) @@ -529,7 +529,7 @@ fn query_all_tokens( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); + let start = start_after.map(RawBound::exclusive); let tokens = TOKENS .keys(deps.storage, start, None, Order::Ascending) .take(limit) diff --git a/contracts/cw20-base/src/enumerable.rs b/contracts/cw20-base/src/enumerable.rs index cb7dc74fc..2d165a1d5 100644 --- a/contracts/cw20-base/src/enumerable.rs +++ b/contracts/cw20-base/src/enumerable.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{Deps, Order, StdResult}; use cw20::{AllAccountsResponse, AllAllowancesResponse, AllowanceInfo}; use crate::state::{ALLOWANCES, BALANCES}; -use cw_storage_plus::Bound; +use cw_storage_plus::RawBound; // settings for pagination const MAX_LIMIT: u32 = 30; @@ -16,7 +16,7 @@ pub fn query_all_allowances( ) -> StdResult { let owner_addr = deps.api.addr_validate(&owner)?; let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); + let start = start_after.map(RawBound::exclusive); let allowances = ALLOWANCES .prefix(&owner_addr) @@ -39,7 +39,7 @@ pub fn query_all_accounts( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); + let start = start_after.map(RawBound::exclusive); let accounts = BALANCES .keys(deps.storage, start, None, Order::Ascending) diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 394e9bc69..284df3c93 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -12,7 +12,7 @@ use cw3::{ ProposalListResponse, ProposalResponse, Status, Vote, VoteInfo, VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, }; -use cw_storage_plus::Bound; +use cw_storage_plus::RawBound; use cw_utils::{Expiration, ThresholdResponse}; use crate::error::ContractError; @@ -287,7 +287,7 @@ fn list_proposals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive_int); + let start = start_after.map(RawBound::exclusive_int); let proposals = PROPOSALS .range(deps.storage, start, None, Order::Ascending) .take(limit) @@ -304,7 +304,7 @@ fn reverse_proposals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let end = start_before.map(Bound::exclusive_int); + let end = start_before.map(RawBound::exclusive_int); let props: StdResult> = PROPOSALS .range(deps.storage, None, end, Order::Descending) .take(limit) @@ -351,7 +351,7 @@ fn list_votes( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); + let start = start_after.map(RawBound::exclusive); let votes = BALLOTS .prefix(proposal_id) @@ -381,7 +381,7 @@ fn list_voters( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); + let start = start_after.map(RawBound::exclusive); let voters = VOTERS .range(deps.storage, start, None, Order::Ascending) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 929975136..50243ab59 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -14,7 +14,7 @@ use cw3::{ }; use cw3_fixed_multisig::state::{next_id, Ballot, Proposal, Votes, BALLOTS, PROPOSALS}; use cw4::{Cw4Contract, MemberChangedHookMsg, MemberDiff}; -use cw_storage_plus::Bound; +use cw_storage_plus::RawBound; use cw_utils::{maybe_addr, Expiration, ThresholdResponse}; use crate::error::ContractError; @@ -315,7 +315,7 @@ fn list_proposals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive_int); + let start = start_after.map(RawBound::exclusive_int); let proposals = PROPOSALS .range(deps.storage, start, None, Order::Ascending) .take(limit) @@ -332,7 +332,7 @@ fn reverse_proposals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let end = start_before.map(Bound::exclusive_int); + let end = start_before.map(RawBound::exclusive_int); let props: StdResult> = PROPOSALS .range(deps.storage, None, end, Order::Descending) .take(limit) @@ -380,7 +380,7 @@ fn list_votes( ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let addr = maybe_addr(deps.api, start_after)?; - let start = addr.map(|addr| Bound::exclusive(addr.as_ref())); + let start = addr.map(|addr| RawBound::exclusive(addr.as_ref())); let votes = BALLOTS .prefix(proposal_id) diff --git a/contracts/cw4-group/src/contract.rs b/contracts/cw4-group/src/contract.rs index cc3ec20c2..9a7a86cde 100644 --- a/contracts/cw4-group/src/contract.rs +++ b/contracts/cw4-group/src/contract.rs @@ -9,7 +9,7 @@ use cw4::{ Member, MemberChangedHookMsg, MemberDiff, MemberListResponse, MemberResponse, TotalWeightResponse, }; -use cw_storage_plus::Bound; +use cw_storage_plus::RawBound; use cw_utils::maybe_addr; use crate::error::ContractError; @@ -190,7 +190,7 @@ fn list_members( ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let addr = maybe_addr(deps.api, start_after)?; - let start = addr.map(|addr| Bound::exclusive(addr.to_string())); + let start = addr.map(|addr| RawBound::exclusive(addr.to_string())); let members = MEMBERS .range(deps.storage, start, None, Order::Ascending) diff --git a/contracts/cw4-stake/src/contract.rs b/contracts/cw4-stake/src/contract.rs index f57be9b9b..28b91ef1a 100644 --- a/contracts/cw4-stake/src/contract.rs +++ b/contracts/cw4-stake/src/contract.rs @@ -11,7 +11,7 @@ use cw4::{ Member, MemberChangedHookMsg, MemberDiff, MemberListResponse, MemberResponse, TotalWeightResponse, }; -use cw_storage_plus::Bound; +use cw_storage_plus::RawBound; use cw_utils::{maybe_addr, NativeBalance}; use crate::error::ContractError; @@ -339,7 +339,7 @@ fn list_members( ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let addr = maybe_addr(deps.api, start_after)?; - let start = addr.map(|addr| Bound::exclusive(addr.as_ref())); + let start = addr.map(|addr| RawBound::exclusive(addr.as_ref())); let members = MEMBERS .range(deps.storage, start, None, Order::Ascending) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index d9a7df53c..e2a6a685c 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -10,7 +10,7 @@ use crate::indexes::Index; use crate::iter_helpers::{deserialize_kv, deserialize_v}; use crate::keys::{Prefixer, PrimaryKey}; use crate::map::Map; -use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; +use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound, RawBound}; use crate::Path; pub trait IndexList { @@ -147,8 +147,8 @@ where pub fn range_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box>> + 'c> where @@ -160,8 +160,8 @@ where pub fn keys_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> { self.no_prefix_raw().keys_raw(store, min, max, order) @@ -247,8 +247,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -261,8 +261,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -469,7 +469,12 @@ mod test { let count = map .idx .name - .range_raw(&store, Some(Bound::inclusive(key)), None, Order::Ascending) + .range_raw( + &store, + Some(RawBound::inclusive(key)), + None, + Order::Ascending, + ) .count(); // gets from the first "Maria" until the end assert_eq!(4, count); @@ -484,7 +489,12 @@ mod test { let count = map .idx .name - .range_raw(&store, Some(Bound::exclusive(key)), None, Order::Ascending) + .range_raw( + &store, + Some(RawBound::exclusive(key)), + None, + Order::Ascending, + ) .count(); // gets from the 2nd "Maria" until the end assert_eq!(3, count); @@ -499,7 +509,7 @@ mod test { .age .range_raw( &store, - Some(Bound::inclusive(age_key)), + Some(RawBound::inclusive(age_key)), None, Order::Ascending, ) @@ -1009,7 +1019,7 @@ mod test { let all: StdResult> = map .range( &store, - Some(Bound::Inclusive(b"3".to_vec())), + Some(RawBound::Inclusive(b"3".to_vec())), None, Order::Ascending, ) diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index e5f45bfa2..492d71841 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -8,7 +8,7 @@ use serde::Serialize; use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::keys::{Prefixer, PrimaryKey}; -use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; +use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound, RawBound}; use crate::snapshot::{ChangeSet, SnapshotMap}; use crate::{IndexList, Map, Path, Strategy}; @@ -196,8 +196,8 @@ where pub fn range_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box>> + 'c> where @@ -209,8 +209,8 @@ where pub fn keys_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> { self.no_prefix_raw().keys_raw(store, min, max, order) @@ -267,8 +267,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -281,8 +281,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -1060,7 +1060,7 @@ mod test { let all: StdResult> = map .range( &store, - Some(Bound::Inclusive(b"3".to_vec())), + Some(RawBound::Inclusive(b"3".to_vec())), None, Order::Ascending, ) diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 91a4f29c7..d835e64f5 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -11,7 +11,7 @@ use crate::helpers::namespaces_with_key; use crate::iter_helpers::deserialize_kv; use crate::map::Map; use crate::prefix::{namespaced_prefix_range, PrefixBound}; -use crate::{Bound, Index, Prefix, Prefixer, PrimaryKey}; +use crate::{Index, Prefix, Prefixer, PrimaryKey, RawBound}; use std::marker::PhantomData; /// MultiIndex stores (namespace, index_name, idx_value, pk) -> b"pk_len". @@ -198,8 +198,8 @@ where pub fn range_raw<'c>( &'c self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: Order, ) -> Box>> + 'c> where @@ -211,8 +211,8 @@ where pub fn keys_raw<'c>( &'c self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: Order, ) -> Box> + 'c> { self.no_prefix_raw().keys_raw(store, min, max, order) @@ -304,8 +304,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -318,8 +318,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index 6f729db10..6964a09a1 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -12,7 +12,7 @@ use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::map::Map; use crate::prefix::{namespaced_prefix_range, PrefixBound}; -use crate::{Bound, Index, Prefix, Prefixer, PrimaryKey}; +use crate::{Index, Prefix, Prefixer, PrimaryKey, RawBound}; /// UniqueRef stores Binary(Vec[u8]) representation of private key and index value #[derive(Deserialize, Serialize)] @@ -143,8 +143,8 @@ where pub fn range_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: Order, ) -> Box>> + 'c> where @@ -156,8 +156,8 @@ where pub fn keys_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: Order, ) -> Box> + 'c> { self.no_prefix_raw().keys_raw(store, min, max, order) @@ -199,8 +199,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -213,8 +213,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index e10e1b02a..b0285194a 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -3,7 +3,7 @@ use cosmwasm_std::Addr; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; use crate::int_key::CwIntKey; -use crate::prefix::Bound2; +use crate::prefix::Bound; #[derive(Debug)] pub enum Key<'a> { @@ -302,25 +302,25 @@ macro_rules! integer_prefix { integer_prefix!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64); pub trait Bounder<'a>: PrimaryKey<'a> + Sized { - fn inclusive_bound(self) -> Option>; - fn exclusive_bound(self) -> Option>; + fn inclusive_bound(self) -> Option>; + fn exclusive_bound(self) -> Option>; } impl<'a> Bounder<'a> for () { - fn inclusive_bound(self) -> Option> { + fn inclusive_bound(self) -> Option> { None } - fn exclusive_bound(self) -> Option> { + fn exclusive_bound(self) -> Option> { None } } impl<'a> Bounder<'a> for &'a [u8] { - fn inclusive_bound(self) -> Option> { - Some(Bound2::inclusive(self)) + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) } - fn exclusive_bound(self) -> Option> { - Some(Bound2::exclusive(self)) + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) } } @@ -330,11 +330,11 @@ impl< U: PrimaryKey<'a> + KeyDeserialize + Clone, > Bounder<'a> for (T, U) { - fn inclusive_bound(self) -> Option> { - Some(Bound2::inclusive(self)) + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) } - fn exclusive_bound(self) -> Option> { - Some(Bound2::exclusive(self)) + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) } } @@ -345,67 +345,67 @@ impl< V: PrimaryKey<'a> + KeyDeserialize + Clone, > Bounder<'a> for (T, U, V) { - fn inclusive_bound(self) -> Option> { - Some(Bound2::inclusive(self)) + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) } - fn exclusive_bound(self) -> Option> { - Some(Bound2::exclusive(self)) + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) } } impl<'a> Bounder<'a> for &'a str { - fn inclusive_bound(self) -> Option> { - Some(Bound2::inclusive(self)) + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) } - fn exclusive_bound(self) -> Option> { - Some(Bound2::exclusive(self)) + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) } } impl<'a> Bounder<'a> for String { - fn inclusive_bound(self) -> Option> { - Some(Bound2::inclusive(self)) + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) } - fn exclusive_bound(self) -> Option> { - Some(Bound2::exclusive(self)) + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) } } impl<'a> Bounder<'a> for Vec { - fn inclusive_bound(self) -> Option> { - Some(Bound2::inclusive(self)) + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) } - fn exclusive_bound(self) -> Option> { - Some(Bound2::exclusive(self)) + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) } } impl<'a> Bounder<'a> for &'a Addr { - fn inclusive_bound(self) -> Option> { - Some(Bound2::inclusive(self)) + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) } - fn exclusive_bound(self) -> Option> { - Some(Bound2::exclusive(self)) + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) } } impl<'a> Bounder<'a> for Addr { - fn inclusive_bound(self) -> Option> { - Some(Bound2::inclusive(self)) + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) } - fn exclusive_bound(self) -> Option> { - Some(Bound2::exclusive(self)) + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) } } macro_rules! integer_bound { (for $($t:ty),+) => { $(impl<'a> Bounder<'a> for $t { - fn inclusive_bound(self) -> Option> { - Some(Bound2::inclusive(self)) + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) } - fn exclusive_bound(self) -> Option> { - Some(Bound2::exclusive(self)) + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) } })* } diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index ff8e508b9..35200acff 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -33,6 +33,6 @@ pub use keys_old::IntKeyOld; pub use map::Map; pub use path::Path; #[cfg(feature = "iterator")] -pub use prefix::{range_with_prefix, Bound, Prefix, PrefixBound}; +pub use prefix::{range_with_prefix, Prefix, PrefixBound, RawBound}; #[cfg(feature = "iterator")] pub use snapshot::{SnapshotItem, SnapshotMap, Strategy}; diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 50be17dab..67379d893 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -11,9 +11,9 @@ use crate::iter_helpers::{deserialize_kv, deserialize_v}; use crate::keys::Prefixer; use crate::keys::{Bounder, Key, PrimaryKey}; use crate::path::Path; -use crate::prefix::Bound2; +use crate::prefix::Bound; #[cfg(feature = "iterator")] -use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; +use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound, RawBound}; use cosmwasm_std::{from_slice, Addr, QuerierWrapper, StdError, StdResult, Storage}; #[derive(Debug, Clone)] @@ -158,8 +158,8 @@ where pub fn range_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box>> + 'c> where @@ -171,8 +171,8 @@ where pub fn keys_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -215,8 +215,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -229,8 +229,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -254,8 +254,8 @@ where pub fn range2_raw<'c>( &self, store: &'c dyn Storage, - min: Option>, - max: Option>, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box>> + 'c> where @@ -267,8 +267,8 @@ where pub fn range2<'c>( &self, store: &'c dyn Storage, - min: Option>, - max: Option>, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -471,7 +471,7 @@ mod test { let all: StdResult> = PEOPLE .range_raw( &store, - Some(Bound::Inclusive(b"j".to_vec())), + Some(RawBound::Inclusive(b"j".to_vec())), None, Order::Ascending, ) @@ -487,7 +487,7 @@ mod test { let all: StdResult> = PEOPLE .range_raw( &store, - Some(Bound::Inclusive(b"jo".to_vec())), + Some(RawBound::Inclusive(b"jo".to_vec())), None, Order::Ascending, ) @@ -531,7 +531,7 @@ mod test { let all: StdResult> = PEOPLE .range( &store, - Some(Bound::Inclusive(b"j".to_vec())), + Some(RawBound::Inclusive(b"j".to_vec())), None, Order::Ascending, ) @@ -547,7 +547,7 @@ mod test { let all: StdResult> = PEOPLE .range( &store, - Some(Bound::Inclusive(b"jo".to_vec())), + Some(RawBound::Inclusive(b"jo".to_vec())), None, Order::Ascending, ) @@ -646,7 +646,7 @@ mod test { let all: StdResult> = PEOPLE_ID .range( &store, - Some(Bound::inclusive_int(56u32)), + Some(RawBound::inclusive_int(56u32)), None, Order::Ascending, ) @@ -659,7 +659,7 @@ mod test { let all: StdResult> = PEOPLE_ID .range( &store, - Some(Bound::inclusive_int(57u32)), + Some(RawBound::inclusive_int(57u32)), None, Order::Ascending, ) @@ -751,7 +751,7 @@ mod test { let all: StdResult> = SIGNED_ID .range( &store, - Some(Bound::inclusive_int(-56i32)), + Some(RawBound::inclusive_int(-56i32)), None, Order::Ascending, ) @@ -764,8 +764,8 @@ mod test { let all: StdResult> = SIGNED_ID .range( &store, - Some(Bound::inclusive_int(-55i32)), - Some(Bound::inclusive_int(50i32)), + Some(RawBound::inclusive_int(-55i32)), + Some(RawBound::inclusive_int(50i32)), Order::Descending, ) .collect(); @@ -1459,7 +1459,7 @@ mod test { let all: StdResult> = PEOPLE .range_raw( &store, - Some(Bound::Exclusive(b"jim".to_vec())), + Some(RawBound::Exclusive(b"jim".to_vec())), None, Order::Ascending, ) @@ -1486,8 +1486,8 @@ mod test { .prefix(b"owner") .range_raw( &store, - Some(Bound::Exclusive(b"spender1".to_vec())), - Some(Bound::Inclusive(b"spender2".to_vec())), + Some(RawBound::Exclusive(b"spender1".to_vec())), + Some(RawBound::Inclusive(b"spender2".to_vec())), Order::Descending, ) .collect(); diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index cf53e6fd8..d5c1c2b59 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -18,40 +18,40 @@ use crate::{Endian, Prefixer, PrimaryKey}; /// Include means we use the given bytes as a limit and *include* anything at that exact key /// Exclude means we use the given bytes as a limit and *exclude* anything at that exact key #[derive(Clone, Debug)] -pub enum Bound { +pub enum RawBound { Inclusive(Vec), Exclusive(Vec), } -impl Bound { +impl RawBound { /// Turns optional binary, like Option into an inclusive bound pub fn inclusive>>(limit: T) -> Self { - Bound::Inclusive(limit.into()) + RawBound::Inclusive(limit.into()) } /// Turns optional binary, like Option into an exclusive bound pub fn exclusive>>(limit: T) -> Self { - Bound::Exclusive(limit.into()) + RawBound::Exclusive(limit.into()) } /// Turns an int, like Option into an inclusive bound pub fn inclusive_int(limit: T) -> Self { - Bound::Inclusive(limit.to_cw_bytes().into()) + RawBound::Inclusive(limit.to_cw_bytes().into()) } /// Turns an int, like Option into an exclusive bound pub fn exclusive_int(limit: T) -> Self { - Bound::Exclusive(limit.to_cw_bytes().into()) + RawBound::Exclusive(limit.to_cw_bytes().into()) } } #[derive(Clone, Debug)] -pub enum Bound2<'a, K: PrimaryKey<'a>> { +pub enum Bound<'a, K: PrimaryKey<'a>> { Inclusive((K, PhantomData<&'a bool>)), Exclusive((K, PhantomData<&'a bool>)), } -impl<'a, K: PrimaryKey<'a>> Bound2<'a, K> { +impl<'a, K: PrimaryKey<'a>> Bound<'a, K> { pub fn inclusive>(k: T) -> Self { Self::Inclusive((k.into(), PhantomData)) } @@ -60,10 +60,10 @@ impl<'a, K: PrimaryKey<'a>> Bound2<'a, K> { Self::Exclusive((k.into(), PhantomData)) } - pub fn to_bound(&self) -> Bound { + pub fn to_raw_bound(&self) -> RawBound { match self { - Bound2::Exclusive((k, _)) => Bound::Exclusive(k.joined_key()), - Bound2::Inclusive((k, _)) => Bound::Inclusive(k.joined_key()), + Bound::Exclusive((k, _)) => RawBound::Exclusive(k.joined_key()), + Bound::Inclusive((k, _)) => RawBound::Inclusive(k.joined_key()), } } } @@ -83,10 +83,10 @@ impl<'a, K: Prefixer<'a>> PrefixBound<'a, K> { Self::Exclusive((k.into(), PhantomData)) } - pub fn to_bound(&self) -> Bound { + pub fn to_raw_bound(&self) -> RawBound { match self { - PrefixBound::Exclusive((k, _)) => Bound::Exclusive(k.joined_prefix()), - PrefixBound::Inclusive((k, _)) => Bound::Inclusive(k.joined_prefix()), + PrefixBound::Exclusive((k, _)) => RawBound::Exclusive(k.joined_prefix()), + PrefixBound::Inclusive((k, _)) => RawBound::Inclusive(k.joined_prefix()), } } } @@ -174,8 +174,8 @@ where pub fn range_raw<'a>( &self, store: &'a dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: Order, ) -> Box>> + 'a> where @@ -191,8 +191,8 @@ where pub fn keys_raw<'a>( &self, store: &'a dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: Order, ) -> Box> + 'a> { let mapped = @@ -203,8 +203,8 @@ where pub fn range<'a>( &self, store: &'a dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: Order, ) -> Box> + 'a> where @@ -221,8 +221,8 @@ where pub fn keys<'a>( &self, store: &'a dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: Order, ) -> Box> + 'a> where @@ -247,8 +247,8 @@ where pub fn range2_raw<'a>( &self, store: &'a dyn Storage, - min: Option>, - max: Option>, + min: Option>, + max: Option>, order: Order, ) -> Box>> + 'a> where @@ -259,8 +259,8 @@ where let mapped = range_with_prefix( store, &self.storage_prefix, - min.map(|b| b.to_bound()), - max.map(|b| b.to_bound()), + min.map(|b| b.to_raw_bound()), + max.map(|b| b.to_raw_bound()), order, ) .map(move |kv| (de_fn)(store, &pk_name, kv)); @@ -270,8 +270,8 @@ where pub fn range2<'a>( &self, store: &'a dyn Storage, - min: Option>, - max: Option>, + min: Option>, + max: Option>, order: Order, ) -> Box> + 'a> where @@ -283,8 +283,8 @@ where let mapped = range_with_prefix( store, &self.storage_prefix, - min.map(|b| b.to_bound()), - max.map(|b| b.to_bound()), + min.map(|b| b.to_raw_bound()), + max.map(|b| b.to_raw_bound()), order, ) .map(move |kv| (de_fn)(store, &pk_name, kv)); @@ -295,8 +295,8 @@ where pub fn range_with_prefix<'a>( storage: &'a dyn Storage, namespace: &[u8], - start: Option, - end: Option, + start: Option, + end: Option, order: Order, ) -> Box + 'a> { let start = calc_start_bound(namespace, start); @@ -311,21 +311,21 @@ pub fn range_with_prefix<'a>( Box::new(mapped) } -fn calc_start_bound(namespace: &[u8], bound: Option) -> Vec { +fn calc_start_bound(namespace: &[u8], bound: Option) -> Vec { match bound { None => namespace.to_vec(), // this is the natural limits of the underlying Storage - Some(Bound::Inclusive(limit)) => concat(namespace, &limit), - Some(Bound::Exclusive(limit)) => concat(namespace, &extend_one_byte(&limit)), + Some(RawBound::Inclusive(limit)) => concat(namespace, &limit), + Some(RawBound::Exclusive(limit)) => concat(namespace, &extend_one_byte(&limit)), } } -fn calc_end_bound(namespace: &[u8], bound: Option) -> Vec { +fn calc_end_bound(namespace: &[u8], bound: Option) -> Vec { match bound { None => increment_last_byte(namespace), // this is the natural limits of the underlying Storage - Some(Bound::Exclusive(limit)) => concat(namespace, &limit), - Some(Bound::Inclusive(limit)) => concat(namespace, &extend_one_byte(&limit)), + Some(RawBound::Exclusive(limit)) => concat(namespace, &limit), + Some(RawBound::Inclusive(limit)) => concat(namespace, &extend_one_byte(&limit)), } } @@ -352,11 +352,11 @@ fn calc_prefix_start_bound<'a, K: Prefixer<'a>>( namespace: &[u8], bound: Option>, ) -> Vec { - match bound.map(|b| b.to_bound()) { + match bound.map(|b| b.to_raw_bound()) { None => namespace.to_vec(), // this is the natural limits of the underlying Storage - Some(Bound::Inclusive(limit)) => concat(namespace, &limit), - Some(Bound::Exclusive(limit)) => concat(namespace, &increment_last_byte(&limit)), + Some(RawBound::Inclusive(limit)) => concat(namespace, &limit), + Some(RawBound::Exclusive(limit)) => concat(namespace, &increment_last_byte(&limit)), } } @@ -364,11 +364,11 @@ fn calc_prefix_end_bound<'a, K: Prefixer<'a>>( namespace: &[u8], bound: Option>, ) -> Vec { - match bound.map(|b| b.to_bound()) { + match bound.map(|b| b.to_raw_bound()) { None => increment_last_byte(namespace), // this is the natural limits of the underlying Storage - Some(Bound::Exclusive(limit)) => concat(namespace, &limit), - Some(Bound::Inclusive(limit)) => concat(namespace, &increment_last_byte(&limit)), + Some(RawBound::Exclusive(limit)) => concat(namespace, &limit), + Some(RawBound::Inclusive(limit)) => concat(namespace, &increment_last_byte(&limit)), } } @@ -441,7 +441,7 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(Bound::Inclusive(b"ra".to_vec())), + Some(RawBound::Inclusive(b"ra".to_vec())), None, Order::Ascending, ) @@ -451,7 +451,7 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(Bound::Exclusive(b"ra".to_vec())), + Some(RawBound::Exclusive(b"ra".to_vec())), None, Order::Ascending, ) @@ -461,7 +461,7 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(Bound::Exclusive(b"r".to_vec())), + Some(RawBound::Exclusive(b"r".to_vec())), None, Order::Ascending, ) @@ -473,7 +473,7 @@ mod test { .range_raw( &store, None, - Some(Bound::Inclusive(b"ra".to_vec())), + Some(RawBound::Inclusive(b"ra".to_vec())), Order::Descending, ) .collect(); @@ -483,7 +483,7 @@ mod test { .range_raw( &store, None, - Some(Bound::Exclusive(b"ra".to_vec())), + Some(RawBound::Exclusive(b"ra".to_vec())), Order::Descending, ) .collect(); @@ -493,7 +493,7 @@ mod test { .range_raw( &store, None, - Some(Bound::Exclusive(b"rb".to_vec())), + Some(RawBound::Exclusive(b"rb".to_vec())), Order::Descending, ) .collect(); @@ -503,8 +503,8 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(Bound::Inclusive(b"ra".to_vec())), - Some(Bound::Exclusive(b"zi".to_vec())), + Some(RawBound::Inclusive(b"ra".to_vec())), + Some(RawBound::Exclusive(b"zi".to_vec())), Order::Ascending, ) .collect(); @@ -513,8 +513,8 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(Bound::Inclusive(b"ra".to_vec())), - Some(Bound::Exclusive(b"zi".to_vec())), + Some(RawBound::Inclusive(b"ra".to_vec())), + Some(RawBound::Exclusive(b"zi".to_vec())), Order::Descending, ) .collect(); @@ -523,8 +523,8 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(Bound::Inclusive(b"ra".to_vec())), - Some(Bound::Inclusive(b"zi".to_vec())), + Some(RawBound::Inclusive(b"ra".to_vec())), + Some(RawBound::Inclusive(b"zi".to_vec())), Order::Descending, ) .collect(); @@ -533,8 +533,8 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(Bound::Exclusive(b"ra".to_vec())), - Some(Bound::Exclusive(b"zi".to_vec())), + Some(RawBound::Exclusive(b"ra".to_vec())), + Some(RawBound::Exclusive(b"zi".to_vec())), Order::Ascending, ) .collect(); diff --git a/packages/storage-plus/src/snapshot/item.rs b/packages/storage-plus/src/snapshot/item.rs index 3cf9bfa0a..1fe58c332 100644 --- a/packages/storage-plus/src/snapshot/item.rs +++ b/packages/storage-plus/src/snapshot/item.rs @@ -283,7 +283,7 @@ mod tests { #[test] #[cfg(feature = "iterator")] fn changelog_range_works() { - use crate::Bound; + use crate::RawBound; use cosmwasm_std::Order; let mut store = MockStorage::new(); @@ -318,7 +318,7 @@ mod tests { .changelog() .range( &store, - Some(Bound::exclusive_int(3u64)), + Some(RawBound::exclusive_int(3u64)), None, Order::Ascending, ) diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index 6536099f6..d52713fa5 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -10,7 +10,7 @@ use crate::map::Map; use crate::path::Path; use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound}; use crate::snapshot::{ChangeSet, Snapshot}; -use crate::{Bound, Prefixer, Strategy}; +use crate::{Prefixer, RawBound, Strategy}; /// Map that maintains a snapshots of one or more checkpoints. /// We can query historical data as well as current state. @@ -171,8 +171,8 @@ where pub fn range_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box>> + 'c> where @@ -184,8 +184,8 @@ where pub fn keys_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -228,8 +228,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -242,8 +242,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option, + max: Option, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -516,7 +516,7 @@ mod tests { .prefix("A") .range( &store, - Some(Bound::inclusive_int(3u64)), + Some(RawBound::inclusive_int(3u64)), None, Order::Ascending, ) @@ -544,7 +544,7 @@ mod tests { let all: StdResult> = EVERY .range( &store, - Some(Bound::Inclusive(b"C".to_vec())), + Some(RawBound::Inclusive(b"C".to_vec())), None, Order::Ascending, ) @@ -557,7 +557,7 @@ mod tests { let all: StdResult> = EVERY .range( &store, - Some(Bound::Inclusive(b"D".to_vec())), + Some(RawBound::Inclusive(b"D".to_vec())), None, Order::Ascending, ) diff --git a/packages/storage-plus/src/snapshot/mod.rs b/packages/storage-plus/src/snapshot/mod.rs index 889f1fad6..9caf904d3 100644 --- a/packages/storage-plus/src/snapshot/mod.rs +++ b/packages/storage-plus/src/snapshot/mod.rs @@ -6,7 +6,7 @@ pub use item::SnapshotItem; pub use map::SnapshotMap; use crate::de::KeyDeserialize; -use crate::{Bound, Map, Prefixer, PrimaryKey}; +use crate::{Map, Prefixer, PrimaryKey, RawBound}; use cosmwasm_std::{Order, StdError, StdResult, Storage}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; @@ -84,7 +84,7 @@ where .transpose()?; if let Some((height, _)) = checkpoint { // any changelog for the given key since then? - let start = Bound::inclusive(height); + let start = RawBound::inclusive(height); let first = self .changelog .prefix(k.clone()) @@ -143,7 +143,7 @@ where // this will look for the first snapshot of height >= given height // If None, there is no snapshot since that time. - let start = Bound::inclusive_int(height); + let start = RawBound::inclusive_int(height); let first = self .changelog .prefix(key) diff --git a/packages/utils/src/pagination.rs b/packages/utils/src/pagination.rs index 7af917acd..ba6e825a1 100644 --- a/packages/utils/src/pagination.rs +++ b/packages/utils/src/pagination.rs @@ -37,7 +37,7 @@ pub fn calc_range_start_string(start_after: Option) -> Option> { mod test { use super::*; use cosmwasm_std::{testing::mock_dependencies, Order}; - use cw_storage_plus::{Bound, Map}; + use cw_storage_plus::{RawBound, Map}; pub const HOLDERS: Map<&Addr, usize> = Map::new("some_data"); const LIMIT: usize = 30; @@ -64,7 +64,7 @@ mod test { Some(addr_from_i(j * LIMIT - 1)) }; - let start = calc_range_start(start_after).map(Bound::exclusive); + let start = calc_range_start(start_after).map(RawBound::exclusive); let holders = HOLDERS .keys(&deps.storage, start, None, Order::Ascending) @@ -93,7 +93,7 @@ mod test { for j in 0..4 { let end_before = Some(addr_from_i(total_elements_count - j * LIMIT)); - let end = calc_range_end(end_before).map(Bound::exclusive); + let end = calc_range_end(end_before).map(RawBound::exclusive); let holders = HOLDERS .keys(&deps.storage, None, end, Order::Descending) From bafe270f9e4b5d0cd7e0dbd899e229419a40d7dd Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 8 Jan 2022 21:28:52 +0100 Subject: [PATCH 188/352] Adjust doc comments --- packages/storage-plus/src/prefix.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index d5c1c2b59..9a40fd402 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -13,10 +13,11 @@ use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim}; use crate::keys::Key; use crate::{Endian, Prefixer, PrimaryKey}; -/// Bound is used to defines the two ends of a range, more explicit than Option -/// None means that we don't limit that side of the range at all. -/// Include means we use the given bytes as a limit and *include* anything at that exact key -/// Exclude means we use the given bytes as a limit and *exclude* anything at that exact key +/// `RawBound` is used to define the two ends of a range, more explicit than `Option`. +/// `None` means that we don't limit that side of the range at all. +/// `Inclusive` means we use the given bytes as a limit and *include* anything at that exact key. +/// `Exclusive` means we use the given bytes as a limit and *exclude* anything at that exact key. +/// See `Bound` for a type safe way to build these bounds. #[derive(Clone, Debug)] pub enum RawBound { Inclusive(Vec), @@ -45,6 +46,10 @@ impl RawBound { } } +/// `Bound` is used to define the two ends of a range. +/// `None` means that we don't limit that side of the range at all. +/// `Inclusive` means we use the given value as a limit and *include* anything at that exact key. +/// `Exclusive` means we use the given value as a limit and *exclude* anything at that exact key. #[derive(Clone, Debug)] pub enum Bound<'a, K: PrimaryKey<'a>> { Inclusive((K, PhantomData<&'a bool>)), From 7a44f45e3959cb0255c03ff46eceefc17077889b Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 9 Jan 2022 09:36:33 +0100 Subject: [PATCH 189/352] Replace RawBound by Bound --- packages/storage-plus/src/indexed_map.rs | 70 +++++----- packages/storage-plus/src/indexed_snapshot.rs | 22 +-- packages/storage-plus/src/indexes/multi.rs | 24 ++-- packages/storage-plus/src/indexes/unique.rs | 28 ++-- packages/storage-plus/src/map.rs | 125 +++++++----------- packages/storage-plus/src/prefix.rs | 89 +++++-------- packages/storage-plus/src/snapshot/map.rs | 26 ++-- packages/storage-plus/src/snapshot/mod.rs | 9 +- 8 files changed, 165 insertions(+), 228 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index e2a6a685c..2057329dc 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -10,7 +10,7 @@ use crate::indexes::Index; use crate::iter_helpers::{deserialize_kv, deserialize_v}; use crate::keys::{Prefixer, PrimaryKey}; use crate::map::Map; -use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound, RawBound}; +use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; use crate::Path; pub trait IndexList { @@ -130,44 +130,11 @@ where } // use no_prefix to scan -> range - fn no_prefix_raw(&self) -> Prefix, T> { + fn no_prefix_raw(&self) -> Prefix, T, K> { Prefix::new(self.pk_namespace, &[]) } } -// short-cut for simple keys, rather than .prefix(()).range_raw(...) -impl<'a, K, T, I> IndexedMap<'a, K, T, I> -where - K: PrimaryKey<'a>, - T: Serialize + DeserializeOwned + Clone, - I: IndexList, -{ - // I would prefer not to copy code from Prefix, but no other way - // with lifetimes (create Prefix inside function and return ref = no no) - pub fn range_raw<'c>( - &self, - store: &'c dyn Storage, - min: Option, - max: Option, - order: cosmwasm_std::Order, - ) -> Box>> + 'c> - where - T: 'c, - { - self.no_prefix_raw().range_raw(store, min, max, order) - } - - pub fn keys_raw<'c>( - &self, - store: &'c dyn Storage, - min: Option, - max: Option, - order: cosmwasm_std::Order, - ) -> Box> + 'c> { - self.no_prefix_raw().keys_raw(store, min, max, order) - } -} - #[cfg(feature = "iterator")] impl<'a, K, T, I> IndexedMap<'a, K, T, I> where @@ -244,11 +211,34 @@ where Box::new(mapped) } + pub fn range_raw<'c>( + &self, + store: &'c dyn Storage, + min: Option>, + max: Option>, + order: cosmwasm_std::Order, + ) -> Box>> + 'c> + where + T: 'c, + { + self.no_prefix_raw().range_raw(store, min, max, order) + } + + pub fn keys_raw<'c>( + &self, + store: &'c dyn Storage, + min: Option>, + max: Option>, + order: cosmwasm_std::Order, + ) -> Box> + 'c> { + self.no_prefix_raw().keys_raw(store, min, max, order) + } + pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -261,8 +251,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -272,7 +262,7 @@ where self.no_prefix().keys(store, min, max, order) } - fn no_prefix(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::new(self.pk_namespace, &[]) } } diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 492d71841..ea305f5d9 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -8,7 +8,7 @@ use serde::Serialize; use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::keys::{Prefixer, PrimaryKey}; -use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound, RawBound}; +use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; use crate::snapshot::{ChangeSet, SnapshotMap}; use crate::{IndexList, Map, Path, Strategy}; @@ -179,7 +179,7 @@ where } // use no_prefix to scan -> range - pub fn no_prefix_raw(&self) -> Prefix, T> { + pub fn no_prefix_raw(&self) -> Prefix, T, K> { Prefix::new(self.pk_namespace, &[]) } } @@ -196,8 +196,8 @@ where pub fn range_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box>> + 'c> where @@ -209,8 +209,8 @@ where pub fn keys_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> { self.no_prefix_raw().keys_raw(store, min, max, order) @@ -267,8 +267,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -281,8 +281,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -292,7 +292,7 @@ where self.no_prefix().keys(store, min, max, order) } - fn no_prefix(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::new(self.pk_namespace, &[]) } } diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index d835e64f5..3ea4c6bbb 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -10,8 +10,8 @@ use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; use crate::iter_helpers::deserialize_kv; use crate::map::Map; -use crate::prefix::{namespaced_prefix_range, PrefixBound}; -use crate::{Index, Prefix, Prefixer, PrimaryKey, RawBound}; +use crate::prefix::{namespaced_prefix_range, Bound, PrefixBound}; +use crate::{Index, Prefix, Prefixer, PrimaryKey}; use std::marker::PhantomData; /// MultiIndex stores (namespace, index_name, idx_value, pk) -> b"pk_len". @@ -143,7 +143,7 @@ where T: Serialize + DeserializeOwned + Clone, IK: PrimaryKey<'a> + Prefixer<'a>, { - fn no_prefix_raw(&self) -> Prefix, T> { + fn no_prefix_raw(&self) -> Prefix, T, IK> { Prefix::with_deserialization_functions( self.idx_namespace, &[], @@ -198,8 +198,8 @@ where pub fn range_raw<'c>( &'c self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: Order, ) -> Box>> + 'c> where @@ -211,8 +211,8 @@ where pub fn keys_raw<'c>( &'c self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: Order, ) -> Box> + 'c> { self.no_prefix_raw().keys_raw(store, min, max, order) @@ -304,8 +304,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -318,8 +318,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -329,7 +329,7 @@ where self.no_prefix().keys(store, min, max, order) } - fn no_prefix(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &[], diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index 6964a09a1..9200ce552 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -11,8 +11,8 @@ use cosmwasm_std::{from_slice, Binary, Order, Record, StdError, StdResult, Stora use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::map::Map; -use crate::prefix::{namespaced_prefix_range, PrefixBound}; -use crate::{Index, Prefix, Prefixer, PrimaryKey, RawBound}; +use crate::prefix::{namespaced_prefix_range, Bound, PrefixBound}; +use crate::{Index, Prefix, Prefixer, PrimaryKey}; /// UniqueRef stores Binary(Vec[u8]) representation of private key and index value #[derive(Deserialize, Serialize)] @@ -112,7 +112,7 @@ where k.joined_key() } - fn no_prefix_raw(&self) -> Prefix, T> { + fn no_prefix_raw(&self) -> Prefix, T, IK> { Prefix::with_deserialization_functions( self.idx_namespace, &[], @@ -143,8 +143,8 @@ where pub fn range_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: Order, ) -> Box>> + 'c> where @@ -156,8 +156,8 @@ where pub fn keys_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: Order, ) -> Box> + 'c> { self.no_prefix_raw().keys_raw(store, min, max, order) @@ -199,8 +199,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -213,8 +213,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -224,7 +224,7 @@ where self.no_prefix().keys(store, min, max, order) } - pub fn prefix(&self, p: IK::Prefix) -> Prefix { + pub fn prefix(&self, p: IK::Prefix) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), @@ -234,7 +234,7 @@ where ) } - pub fn sub_prefix(&self, p: IK::SubPrefix) -> Prefix { + pub fn sub_prefix(&self, p: IK::SubPrefix) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), @@ -244,7 +244,7 @@ where ) } - fn no_prefix(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &[], diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 67379d893..6e83fabaa 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -13,7 +13,7 @@ use crate::keys::{Bounder, Key, PrimaryKey}; use crate::path::Path; use crate::prefix::Bound; #[cfg(feature = "iterator")] -use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound, RawBound}; +use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound}; use cosmwasm_std::{from_slice, Addr, QuerierWrapper, StdError, StdResult, Storage}; #[derive(Debug, Clone)] @@ -154,32 +154,6 @@ where namespaced_prefix_range(store, self.namespace, min, max, order).map(deserialize_v); Box::new(mapped) } - - pub fn range_raw<'c>( - &self, - store: &'c dyn Storage, - min: Option, - max: Option, - order: cosmwasm_std::Order, - ) -> Box>> + 'c> - where - T: 'c, - { - self.no_prefix_raw().range_raw(store, min, max, order) - } - - pub fn keys_raw<'c>( - &self, - store: &'c dyn Storage, - min: Option, - max: Option, - order: cosmwasm_std::Order, - ) -> Box> + 'c> - where - T: 'c, - { - self.no_prefix_raw().keys_raw(store, min, max, order) - } } #[cfg(feature = "iterator")] @@ -212,70 +186,69 @@ where Box::new(mapped) } - pub fn range<'c>( + fn no_prefix(&self) -> Prefix { + Prefix::new(self.namespace, &[]) + } +} + +#[cfg(feature = "iterator")] +impl<'a, K, T> Map<'a, K, T> +where + T: Serialize + DeserializeOwned, + K: PrimaryKey<'a> + KeyDeserialize + Bounder<'a>, +{ + pub fn range_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, - ) -> Box> + 'c> + ) -> Box>> + 'c> where T: 'c, - K::Output: 'static, { - self.no_prefix().range(store, min, max, order) + self.no_prefix_raw().range_raw(store, min, max, order) } - pub fn keys<'c>( + pub fn keys_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, - ) -> Box> + 'c> + ) -> Box> + 'c> where T: 'c, - K::Output: 'static, { - self.no_prefix().keys(store, min, max, order) - } - - fn no_prefix(&self) -> Prefix { - Prefix::new(self.namespace, &[]) + self.no_prefix_raw().keys_raw(store, min, max, order) } -} -#[cfg(feature = "iterator")] -impl<'a, K, T> Map<'a, K, T> -where - T: Serialize + DeserializeOwned, - K: PrimaryKey<'a> + KeyDeserialize + Bounder<'a>, -{ - pub fn range2_raw<'c>( + pub fn range<'c>( &self, store: &'c dyn Storage, min: Option>, max: Option>, order: cosmwasm_std::Order, - ) -> Box>> + 'c> + ) -> Box> + 'c> where T: 'c, + K::Output: 'static, { - self.no_prefix_raw().range2_raw(store, min, max, order) + self.no_prefix().range(store, min, max, order) } - pub fn range2<'c>( + pub fn keys<'c>( &self, store: &'c dyn Storage, min: Option>, max: Option>, order: cosmwasm_std::Order, - ) -> Box> + 'c> + ) -> Box> + 'c> where T: 'c, K::Output: 'static, { - self.no_prefix().range2(store, min, max, order) + self.no_prefix().keys(store, min, max, order) } } @@ -582,9 +555,7 @@ mod test { PEOPLE.save(&mut store, b"ada", &data3).unwrap(); // let's try to iterate! - let all: StdResult> = PEOPLE - .range2(&store, None, None, Order::Ascending) - .collect(); + let all: StdResult> = PEOPLE.range(&store, None, None, Order::Ascending).collect(); let all = all.unwrap(); assert_eq!(3, all.len()); assert_eq!( @@ -598,7 +569,7 @@ mod test { // let's try to iterate over a range let all: StdResult> = PEOPLE - .range2(&store, b"j".inclusive_bound(), None, Order::Ascending) + .range(&store, b"j".inclusive_bound(), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -609,7 +580,7 @@ mod test { // let's try to iterate over a more restrictive range let all: StdResult> = PEOPLE - .range2(&store, b"jo".inclusive_bound(), None, Order::Ascending) + .range(&store, b"jo".inclusive_bound(), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(1, all.len()); @@ -688,7 +659,7 @@ mod test { // let's try to iterate! let all: StdResult> = PEOPLE_ID - .range2(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -696,7 +667,7 @@ mod test { // let's try to iterate over a range let all: StdResult> = PEOPLE_ID - .range2(&store, 56u32.inclusive_bound(), None, Order::Ascending) + .range(&store, 56u32.inclusive_bound(), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -704,7 +675,7 @@ mod test { // let's try to iterate over a more restrictive range let all: StdResult> = PEOPLE_ID - .range2(&store, 57u32.inclusive_bound(), None, Order::Ascending) + .range(&store, 57u32.inclusive_bound(), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(1, all.len()); @@ -800,7 +771,7 @@ mod test { // let's try to iterate! let all: StdResult> = SIGNED_ID - .range2(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(3, all.len()); @@ -812,7 +783,7 @@ mod test { // let's try to iterate over a range let all: StdResult> = SIGNED_ID - .range2(&store, (-56i32).inclusive_bound(), None, Order::Ascending) + .range(&store, (-56i32).inclusive_bound(), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -820,7 +791,7 @@ mod test { // let's try to iterate over a more restrictive range let all: StdResult> = SIGNED_ID - .range2( + .range( &store, (-55i32).inclusive_bound(), 50i32.inclusive_bound(), @@ -1008,7 +979,7 @@ mod test { // let's try to iterate! let all: StdResult> = ALLOWANCE - .range2(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(3, all.len()); @@ -1024,7 +995,7 @@ mod test { // let's try to iterate over a prefix let all: StdResult> = ALLOWANCE .prefix(b"owner") - .range2(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -1036,7 +1007,7 @@ mod test { // let's try to iterate over a prefixed restricted inclusive range let all: StdResult> = ALLOWANCE .prefix(b"owner") - .range2(&store, b"spender".inclusive_bound(), None, Order::Ascending) + .range(&store, b"spender".inclusive_bound(), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -1048,7 +1019,7 @@ mod test { // let's try to iterate over a prefixed restricted exclusive range let all: StdResult> = ALLOWANCE .prefix(b"owner") - .range2(&store, b"spender".exclusive_bound(), None, Order::Ascending) + .range(&store, b"spender".exclusive_bound(), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(1, all.len()); @@ -1220,9 +1191,7 @@ mod test { .unwrap(); // let's try to iterate! - let all: StdResult> = TRIPLE - .range2(&store, None, None, Order::Ascending) - .collect(); + let all: StdResult> = TRIPLE.range(&store, None, None, Order::Ascending).collect(); let all = all.unwrap(); assert_eq!(4, all.len()); assert_eq!( @@ -1238,7 +1207,7 @@ mod test { // let's iterate over a sub_prefix let all: StdResult> = TRIPLE .sub_prefix(b"owner") - .range2(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(3, all.len()); @@ -1254,7 +1223,7 @@ mod test { // let's iterate over a prefix let all: StdResult> = TRIPLE .prefix((b"owner", 9)) - .range2(&store, None, None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -1269,7 +1238,7 @@ mod test { // let's try to iterate over a prefixed restricted inclusive range let all: StdResult> = TRIPLE .prefix((b"owner", 9)) - .range2( + .range( &store, "recipient".inclusive_bound(), None, @@ -1289,7 +1258,7 @@ mod test { // let's try to iterate over a prefixed restricted exclusive range let all: StdResult> = TRIPLE .prefix((b"owner", 9)) - .range2( + .range( &store, "recipient".exclusive_bound(), None, diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 9a40fd402..8c5180ef9 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -175,12 +175,19 @@ where de_fn_v, } } +} +impl<'b, K, T, B> Prefix +where + B: PrimaryKey<'b>, + K: KeyDeserialize, + T: Serialize + DeserializeOwned, +{ pub fn range_raw<'a>( &self, store: &'a dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: Order, ) -> Box>> + 'a> where @@ -188,28 +195,40 @@ where { let de_fn = self.de_fn_v; let pk_name = self.pk_name.clone(); - let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) - .map(move |kv| (de_fn)(store, &pk_name, kv)); + let mapped = range_with_prefix( + store, + &self.storage_prefix, + min.map(|b| b.to_raw_bound()), + max.map(|b| b.to_raw_bound()), + order, + ) + .map(move |kv| (de_fn)(store, &pk_name, kv)); Box::new(mapped) } pub fn keys_raw<'a>( &self, store: &'a dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: Order, ) -> Box> + 'a> { - let mapped = - range_with_prefix(store, &self.storage_prefix, min, max, order).map(|(k, _)| k); + let mapped = range_with_prefix( + store, + &self.storage_prefix, + min.map(|b| b.to_raw_bound()), + max.map(|b| b.to_raw_bound()), + order, + ) + .map(|(k, _)| k); Box::new(mapped) } pub fn range<'a>( &self, store: &'a dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: Order, ) -> Box> + 'a> where @@ -218,49 +237,6 @@ where { let de_fn = self.de_fn_kv; let pk_name = self.pk_name.clone(); - let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) - .map(move |kv| (de_fn)(store, &pk_name, kv)); - Box::new(mapped) - } - - pub fn keys<'a>( - &self, - store: &'a dyn Storage, - min: Option, - max: Option, - order: Order, - ) -> Box> + 'a> - where - T: 'a, - K::Output: 'static, - { - let de_fn = self.de_fn_kv; - let pk_name = self.pk_name.clone(); - let mapped = range_with_prefix(store, &self.storage_prefix, min, max, order) - .map(move |kv| (de_fn)(store, &pk_name, kv).map(|(k, _)| Ok(k))) - .flatten(); - Box::new(mapped) - } -} - -impl<'b, K, T, B> Prefix -where - B: PrimaryKey<'b>, - K: KeyDeserialize, - T: Serialize + DeserializeOwned, -{ - pub fn range2_raw<'a>( - &self, - store: &'a dyn Storage, - min: Option>, - max: Option>, - order: Order, - ) -> Box>> + 'a> - where - T: 'a, - { - let de_fn = self.de_fn_v; - let pk_name = self.pk_name.clone(); let mapped = range_with_prefix( store, &self.storage_prefix, @@ -272,13 +248,13 @@ where Box::new(mapped) } - pub fn range2<'a>( + pub fn keys<'a>( &self, store: &'a dyn Storage, min: Option>, max: Option>, order: Order, - ) -> Box> + 'a> + ) -> Box> + 'a> where T: 'a, K::Output: 'static, @@ -292,7 +268,8 @@ where max.map(|b| b.to_raw_bound()), order, ) - .map(move |kv| (de_fn)(store, &pk_name, kv)); + .map(move |kv| (de_fn)(store, &pk_name, kv).map(|(k, _)| Ok(k))) + .flatten(); Box::new(mapped) } } diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index d52713fa5..db142e4a8 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -8,9 +8,9 @@ use crate::iter_helpers::deserialize_kv; use crate::keys::PrimaryKey; use crate::map::Map; use crate::path::Path; -use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound}; +use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; use crate::snapshot::{ChangeSet, Snapshot}; -use crate::{Prefixer, RawBound, Strategy}; +use crate::{Prefixer, Strategy}; /// Map that maintains a snapshots of one or more checkpoints. /// We can query historical data as well as current state. @@ -171,8 +171,8 @@ where pub fn range_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box>> + 'c> where @@ -184,8 +184,8 @@ where pub fn keys_raw<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -228,8 +228,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -242,8 +242,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option, - max: Option, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -253,15 +253,15 @@ where self.no_prefix().keys(store, min, max, order) } - pub fn prefix(&self, p: K::Prefix) -> Prefix { + pub fn prefix(&self, p: K::Prefix) -> Prefix { Prefix::new(self.primary.namespace(), &p.prefix()) } - pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { + pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { Prefix::new(self.primary.namespace(), &p.prefix()) } - fn no_prefix(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::new(self.primary.namespace(), &[]) } } diff --git a/packages/storage-plus/src/snapshot/mod.rs b/packages/storage-plus/src/snapshot/mod.rs index 9caf904d3..bf2436c9e 100644 --- a/packages/storage-plus/src/snapshot/mod.rs +++ b/packages/storage-plus/src/snapshot/mod.rs @@ -6,7 +6,8 @@ pub use item::SnapshotItem; pub use map::SnapshotMap; use crate::de::KeyDeserialize; -use crate::{Map, Prefixer, PrimaryKey, RawBound}; +use crate::prefix::Bound; +use crate::{Map, Prefixer, PrimaryKey}; use cosmwasm_std::{Order, StdError, StdResult, Storage}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; @@ -79,12 +80,12 @@ where // most recent checkpoint let checkpoint = self .checkpoints - .range_raw(store, None, None, Order::Descending) + .range(store, None, None, Order::Descending) .next() .transpose()?; if let Some((height, _)) = checkpoint { // any changelog for the given key since then? - let start = RawBound::inclusive(height); + let start = Bound::inclusive(height); let first = self .changelog .prefix(k.clone()) @@ -143,7 +144,7 @@ where // this will look for the first snapshot of height >= given height // If None, there is no snapshot since that time. - let start = RawBound::inclusive_int(height); + let start = Bound::inclusive(height); let first = self .changelog .prefix(key) From 7e88c48fa3a6d75e2009ff4a056d2a9e039ccad5 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 9 Jan 2022 10:54:06 +0100 Subject: [PATCH 190/352] Replace RawBound by Bound in tests --- packages/storage-plus/src/indexed_map.rs | 15 +++----- packages/storage-plus/src/indexed_snapshot.rs | 7 +--- packages/storage-plus/src/map.rs | 32 +++++++++-------- packages/storage-plus/src/prefix.rs | 34 +++++++++++-------- packages/storage-plus/src/snapshot/item.rs | 9 ++--- packages/storage-plus/src/snapshot/map.rs | 21 ++---------- 6 files changed, 46 insertions(+), 72 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 2057329dc..67ab57652 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -461,7 +461,7 @@ mod test { .name .range_raw( &store, - Some(RawBound::inclusive(key)), + Some(Bound::InclusiveRaw(key)), None, Order::Ascending, ) @@ -481,7 +481,7 @@ mod test { .name .range_raw( &store, - Some(RawBound::exclusive(key)), + Some(Bound::ExclusiveRaw(key)), None, Order::Ascending, ) @@ -491,15 +491,13 @@ mod test { // index_key() over UniqueIndex works. let age_key = 23u32; - // Use the index_key() helper to build the (raw) index key - let age_key = map.idx.age.index_key(age_key); // Iterate using a (inclusive) bound over the raw key. let count = map .idx .age .range_raw( &store, - Some(RawBound::inclusive(age_key)), + Some(Bound::inclusive(age_key)), None, Order::Ascending, ) @@ -1007,12 +1005,7 @@ mod test { // let's try to iterate over a range let all: StdResult> = map - .range( - &store, - Some(RawBound::Inclusive(b"3".to_vec())), - None, - Order::Ascending, - ) + .range(&store, Some(Bound::inclusive("3")), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!( diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index ea305f5d9..f15297506 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -1058,12 +1058,7 @@ mod test { // let's try to iterate over a range let all: StdResult> = map - .range( - &store, - Some(RawBound::Inclusive(b"3".to_vec())), - None, - Order::Ascending, - ) + .range(&store, Some(Bound::inclusive("3")), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!( diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 6e83fabaa..6ebe57da7 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -263,7 +263,7 @@ mod test { use cosmwasm_std::{Order, StdResult}; use crate::int_key::CwIntKey; - use crate::keys_old::IntKeyOld; + // use crate::keys_old::IntKeyOld; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] struct Data { @@ -274,8 +274,8 @@ mod test { const PEOPLE: Map<&[u8], Data> = Map::new("people"); #[cfg(feature = "iterator")] const PEOPLE_ID: Map = Map::new("people_id"); - #[cfg(feature = "iterator")] - const SIGNED_ID_OLD: Map, Data> = Map::new("signed_id"); + // #[cfg(feature = "iterator")] + // const SIGNED_ID_OLD: Map, Data> = Map::new("signed_id"); #[cfg(feature = "iterator")] const SIGNED_ID: Map = Map::new("signed_id"); @@ -444,7 +444,7 @@ mod test { let all: StdResult> = PEOPLE .range_raw( &store, - Some(RawBound::Inclusive(b"j".to_vec())), + Some(Bound::inclusive(b"j" as &[u8])), None, Order::Ascending, ) @@ -460,7 +460,7 @@ mod test { let all: StdResult> = PEOPLE .range_raw( &store, - Some(RawBound::Inclusive(b"jo".to_vec())), + Some(Bound::inclusive(b"jo" as &[u8])), None, Order::Ascending, ) @@ -504,7 +504,7 @@ mod test { let all: StdResult> = PEOPLE .range( &store, - Some(RawBound::Inclusive(b"j".to_vec())), + Some(Bound::inclusive(b"j" as &[u8])), None, Order::Ascending, ) @@ -520,7 +520,7 @@ mod test { let all: StdResult> = PEOPLE .range( &store, - Some(RawBound::Inclusive(b"jo".to_vec())), + Some(Bound::inclusive(b"jo" as &[u8])), None, Order::Ascending, ) @@ -617,7 +617,7 @@ mod test { let all: StdResult> = PEOPLE_ID .range( &store, - Some(RawBound::inclusive_int(56u32)), + Some(Bound::inclusive(56u32)), None, Order::Ascending, ) @@ -630,7 +630,7 @@ mod test { let all: StdResult> = PEOPLE_ID .range( &store, - Some(RawBound::inclusive_int(57u32)), + Some(Bound::inclusive(57u32)), None, Order::Ascending, ) @@ -722,7 +722,7 @@ mod test { let all: StdResult> = SIGNED_ID .range( &store, - Some(RawBound::inclusive_int(-56i32)), + Some(Bound::inclusive(-56i32)), None, Order::Ascending, ) @@ -735,8 +735,8 @@ mod test { let all: StdResult> = SIGNED_ID .range( &store, - Some(RawBound::inclusive_int(-55i32)), - Some(RawBound::inclusive_int(50i32)), + Some(Bound::inclusive(-55i32)), + Some(Bound::inclusive(50i32)), Order::Descending, ) .collect(); @@ -803,6 +803,7 @@ mod test { assert_eq!(all, vec![(50, data3)]); } + /* #[test] #[cfg(feature = "iterator")] fn range_signed_integer_key_migration() { @@ -872,6 +873,7 @@ mod test { // confirm new order is right assert_eq!(new, vec![(-1234, data), (-56, data2), (50, data3)]); } + */ #[test] #[cfg(feature = "iterator")] @@ -1428,7 +1430,7 @@ mod test { let all: StdResult> = PEOPLE .range_raw( &store, - Some(RawBound::Exclusive(b"jim".to_vec())), + Some(Bound::exclusive(b"jim" as &[u8])), None, Order::Ascending, ) @@ -1455,8 +1457,8 @@ mod test { .prefix(b"owner") .range_raw( &store, - Some(RawBound::Exclusive(b"spender1".to_vec())), - Some(RawBound::Inclusive(b"spender2".to_vec())), + Some(Bound::exclusive(b"spender1" as &[u8])), + Some(Bound::inclusive(b"spender2" as &[u8])), Order::Descending, ) .collect(); diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 8c5180ef9..01edfbb34 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -54,6 +54,8 @@ impl RawBound { pub enum Bound<'a, K: PrimaryKey<'a>> { Inclusive((K, PhantomData<&'a bool>)), Exclusive((K, PhantomData<&'a bool>)), + InclusiveRaw(Vec), + ExclusiveRaw(Vec), } impl<'a, K: PrimaryKey<'a>> Bound<'a, K> { @@ -67,8 +69,10 @@ impl<'a, K: PrimaryKey<'a>> Bound<'a, K> { pub fn to_raw_bound(&self) -> RawBound { match self { - Bound::Exclusive((k, _)) => RawBound::Exclusive(k.joined_key()), Bound::Inclusive((k, _)) => RawBound::Inclusive(k.joined_key()), + Bound::Exclusive((k, _)) => RawBound::Exclusive(k.joined_key()), + Bound::ExclusiveRaw(raw_k) => RawBound::Exclusive(raw_k.clone()), + Bound::InclusiveRaw(raw_k) => RawBound::Inclusive(raw_k.clone()), } } } @@ -423,7 +427,7 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(RawBound::Inclusive(b"ra".to_vec())), + Some(Bound::inclusive(b"ra".to_vec())), None, Order::Ascending, ) @@ -433,7 +437,7 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(RawBound::Exclusive(b"ra".to_vec())), + Some(Bound::exclusive(b"ra".to_vec())), None, Order::Ascending, ) @@ -443,7 +447,7 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(RawBound::Exclusive(b"r".to_vec())), + Some(Bound::exclusive(b"r".to_vec())), None, Order::Ascending, ) @@ -455,7 +459,7 @@ mod test { .range_raw( &store, None, - Some(RawBound::Inclusive(b"ra".to_vec())), + Some(Bound::inclusive(b"ra".to_vec())), Order::Descending, ) .collect(); @@ -465,7 +469,7 @@ mod test { .range_raw( &store, None, - Some(RawBound::Exclusive(b"ra".to_vec())), + Some(Bound::exclusive(b"ra".to_vec())), Order::Descending, ) .collect(); @@ -475,7 +479,7 @@ mod test { .range_raw( &store, None, - Some(RawBound::Exclusive(b"rb".to_vec())), + Some(Bound::exclusive(b"rb".to_vec())), Order::Descending, ) .collect(); @@ -485,8 +489,8 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(RawBound::Inclusive(b"ra".to_vec())), - Some(RawBound::Exclusive(b"zi".to_vec())), + Some(Bound::inclusive(b"ra".to_vec())), + Some(Bound::exclusive(b"zi".to_vec())), Order::Ascending, ) .collect(); @@ -495,8 +499,8 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(RawBound::Inclusive(b"ra".to_vec())), - Some(RawBound::Exclusive(b"zi".to_vec())), + Some(Bound::inclusive(b"ra".to_vec())), + Some(Bound::exclusive(b"zi".to_vec())), Order::Descending, ) .collect(); @@ -505,8 +509,8 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(RawBound::Inclusive(b"ra".to_vec())), - Some(RawBound::Inclusive(b"zi".to_vec())), + Some(Bound::inclusive(b"ra".to_vec())), + Some(Bound::inclusive(b"zi".to_vec())), Order::Descending, ) .collect(); @@ -515,8 +519,8 @@ mod test { let res: StdResult> = prefix .range_raw( &store, - Some(RawBound::Exclusive(b"ra".to_vec())), - Some(RawBound::Exclusive(b"zi".to_vec())), + Some(Bound::exclusive(b"ra".to_vec())), + Some(Bound::exclusive(b"zi".to_vec())), Order::Ascending, ) .collect(); diff --git a/packages/storage-plus/src/snapshot/item.rs b/packages/storage-plus/src/snapshot/item.rs index 1fe58c332..51daaa6d2 100644 --- a/packages/storage-plus/src/snapshot/item.rs +++ b/packages/storage-plus/src/snapshot/item.rs @@ -132,6 +132,7 @@ where #[cfg(test)] mod tests { use super::*; + use crate::prefix::Bound; use cosmwasm_std::testing::MockStorage; type TestItem = SnapshotItem<'static, u64>; @@ -283,7 +284,6 @@ mod tests { #[test] #[cfg(feature = "iterator")] fn changelog_range_works() { - use crate::RawBound; use cosmwasm_std::Order; let mut store = MockStorage::new(); @@ -316,12 +316,7 @@ mod tests { // let's try to iterate over a changelog range let all: StdResult> = EVERY .changelog() - .range( - &store, - Some(RawBound::exclusive_int(3u64)), - None, - Order::Ascending, - ) + .range(&store, Some(Bound::exclusive(3u64)), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(1, all.len()); diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index db142e4a8..fd003faaf 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -514,12 +514,7 @@ mod tests { let all: StdResult> = EVERY .changelog() .prefix("A") - .range( - &store, - Some(RawBound::inclusive_int(3u64)), - None, - Order::Ascending, - ) + .range(&store, Some(Bound::inclusive(3u64)), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(1, all.len()); @@ -542,12 +537,7 @@ mod tests { // let's try to iterate over a range let all: StdResult> = EVERY - .range( - &store, - Some(RawBound::Inclusive(b"C".to_vec())), - None, - Order::Ascending, - ) + .range(&store, Some(Bound::inclusive("C")), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(2, all.len()); @@ -555,12 +545,7 @@ mod tests { // let's try to iterate over a more restrictive range let all: StdResult> = EVERY - .range( - &store, - Some(RawBound::Inclusive(b"D".to_vec())), - None, - Order::Ascending, - ) + .range(&store, Some(Bound::inclusive("D")), None, Order::Ascending) .collect(); let all = all.unwrap(); assert_eq!(1, all.len()); From 1db0b8c50068084f2654d0c14bd4770722e8433f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 9 Jan 2022 10:55:12 +0100 Subject: [PATCH 191/352] Publish Bound enum and Bounder trait --- packages/storage-plus/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 35200acff..d560020d9 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -28,11 +28,11 @@ pub use indexes::UniqueIndex; pub use indexes::{index_string, index_string_tuple, index_triple, index_tuple, Index}; pub use int_key::CwIntKey; pub use item::Item; -pub use keys::{Key, Prefixer, PrimaryKey}; +pub use keys::{Bounder, Key, Prefixer, PrimaryKey}; pub use keys_old::IntKeyOld; pub use map::Map; pub use path::Path; #[cfg(feature = "iterator")] -pub use prefix::{range_with_prefix, Prefix, PrefixBound, RawBound}; +pub use prefix::{range_with_prefix, Bound, Prefix, PrefixBound, RawBound}; #[cfg(feature = "iterator")] pub use snapshot::{SnapshotItem, SnapshotMap, Strategy}; From ef1d2cc7ed08be36a63ab80d4584e18c43365763 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 9 Jan 2022 11:40:22 +0100 Subject: [PATCH 192/352] Migrate packages to Bound --- packages/utils/src/pagination.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/utils/src/pagination.rs b/packages/utils/src/pagination.rs index ba6e825a1..a88996acb 100644 --- a/packages/utils/src/pagination.rs +++ b/packages/utils/src/pagination.rs @@ -37,7 +37,7 @@ pub fn calc_range_start_string(start_after: Option) -> Option> { mod test { use super::*; use cosmwasm_std::{testing::mock_dependencies, Order}; - use cw_storage_plus::{RawBound, Map}; + use cw_storage_plus::{Bound, Map}; pub const HOLDERS: Map<&Addr, usize> = Map::new("some_data"); const LIMIT: usize = 30; @@ -64,7 +64,7 @@ mod test { Some(addr_from_i(j * LIMIT - 1)) }; - let start = calc_range_start(start_after).map(RawBound::exclusive); + let start = calc_range_start(start_after).map(Bound::ExclusiveRaw); let holders = HOLDERS .keys(&deps.storage, start, None, Order::Ascending) @@ -93,7 +93,7 @@ mod test { for j in 0..4 { let end_before = Some(addr_from_i(total_elements_count - j * LIMIT)); - let end = calc_range_end(end_before).map(RawBound::exclusive); + let end = calc_range_end(end_before).map(Bound::ExclusiveRaw); let holders = HOLDERS .keys(&deps.storage, None, end, Order::Descending) From 828dd1a8d8eea6ffc816b09d5d77e26dc00deba7 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 9 Jan 2022 14:24:53 +0100 Subject: [PATCH 193/352] Migrate contracts to type safe Bound --- contracts/cw1-subkeys/src/contract.rs | 6 +++--- contracts/cw1155-base/src/contract.rs | 8 ++++---- contracts/cw20-base/src/enumerable.rs | 6 +++--- contracts/cw3-fixed-multisig/src/contract.rs | 10 +++++----- contracts/cw3-flex-multisig/src/contract.rs | 8 ++++---- contracts/cw4-group/src/contract.rs | 4 ++-- contracts/cw4-stake/src/contract.rs | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/contract.rs index e6535ae2f..0b6fe1165 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs @@ -18,7 +18,7 @@ use cw1_whitelist::{ state::ADMIN_LIST, }; use cw2::{get_contract_version, set_contract_version}; -use cw_storage_plus::RawBound; +use cw_storage_plus::Bound; use cw_utils::Expiration; use semver::Version; @@ -407,7 +407,7 @@ pub fn query_all_allowances( ) -> StdResult { let limit = calc_limit(limit); // we use raw addresses here.... - let start = start_after.map(RawBound::exclusive); + let start = start_after.map(|s| Bound::ExclusiveRaw(s.into())); let allowances = ALLOWANCES .range(deps.storage, start, None, Order::Ascending) @@ -437,7 +437,7 @@ pub fn query_all_permissions( limit: Option, ) -> StdResult { let limit = calc_limit(limit); - let start = start_after.map(RawBound::exclusive); + let start = start_after.map(|s| Bound::ExclusiveRaw(s.into())); let permissions = PERMISSIONS .range(deps.storage, start, None, Order::Ascending) diff --git a/contracts/cw1155-base/src/contract.rs b/contracts/cw1155-base/src/contract.rs index 4f254a144..8150809f1 100644 --- a/contracts/cw1155-base/src/contract.rs +++ b/contracts/cw1155-base/src/contract.rs @@ -3,7 +3,7 @@ use cosmwasm_std::{ to_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Order, Response, StdResult, SubMsg, Uint128, }; -use cw_storage_plus::RawBound; +use cw_storage_plus::Bound; use cw1155::{ ApproveAllEvent, ApprovedForAllResponse, BalanceResponse, BatchBalanceResponse, @@ -494,7 +494,7 @@ fn query_all_approvals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(|addr| RawBound::exclusive(addr.as_ref())); + let start = start_after.as_ref().map(Bound::exclusive); let operators = APPROVES .prefix(&owner) @@ -513,7 +513,7 @@ fn query_tokens( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(RawBound::exclusive); + let start = start_after.as_ref().map(|s| Bound::exclusive(s.as_str())); let tokens = BALANCES .prefix(&owner) @@ -529,7 +529,7 @@ fn query_all_tokens( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(RawBound::exclusive); + let start = start_after.as_ref().map(|s| Bound::exclusive(s.as_str())); let tokens = TOKENS .keys(deps.storage, start, None, Order::Ascending) .take(limit) diff --git a/contracts/cw20-base/src/enumerable.rs b/contracts/cw20-base/src/enumerable.rs index 2d165a1d5..aa5998d86 100644 --- a/contracts/cw20-base/src/enumerable.rs +++ b/contracts/cw20-base/src/enumerable.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{Deps, Order, StdResult}; use cw20::{AllAccountsResponse, AllAllowancesResponse, AllowanceInfo}; use crate::state::{ALLOWANCES, BALANCES}; -use cw_storage_plus::RawBound; +use cw_storage_plus::Bound; // settings for pagination const MAX_LIMIT: u32 = 30; @@ -16,7 +16,7 @@ pub fn query_all_allowances( ) -> StdResult { let owner_addr = deps.api.addr_validate(&owner)?; let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(RawBound::exclusive); + let start = start_after.map(|s| Bound::ExclusiveRaw(s.as_bytes().into())); let allowances = ALLOWANCES .prefix(&owner_addr) @@ -39,7 +39,7 @@ pub fn query_all_accounts( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(RawBound::exclusive); + let start = start_after.map(|s| Bound::ExclusiveRaw(s.into())); let accounts = BALANCES .keys(deps.storage, start, None, Order::Ascending) diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 284df3c93..5928bcf82 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -12,7 +12,7 @@ use cw3::{ ProposalListResponse, ProposalResponse, Status, Vote, VoteInfo, VoteListResponse, VoteResponse, VoterDetail, VoterListResponse, VoterResponse, }; -use cw_storage_plus::RawBound; +use cw_storage_plus::Bound; use cw_utils::{Expiration, ThresholdResponse}; use crate::error::ContractError; @@ -287,7 +287,7 @@ fn list_proposals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(RawBound::exclusive_int); + let start = start_after.map(Bound::exclusive); let proposals = PROPOSALS .range(deps.storage, start, None, Order::Ascending) .take(limit) @@ -304,7 +304,7 @@ fn reverse_proposals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let end = start_before.map(RawBound::exclusive_int); + let end = start_before.map(Bound::exclusive); let props: StdResult> = PROPOSALS .range(deps.storage, None, end, Order::Descending) .take(limit) @@ -351,7 +351,7 @@ fn list_votes( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(RawBound::exclusive); + let start = start_after.map(|s| Bound::ExclusiveRaw(s.into())); let votes = BALLOTS .prefix(proposal_id) @@ -381,7 +381,7 @@ fn list_voters( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(RawBound::exclusive); + let start = start_after.map(|s| Bound::ExclusiveRaw(s.into())); let voters = VOTERS .range(deps.storage, start, None, Order::Ascending) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 50243ab59..6b31f1071 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -14,7 +14,7 @@ use cw3::{ }; use cw3_fixed_multisig::state::{next_id, Ballot, Proposal, Votes, BALLOTS, PROPOSALS}; use cw4::{Cw4Contract, MemberChangedHookMsg, MemberDiff}; -use cw_storage_plus::RawBound; +use cw_storage_plus::Bound; use cw_utils::{maybe_addr, Expiration, ThresholdResponse}; use crate::error::ContractError; @@ -315,7 +315,7 @@ fn list_proposals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(RawBound::exclusive_int); + let start = start_after.map(Bound::exclusive); let proposals = PROPOSALS .range(deps.storage, start, None, Order::Ascending) .take(limit) @@ -332,7 +332,7 @@ fn reverse_proposals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let end = start_before.map(RawBound::exclusive_int); + let end = start_before.map(Bound::exclusive); let props: StdResult> = PROPOSALS .range(deps.storage, None, end, Order::Descending) .take(limit) @@ -380,7 +380,7 @@ fn list_votes( ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let addr = maybe_addr(deps.api, start_after)?; - let start = addr.map(|addr| RawBound::exclusive(addr.as_ref())); + let start = addr.as_ref().map(Bound::exclusive); let votes = BALLOTS .prefix(proposal_id) diff --git a/contracts/cw4-group/src/contract.rs b/contracts/cw4-group/src/contract.rs index 9a7a86cde..913d427f6 100644 --- a/contracts/cw4-group/src/contract.rs +++ b/contracts/cw4-group/src/contract.rs @@ -9,7 +9,7 @@ use cw4::{ Member, MemberChangedHookMsg, MemberDiff, MemberListResponse, MemberResponse, TotalWeightResponse, }; -use cw_storage_plus::RawBound; +use cw_storage_plus::Bound; use cw_utils::maybe_addr; use crate::error::ContractError; @@ -190,7 +190,7 @@ fn list_members( ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let addr = maybe_addr(deps.api, start_after)?; - let start = addr.map(|addr| RawBound::exclusive(addr.to_string())); + let start = addr.as_ref().map(Bound::exclusive); let members = MEMBERS .range(deps.storage, start, None, Order::Ascending) diff --git a/contracts/cw4-stake/src/contract.rs b/contracts/cw4-stake/src/contract.rs index 28b91ef1a..6b51897b5 100644 --- a/contracts/cw4-stake/src/contract.rs +++ b/contracts/cw4-stake/src/contract.rs @@ -11,7 +11,7 @@ use cw4::{ Member, MemberChangedHookMsg, MemberDiff, MemberListResponse, MemberResponse, TotalWeightResponse, }; -use cw_storage_plus::RawBound; +use cw_storage_plus::Bound; use cw_utils::{maybe_addr, NativeBalance}; use crate::error::ContractError; @@ -339,7 +339,7 @@ fn list_members( ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; let addr = maybe_addr(deps.api, start_after)?; - let start = addr.map(|addr| RawBound::exclusive(addr.as_ref())); + let start = addr.as_ref().map(Bound::exclusive); let members = MEMBERS .range(deps.storage, start, None, Order::Ascending) From 849c55be92c36bd3cb58b7cd8bedb0cd1492fb6c Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 9 Jan 2022 14:53:25 +0100 Subject: [PATCH 194/352] Implement Bounder for IntKeyOld --- packages/storage-plus/src/keys_old.rs | 16 +++++++++++++++- packages/storage-plus/src/map.rs | 8 +++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/storage-plus/src/keys_old.rs b/packages/storage-plus/src/keys_old.rs index d864153e2..8a25617fe 100644 --- a/packages/storage-plus/src/keys_old.rs +++ b/packages/storage-plus/src/keys_old.rs @@ -1,6 +1,6 @@ use crate::de::KeyDeserialize; use crate::keys::Key; -use crate::{Endian, Prefixer, PrimaryKey}; +use crate::{Bound, Bounder, Endian, Prefixer, PrimaryKey}; use std::marker::PhantomData; #[derive(Clone, Debug, PartialEq, Eq)] @@ -61,6 +61,20 @@ impl<'a, T: Endian> Prefixer<'a> for IntKeyOld { } } +// this auto-implements Bounder for all the IntKey types +impl<'a, T: Endian> Bounder<'a> for IntKeyOld +where + IntKeyOld: KeyDeserialize, +{ + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) + } + + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) + } +} + #[cfg(test)] mod test { use super::*; diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 6ebe57da7..029a5c279 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -263,7 +263,7 @@ mod test { use cosmwasm_std::{Order, StdResult}; use crate::int_key::CwIntKey; - // use crate::keys_old::IntKeyOld; + use crate::IntKeyOld; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] struct Data { @@ -274,8 +274,8 @@ mod test { const PEOPLE: Map<&[u8], Data> = Map::new("people"); #[cfg(feature = "iterator")] const PEOPLE_ID: Map = Map::new("people_id"); - // #[cfg(feature = "iterator")] - // const SIGNED_ID_OLD: Map, Data> = Map::new("signed_id"); + #[cfg(feature = "iterator")] + const SIGNED_ID_OLD: Map, Data> = Map::new("signed_id"); #[cfg(feature = "iterator")] const SIGNED_ID: Map = Map::new("signed_id"); @@ -803,7 +803,6 @@ mod test { assert_eq!(all, vec![(50, data3)]); } - /* #[test] #[cfg(feature = "iterator")] fn range_signed_integer_key_migration() { @@ -873,7 +872,6 @@ mod test { // confirm new order is right assert_eq!(new, vec![(-1234, data), (-56, data2), (50, data3)]); } - */ #[test] #[cfg(feature = "iterator")] From 393abb95b8c922e165e2bf5cf5f5f021fe5ddba9 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 9 Jan 2022 14:58:35 +0100 Subject: [PATCH 195/352] Remove obsolete RawBound helpers --- packages/storage-plus/src/prefix.rs | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 01edfbb34..3dcc42ab9 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -8,10 +8,9 @@ use std::ops::Deref; use crate::de::KeyDeserialize; use crate::helpers::{namespaces_with_key, nested_namespaces_with_key}; -use crate::int_key::CwIntKey; use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim}; use crate::keys::Key; -use crate::{Endian, Prefixer, PrimaryKey}; +use crate::{Prefixer, PrimaryKey}; /// `RawBound` is used to define the two ends of a range, more explicit than `Option`. /// `None` means that we don't limit that side of the range at all. @@ -24,28 +23,6 @@ pub enum RawBound { Exclusive(Vec), } -impl RawBound { - /// Turns optional binary, like Option into an inclusive bound - pub fn inclusive>>(limit: T) -> Self { - RawBound::Inclusive(limit.into()) - } - - /// Turns optional binary, like Option into an exclusive bound - pub fn exclusive>>(limit: T) -> Self { - RawBound::Exclusive(limit.into()) - } - - /// Turns an int, like Option into an inclusive bound - pub fn inclusive_int(limit: T) -> Self { - RawBound::Inclusive(limit.to_cw_bytes().into()) - } - - /// Turns an int, like Option into an exclusive bound - pub fn exclusive_int(limit: T) -> Self { - RawBound::Exclusive(limit.to_cw_bytes().into()) - } -} - /// `Bound` is used to define the two ends of a range. /// `None` means that we don't limit that side of the range at all. /// `Inclusive` means we use the given value as a limit and *include* anything at that exact key. From 4e3ba553186ba0ce2c7b5f3f4ec9e358ef76b8e6 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 9 Jan 2022 20:40:52 +0100 Subject: [PATCH 196/352] Fix MultiIndex bound type Use tuple of IK and PK for multi index bound type --- packages/storage-plus/src/indexed_map.rs | 35 +++++++++++----------- packages/storage-plus/src/indexes/multi.rs | 23 +++++++------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 67ab57652..c41dc5872 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -449,19 +449,26 @@ mod test { .count(); assert_eq!(0, count); - // index_key() over MultiIndex works (empty pk) - // In a MultiIndex, an index key is composed by the index and the primary key. + // In a MultiIndex, the index key is composed by the index and the primary key. // Primary key may be empty (so that to iterate over all elements that match just the index) + let key = ("Maria".to_string(), "".to_string()); + // Iterate using an inclusive bound over the key + let count = map + .idx + .name + .range_raw(&store, Some(Bound::inclusive(key)), None, Order::Ascending) + .count(); + // gets from the first "Maria" until the end + assert_eq!(4, count); + + // This is equivalent to using prefix_range let key = "Maria".to_string(); - // Use the index_key() helper to build the (raw) index key with an empty pk - let key = map.idx.name.index_key(key); - // Iterate using a bound over the raw key let count = map .idx .name - .range_raw( + .prefix_range_raw( &store, - Some(Bound::InclusiveRaw(key)), + Some(PrefixBound::inclusive(key)), None, Order::Ascending, ) @@ -469,29 +476,21 @@ mod test { // gets from the first "Maria" until the end assert_eq!(4, count); - // index_key() over MultiIndex works (non-empty pk) // Build key including a non-empty pk let key = ("Maria".to_string(), "1".to_string()); - // Use the joined_key() helper to build the (raw) index key - let key = key.joined_key(); - // Iterate using a (exclusive) bound over the raw key. + // Iterate using a (exclusive) bound over the key. // (Useful for pagination / continuation contexts). let count = map .idx .name - .range_raw( - &store, - Some(Bound::ExclusiveRaw(key)), - None, - Order::Ascending, - ) + .range_raw(&store, Some(Bound::exclusive(key)), None, Order::Ascending) .count(); // gets from the 2nd "Maria" until the end assert_eq!(3, count); // index_key() over UniqueIndex works. let age_key = 23u32; - // Iterate using a (inclusive) bound over the raw key. + // Iterate using a (inclusive) bound over the key. let count = map .idx .age diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 3ea4c6bbb..e61d2f061 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -143,7 +143,7 @@ where T: Serialize + DeserializeOwned + Clone, IK: PrimaryKey<'a> + Prefixer<'a>, { - fn no_prefix_raw(&self) -> Prefix, T, IK> { + fn no_prefix_raw(&self) -> Prefix, T, (IK, PK)> { Prefix::with_deserialization_functions( self.idx_namespace, &[], @@ -191,15 +191,16 @@ where impl<'a, IK, T, PK> MultiIndex<'a, IK, T, PK> where T: Serialize + DeserializeOwned + Clone, - IK: PrimaryKey<'a> + Prefixer<'a>, + IK: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize, + PK: PrimaryKey<'a> + KeyDeserialize, { // I would prefer not to copy code from Prefix, but no other way // with lifetimes (create Prefix inside function and return ref = no no) pub fn range_raw<'c>( &'c self, store: &'c dyn Storage, - min: Option>, - max: Option>, + min: Option>, + max: Option>, order: Order, ) -> Box>> + 'c> where @@ -211,8 +212,8 @@ where pub fn keys_raw<'c>( &'c self, store: &'c dyn Storage, - min: Option>, - max: Option>, + min: Option>, + max: Option>, order: Order, ) -> Box> + 'c> { self.no_prefix_raw().keys_raw(store, min, max, order) @@ -304,8 +305,8 @@ where pub fn range<'c>( &self, store: &'c dyn Storage, - min: Option>, - max: Option>, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -318,8 +319,8 @@ where pub fn keys<'c>( &self, store: &'c dyn Storage, - min: Option>, - max: Option>, + min: Option>, + max: Option>, order: cosmwasm_std::Order, ) -> Box> + 'c> where @@ -329,7 +330,7 @@ where self.no_prefix().keys(store, min, max, order) } - fn no_prefix(&self) -> Prefix { + fn no_prefix(&self) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &[], From 321cc9c152b476b9f0a3b4cf226af257aa229aba Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 9 Jan 2022 20:52:51 +0100 Subject: [PATCH 197/352] Improve indexed map multi index tests --- packages/storage-plus/src/indexed_map.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index c41dc5872..b6098e49c 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -453,17 +453,18 @@ mod test { // Primary key may be empty (so that to iterate over all elements that match just the index) let key = ("Maria".to_string(), "".to_string()); // Iterate using an inclusive bound over the key - let count = map + let marias = map .idx .name .range_raw(&store, Some(Bound::inclusive(key)), None, Order::Ascending) - .count(); + .collect::>>() + .unwrap(); // gets from the first "Maria" until the end - assert_eq!(4, count); + assert_eq!(4, marias.len()); // This is equivalent to using prefix_range let key = "Maria".to_string(); - let count = map + let marias2 = map .idx .name .prefix_range_raw( @@ -472,9 +473,10 @@ mod test { None, Order::Ascending, ) - .count(); - // gets from the first "Maria" until the end - assert_eq!(4, count); + .collect::>>() + .unwrap(); + assert_eq!(4, marias2.len()); + assert_eq!(marias, marias2); // Build key including a non-empty pk let key = ("Maria".to_string(), "1".to_string()); From 6bb789662e2dacce793750ece220c88e476133f0 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 9 Jan 2022 18:14:23 +0100 Subject: [PATCH 198/352] Refactor bounds into own module --- packages/storage-plus/src/bound.rs | 184 ++++++++++++++++++ packages/storage-plus/src/indexed_map.rs | 5 +- packages/storage-plus/src/indexed_snapshot.rs | 5 +- packages/storage-plus/src/indexes/multi.rs | 5 +- packages/storage-plus/src/indexes/unique.rs | 5 +- packages/storage-plus/src/keys.rs | 113 ----------- packages/storage-plus/src/keys_old.rs | 5 +- packages/storage-plus/src/lib.rs | 7 +- packages/storage-plus/src/map.rs | 8 +- packages/storage-plus/src/prefix.rs | 68 +------ packages/storage-plus/src/snapshot/item.rs | 2 +- packages/storage-plus/src/snapshot/map.rs | 5 +- packages/storage-plus/src/snapshot/mod.rs | 2 +- 13 files changed, 217 insertions(+), 197 deletions(-) create mode 100644 packages/storage-plus/src/bound.rs diff --git a/packages/storage-plus/src/bound.rs b/packages/storage-plus/src/bound.rs new file mode 100644 index 000000000..597b569b9 --- /dev/null +++ b/packages/storage-plus/src/bound.rs @@ -0,0 +1,184 @@ +#![cfg(feature = "iterator")] + +use cosmwasm_std::Addr; +use std::marker::PhantomData; + +use crate::de::KeyDeserialize; +use crate::{Prefixer, PrimaryKey}; + +/// `RawBound` is used to define the two ends of a range, more explicit than `Option`. +/// `None` means that we don't limit that side of the range at all. +/// `Inclusive` means we use the given bytes as a limit and *include* anything at that exact key. +/// `Exclusive` means we use the given bytes as a limit and *exclude* anything at that exact key. +/// See `Bound` for a type safe way to build these bounds. +#[derive(Clone, Debug)] +pub enum RawBound { + Inclusive(Vec), + Exclusive(Vec), +} + +/// `Bound` is used to define the two ends of a range. +/// `None` means that we don't limit that side of the range at all. +/// `Inclusive` means we use the given value as a limit and *include* anything at that exact key. +/// `Exclusive` means we use the given value as a limit and *exclude* anything at that exact key. +#[derive(Clone, Debug)] +pub enum Bound<'a, K: PrimaryKey<'a>> { + Inclusive((K, PhantomData<&'a bool>)), + Exclusive((K, PhantomData<&'a bool>)), + InclusiveRaw(Vec), + ExclusiveRaw(Vec), +} + +impl<'a, K: PrimaryKey<'a>> Bound<'a, K> { + pub fn inclusive>(k: T) -> Self { + Self::Inclusive((k.into(), PhantomData)) + } + + pub fn exclusive>(k: T) -> Self { + Self::Exclusive((k.into(), PhantomData)) + } + + pub fn to_raw_bound(&self) -> RawBound { + match self { + Bound::Inclusive((k, _)) => RawBound::Inclusive(k.joined_key()), + Bound::Exclusive((k, _)) => RawBound::Exclusive(k.joined_key()), + Bound::ExclusiveRaw(raw_k) => RawBound::Exclusive(raw_k.clone()), + Bound::InclusiveRaw(raw_k) => RawBound::Inclusive(raw_k.clone()), + } + } +} + +#[derive(Clone, Debug)] +pub enum PrefixBound<'a, K: Prefixer<'a>> { + Inclusive((K, PhantomData<&'a bool>)), + Exclusive((K, PhantomData<&'a bool>)), +} + +impl<'a, K: Prefixer<'a>> PrefixBound<'a, K> { + pub fn inclusive>(k: T) -> Self { + Self::Inclusive((k.into(), PhantomData)) + } + + pub fn exclusive>(k: T) -> Self { + Self::Exclusive((k.into(), PhantomData)) + } + + pub fn to_raw_bound(&self) -> RawBound { + match self { + PrefixBound::Exclusive((k, _)) => RawBound::Exclusive(k.joined_prefix()), + PrefixBound::Inclusive((k, _)) => RawBound::Inclusive(k.joined_prefix()), + } + } +} + +pub trait Bounder<'a>: PrimaryKey<'a> + Sized { + fn inclusive_bound(self) -> Option>; + fn exclusive_bound(self) -> Option>; +} + +impl<'a> Bounder<'a> for () { + fn inclusive_bound(self) -> Option> { + None + } + fn exclusive_bound(self) -> Option> { + None + } +} + +impl<'a> Bounder<'a> for &'a [u8] { + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) + } + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) + } +} + +impl< + 'a, + T: PrimaryKey<'a> + KeyDeserialize + Prefixer<'a> + Clone, + U: PrimaryKey<'a> + KeyDeserialize + Clone, + > Bounder<'a> for (T, U) +{ + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) + } + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) + } +} + +impl< + 'a, + T: PrimaryKey<'a> + Prefixer<'a> + Clone, + U: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize + Clone, + V: PrimaryKey<'a> + KeyDeserialize + Clone, + > Bounder<'a> for (T, U, V) +{ + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) + } + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) + } +} + +impl<'a> Bounder<'a> for &'a str { + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) + } + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) + } +} + +impl<'a> Bounder<'a> for String { + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) + } + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) + } +} + +impl<'a> Bounder<'a> for Vec { + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) + } + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) + } +} + +impl<'a> Bounder<'a> for &'a Addr { + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) + } + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) + } +} + +impl<'a> Bounder<'a> for Addr { + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) + } + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) + } +} + +macro_rules! integer_bound { + (for $($t:ty),+) => { + $(impl<'a> Bounder<'a> for $t { + fn inclusive_bound(self) -> Option> { + Some(Bound::inclusive(self)) + } + fn exclusive_bound(self) -> Option> { + Some(Bound::exclusive(self)) + } + })* + } +} + +integer_bound!(for i8, u8, i16, u16, i32, u32, i64, u64); diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index b6098e49c..4033f2606 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -1,6 +1,7 @@ // this module requires iterator to be useful at all #![cfg(feature = "iterator")] +use crate::PrefixBound; use cosmwasm_std::{StdError, StdResult, Storage}; use serde::de::DeserializeOwned; use serde::Serialize; @@ -10,8 +11,8 @@ use crate::indexes::Index; use crate::iter_helpers::{deserialize_kv, deserialize_v}; use crate::keys::{Prefixer, PrimaryKey}; use crate::map::Map; -use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; -use crate::Path; +use crate::prefix::{namespaced_prefix_range, Prefix}; +use crate::{Bound, Path}; pub trait IndexList { fn get_indexes(&'_ self) -> Box> + '_>; diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index f15297506..60029b1b0 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -8,9 +8,10 @@ use serde::Serialize; use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::keys::{Prefixer, PrimaryKey}; -use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; +use crate::prefix::{namespaced_prefix_range, Prefix}; use crate::snapshot::{ChangeSet, SnapshotMap}; -use crate::{IndexList, Map, Path, Strategy}; +use crate::PrefixBound; +use crate::{Bound, IndexList, Map, Path, Strategy}; /// `IndexedSnapshotMap` works like a `SnapshotMap` but has a secondary index pub struct IndexedSnapshotMap<'a, K, T, I> { diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index e61d2f061..89209718a 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -6,12 +6,13 @@ use serde::Serialize; use cosmwasm_std::{from_slice, Order, Record, StdError, StdResult, Storage}; +use crate::bound::PrefixBound; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; use crate::iter_helpers::deserialize_kv; use crate::map::Map; -use crate::prefix::{namespaced_prefix_range, Bound, PrefixBound}; -use crate::{Index, Prefix, Prefixer, PrimaryKey}; +use crate::prefix::namespaced_prefix_range; +use crate::{Bound, Index, Prefix, Prefixer, PrimaryKey}; use std::marker::PhantomData; /// MultiIndex stores (namespace, index_name, idx_value, pk) -> b"pk_len". diff --git a/packages/storage-plus/src/indexes/unique.rs b/packages/storage-plus/src/indexes/unique.rs index 9200ce552..3143e5cff 100644 --- a/packages/storage-plus/src/indexes/unique.rs +++ b/packages/storage-plus/src/indexes/unique.rs @@ -8,11 +8,12 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{from_slice, Binary, Order, Record, StdError, StdResult, Storage}; +use crate::bound::PrefixBound; use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::map::Map; -use crate::prefix::{namespaced_prefix_range, Bound, PrefixBound}; -use crate::{Index, Prefix, Prefixer, PrimaryKey}; +use crate::prefix::namespaced_prefix_range; +use crate::{Bound, Index, Prefix, Prefixer, PrimaryKey}; /// UniqueRef stores Binary(Vec[u8]) representation of private key and index value #[derive(Deserialize, Serialize)] diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index b0285194a..e4240abb1 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -3,7 +3,6 @@ use cosmwasm_std::Addr; use crate::de::KeyDeserialize; use crate::helpers::namespaces_with_key; use crate::int_key::CwIntKey; -use crate::prefix::Bound; #[derive(Debug)] pub enum Key<'a> { @@ -301,118 +300,6 @@ macro_rules! integer_prefix { integer_prefix!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64); -pub trait Bounder<'a>: PrimaryKey<'a> + Sized { - fn inclusive_bound(self) -> Option>; - fn exclusive_bound(self) -> Option>; -} - -impl<'a> Bounder<'a> for () { - fn inclusive_bound(self) -> Option> { - None - } - fn exclusive_bound(self) -> Option> { - None - } -} - -impl<'a> Bounder<'a> for &'a [u8] { - fn inclusive_bound(self) -> Option> { - Some(Bound::inclusive(self)) - } - fn exclusive_bound(self) -> Option> { - Some(Bound::exclusive(self)) - } -} - -impl< - 'a, - T: PrimaryKey<'a> + KeyDeserialize + Prefixer<'a> + Clone, - U: PrimaryKey<'a> + KeyDeserialize + Clone, - > Bounder<'a> for (T, U) -{ - fn inclusive_bound(self) -> Option> { - Some(Bound::inclusive(self)) - } - fn exclusive_bound(self) -> Option> { - Some(Bound::exclusive(self)) - } -} - -impl< - 'a, - T: PrimaryKey<'a> + Prefixer<'a> + Clone, - U: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize + Clone, - V: PrimaryKey<'a> + KeyDeserialize + Clone, - > Bounder<'a> for (T, U, V) -{ - fn inclusive_bound(self) -> Option> { - Some(Bound::inclusive(self)) - } - fn exclusive_bound(self) -> Option> { - Some(Bound::exclusive(self)) - } -} - -impl<'a> Bounder<'a> for &'a str { - fn inclusive_bound(self) -> Option> { - Some(Bound::inclusive(self)) - } - fn exclusive_bound(self) -> Option> { - Some(Bound::exclusive(self)) - } -} - -impl<'a> Bounder<'a> for String { - fn inclusive_bound(self) -> Option> { - Some(Bound::inclusive(self)) - } - fn exclusive_bound(self) -> Option> { - Some(Bound::exclusive(self)) - } -} - -impl<'a> Bounder<'a> for Vec { - fn inclusive_bound(self) -> Option> { - Some(Bound::inclusive(self)) - } - fn exclusive_bound(self) -> Option> { - Some(Bound::exclusive(self)) - } -} - -impl<'a> Bounder<'a> for &'a Addr { - fn inclusive_bound(self) -> Option> { - Some(Bound::inclusive(self)) - } - fn exclusive_bound(self) -> Option> { - Some(Bound::exclusive(self)) - } -} - -impl<'a> Bounder<'a> for Addr { - fn inclusive_bound(self) -> Option> { - Some(Bound::inclusive(self)) - } - fn exclusive_bound(self) -> Option> { - Some(Bound::exclusive(self)) - } -} - -macro_rules! integer_bound { - (for $($t:ty),+) => { - $(impl<'a> Bounder<'a> for $t { - fn inclusive_bound(self) -> Option> { - Some(Bound::inclusive(self)) - } - fn exclusive_bound(self) -> Option> { - Some(Bound::exclusive(self)) - } - })* - } -} - -integer_bound!(for i8, u8, i16, u16, i32, u32, i64, u64); - #[cfg(test)] mod test { use super::*; diff --git a/packages/storage-plus/src/keys_old.rs b/packages/storage-plus/src/keys_old.rs index 8a25617fe..97752ae03 100644 --- a/packages/storage-plus/src/keys_old.rs +++ b/packages/storage-plus/src/keys_old.rs @@ -1,6 +1,8 @@ use crate::de::KeyDeserialize; use crate::keys::Key; -use crate::{Bound, Bounder, Endian, Prefixer, PrimaryKey}; +#[cfg(feature = "iterator")] +use crate::{Bound, Bounder}; +use crate::{Endian, Prefixer, PrimaryKey}; use std::marker::PhantomData; #[derive(Clone, Debug, PartialEq, Eq)] @@ -62,6 +64,7 @@ impl<'a, T: Endian> Prefixer<'a> for IntKeyOld { } // this auto-implements Bounder for all the IntKey types +#[cfg(feature = "iterator")] impl<'a, T: Endian> Bounder<'a> for IntKeyOld where IntKeyOld: KeyDeserialize, diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index d560020d9..0d6e464c9 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -1,3 +1,4 @@ +mod bound; mod de; mod de_old; mod endian; @@ -15,6 +16,8 @@ mod path; mod prefix; mod snapshot; +#[cfg(feature = "iterator")] +pub use bound::{Bound, Bounder, PrefixBound, RawBound}; pub use endian::Endian; #[cfg(feature = "iterator")] pub use indexed_map::{IndexList, IndexedMap}; @@ -28,11 +31,11 @@ pub use indexes::UniqueIndex; pub use indexes::{index_string, index_string_tuple, index_triple, index_tuple, Index}; pub use int_key::CwIntKey; pub use item::Item; -pub use keys::{Bounder, Key, Prefixer, PrimaryKey}; +pub use keys::{Key, Prefixer, PrimaryKey}; pub use keys_old::IntKeyOld; pub use map::Map; pub use path::Path; #[cfg(feature = "iterator")] -pub use prefix::{range_with_prefix, Bound, Prefix, PrefixBound, RawBound}; +pub use prefix::{range_with_prefix, Prefix}; #[cfg(feature = "iterator")] pub use snapshot::{SnapshotItem, SnapshotMap, Strategy}; diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 029a5c279..2d00cc4de 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -2,6 +2,8 @@ use serde::de::DeserializeOwned; use serde::Serialize; use std::marker::PhantomData; +#[cfg(feature = "iterator")] +use crate::bound::{Bound, Bounder, PrefixBound}; #[cfg(feature = "iterator")] use crate::de::KeyDeserialize; use crate::helpers::query_raw; @@ -9,11 +11,10 @@ use crate::helpers::query_raw; use crate::iter_helpers::{deserialize_kv, deserialize_v}; #[cfg(feature = "iterator")] use crate::keys::Prefixer; -use crate::keys::{Bounder, Key, PrimaryKey}; +use crate::keys::{Key, PrimaryKey}; use crate::path::Path; -use crate::prefix::Bound; #[cfg(feature = "iterator")] -use crate::prefix::{namespaced_prefix_range, Prefix, PrefixBound}; +use crate::prefix::{namespaced_prefix_range, Prefix}; use cosmwasm_std::{from_slice, Addr, QuerierWrapper, StdError, StdResult, Storage}; #[derive(Debug, Clone)] @@ -263,6 +264,7 @@ mod test { use cosmwasm_std::{Order, StdResult}; use crate::int_key::CwIntKey; + #[cfg(feature = "iterator")] use crate::IntKeyOld; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 3dcc42ab9..2ee04233a 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -6,76 +6,12 @@ use std::marker::PhantomData; use cosmwasm_std::{Order, Record, StdResult, Storage}; use std::ops::Deref; +use crate::bound::{PrefixBound, RawBound}; use crate::de::KeyDeserialize; use crate::helpers::{namespaces_with_key, nested_namespaces_with_key}; use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim}; use crate::keys::Key; -use crate::{Prefixer, PrimaryKey}; - -/// `RawBound` is used to define the two ends of a range, more explicit than `Option`. -/// `None` means that we don't limit that side of the range at all. -/// `Inclusive` means we use the given bytes as a limit and *include* anything at that exact key. -/// `Exclusive` means we use the given bytes as a limit and *exclude* anything at that exact key. -/// See `Bound` for a type safe way to build these bounds. -#[derive(Clone, Debug)] -pub enum RawBound { - Inclusive(Vec), - Exclusive(Vec), -} - -/// `Bound` is used to define the two ends of a range. -/// `None` means that we don't limit that side of the range at all. -/// `Inclusive` means we use the given value as a limit and *include* anything at that exact key. -/// `Exclusive` means we use the given value as a limit and *exclude* anything at that exact key. -#[derive(Clone, Debug)] -pub enum Bound<'a, K: PrimaryKey<'a>> { - Inclusive((K, PhantomData<&'a bool>)), - Exclusive((K, PhantomData<&'a bool>)), - InclusiveRaw(Vec), - ExclusiveRaw(Vec), -} - -impl<'a, K: PrimaryKey<'a>> Bound<'a, K> { - pub fn inclusive>(k: T) -> Self { - Self::Inclusive((k.into(), PhantomData)) - } - - pub fn exclusive>(k: T) -> Self { - Self::Exclusive((k.into(), PhantomData)) - } - - pub fn to_raw_bound(&self) -> RawBound { - match self { - Bound::Inclusive((k, _)) => RawBound::Inclusive(k.joined_key()), - Bound::Exclusive((k, _)) => RawBound::Exclusive(k.joined_key()), - Bound::ExclusiveRaw(raw_k) => RawBound::Exclusive(raw_k.clone()), - Bound::InclusiveRaw(raw_k) => RawBound::Inclusive(raw_k.clone()), - } - } -} - -#[derive(Clone, Debug)] -pub enum PrefixBound<'a, K: Prefixer<'a>> { - Inclusive((K, PhantomData<&'a bool>)), - Exclusive((K, PhantomData<&'a bool>)), -} - -impl<'a, K: Prefixer<'a>> PrefixBound<'a, K> { - pub fn inclusive>(k: T) -> Self { - Self::Inclusive((k.into(), PhantomData)) - } - - pub fn exclusive>(k: T) -> Self { - Self::Exclusive((k.into(), PhantomData)) - } - - pub fn to_raw_bound(&self) -> RawBound { - match self { - PrefixBound::Exclusive((k, _)) => RawBound::Exclusive(k.joined_prefix()), - PrefixBound::Inclusive((k, _)) => RawBound::Inclusive(k.joined_prefix()), - } - } -} +use crate::{Bound, Prefixer, PrimaryKey}; type DeserializeVFn = fn(&dyn Storage, &[u8], Record) -> StdResult>; diff --git a/packages/storage-plus/src/snapshot/item.rs b/packages/storage-plus/src/snapshot/item.rs index 51daaa6d2..633f073ff 100644 --- a/packages/storage-plus/src/snapshot/item.rs +++ b/packages/storage-plus/src/snapshot/item.rs @@ -132,7 +132,7 @@ where #[cfg(test)] mod tests { use super::*; - use crate::prefix::Bound; + use crate::bound::Bound; use cosmwasm_std::testing::MockStorage; type TestItem = SnapshotItem<'static, u64>; diff --git a/packages/storage-plus/src/snapshot/map.rs b/packages/storage-plus/src/snapshot/map.rs index fd003faaf..3d7e6b0e4 100644 --- a/packages/storage-plus/src/snapshot/map.rs +++ b/packages/storage-plus/src/snapshot/map.rs @@ -3,14 +3,15 @@ use serde::Serialize; use cosmwasm_std::{StdError, StdResult, Storage}; +use crate::bound::PrefixBound; use crate::de::KeyDeserialize; use crate::iter_helpers::deserialize_kv; use crate::keys::PrimaryKey; use crate::map::Map; use crate::path::Path; -use crate::prefix::{namespaced_prefix_range, Bound, Prefix, PrefixBound}; +use crate::prefix::{namespaced_prefix_range, Prefix}; use crate::snapshot::{ChangeSet, Snapshot}; -use crate::{Prefixer, Strategy}; +use crate::{Bound, Prefixer, Strategy}; /// Map that maintains a snapshots of one or more checkpoints. /// We can query historical data as well as current state. diff --git a/packages/storage-plus/src/snapshot/mod.rs b/packages/storage-plus/src/snapshot/mod.rs index bf2436c9e..d992743b9 100644 --- a/packages/storage-plus/src/snapshot/mod.rs +++ b/packages/storage-plus/src/snapshot/mod.rs @@ -5,8 +5,8 @@ mod map; pub use item::SnapshotItem; pub use map::SnapshotMap; +use crate::bound::Bound; use crate::de::KeyDeserialize; -use crate::prefix::Bound; use crate::{Map, Prefixer, PrimaryKey}; use cosmwasm_std::{Order, StdError, StdResult, Storage}; use serde::de::DeserializeOwned; From 96b937b600e41c2b6f9d47f44c4cd1127e0cb794 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 27 Jan 2022 22:05:27 +0100 Subject: [PATCH 199/352] Migrate cw20-ics20 to type safe Bound --- contracts/cw20-ics20/src/contract.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 8c705bd1f..82133c6a7 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -17,7 +17,7 @@ use crate::msg::{ ListAllowedResponse, ListChannelsResponse, MigrateMsg, PortResponse, QueryMsg, TransferMsg, }; use crate::state::{AllowInfo, Config, ALLOW_LIST, CHANNEL_INFO, CHANNEL_STATE, CONFIG}; -use cw_utils::{nonpayable, one_coin}; +use cw_utils::{maybe_addr, nonpayable, one_coin}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw20-ics20"; @@ -284,10 +284,8 @@ fn list_allowed( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = match start_after { - Some(x) => Some(Bound::exclusive(deps.api.addr_validate(&x)?.into_string())), - None => None, - }; + let addr = maybe_addr(deps.api, start_after)?; + let start = addr.as_ref().map(Bound::exclusive); let allow = ALLOW_LIST .range(deps.storage, start, None, Order::Ascending) From 1d9379a996a0a90192bd1346cf635f7e58a87eff Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jan 2022 15:12:10 +0100 Subject: [PATCH 200/352] Remove redundant test --- packages/storage-plus/src/map.rs | 60 -------------------------------- 1 file changed, 60 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 2d00cc4de..0bb6cd092 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -477,66 +477,6 @@ mod test { fn range_simple_string_key() { let mut store = MockStorage::new(); - // save and load on two keys - let data = Data { - name: "John".to_string(), - age: 32, - }; - PEOPLE.save(&mut store, b"john", &data).unwrap(); - - let data2 = Data { - name: "Jim".to_string(), - age: 44, - }; - PEOPLE.save(&mut store, b"jim", &data2).unwrap(); - - // let's try to iterate! - let all: StdResult> = PEOPLE.range(&store, None, None, Order::Ascending).collect(); - let all = all.unwrap(); - assert_eq!(2, all.len()); - assert_eq!( - all, - vec![ - (b"jim".to_vec(), data2.clone()), - (b"john".to_vec(), data.clone()) - ] - ); - - // let's try to iterate over a range - let all: StdResult> = PEOPLE - .range( - &store, - Some(Bound::inclusive(b"j" as &[u8])), - None, - Order::Ascending, - ) - .collect(); - let all = all.unwrap(); - assert_eq!(2, all.len()); - assert_eq!( - all, - vec![(b"jim".to_vec(), data2), (b"john".to_vec(), data.clone())] - ); - - // let's try to iterate over a more restrictive range - let all: StdResult> = PEOPLE - .range( - &store, - Some(Bound::inclusive(b"jo" as &[u8])), - None, - Order::Ascending, - ) - .collect(); - let all = all.unwrap(); - assert_eq!(1, all.len()); - assert_eq!(all, vec![(b"john".to_vec(), data)]); - } - - #[test] - #[cfg(feature = "iterator")] - fn range2_simple_string_key() { - let mut store = MockStorage::new(); - // save and load on three keys let data = Data { name: "John".to_string(), From e0e60df3c8703c2490b9c5ac1e63b9475674ae98 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jan 2022 15:16:25 +0100 Subject: [PATCH 201/352] Rename tests for clarity --- packages/storage-plus/src/map.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 0bb6cd092..962e94297 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -581,9 +581,10 @@ mod test { assert_eq!(1, all.len()); assert_eq!(all, vec![(1234, data)]); } + #[test] #[cfg(feature = "iterator")] - fn range2_simple_integer_key() { + fn range_simple_integer_key_with_bounder_trait() { let mut store = MockStorage::new(); // save and load on two keys @@ -689,7 +690,7 @@ mod test { #[test] #[cfg(feature = "iterator")] - fn range2_simple_signed_integer_key() { + fn range_simple_signed_integer_key_with_bounder_trait() { let mut store = MockStorage::new(); // save and load on three keys From a3ea930b8a14a08db7c745ef63ad4211367931a5 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jan 2022 15:22:35 +0100 Subject: [PATCH 202/352] Remove redundant / repeated test cases --- packages/storage-plus/src/map.rs | 109 ------------------------------- 1 file changed, 109 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 962e94297..0b50944ab 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -902,50 +902,6 @@ mod test { all, vec![(b"spender".to_vec(), 1000), (b"spender2".to_vec(), 3000),] ); - } - - #[test] - #[cfg(feature = "iterator")] - fn range2_composite_key() { - let mut store = MockStorage::new(); - - // save and load on three keys, one under different owner - ALLOWANCE - .save(&mut store, (b"owner", b"spender"), &1000) - .unwrap(); - ALLOWANCE - .save(&mut store, (b"owner", b"spender2"), &3000) - .unwrap(); - ALLOWANCE - .save(&mut store, (b"owner2", b"spender"), &5000) - .unwrap(); - - // let's try to iterate! - let all: StdResult> = ALLOWANCE - .range(&store, None, None, Order::Ascending) - .collect(); - let all = all.unwrap(); - assert_eq!(3, all.len()); - assert_eq!( - all, - vec![ - ((b"owner".to_vec(), b"spender".to_vec()), 1000), - ((b"owner".to_vec(), b"spender2".to_vec()), 3000), - ((b"owner2".to_vec(), b"spender".to_vec()), 5000) - ] - ); - - // let's try to iterate over a prefix - let all: StdResult> = ALLOWANCE - .prefix(b"owner") - .range(&store, None, None, Order::Ascending) - .collect(); - let all = all.unwrap(); - assert_eq!(2, all.len()); - assert_eq!( - all, - vec![(b"spender".to_vec(), 1000), (b"spender2".to_vec(), 3000),] - ); // let's try to iterate over a prefixed restricted inclusive range let all: StdResult> = ALLOWANCE @@ -1112,71 +1068,6 @@ mod test { ("recipient2".to_string(), 3000), ] ); - } - - #[test] - #[cfg(feature = "iterator")] - fn range2_triple_key() { - let mut store = MockStorage::new(); - - // save and load on three keys, one under different owner - TRIPLE - .save(&mut store, (b"owner", 9u8, "recipient"), &1000) - .unwrap(); - TRIPLE - .save(&mut store, (b"owner", 9u8, "recipient2"), &3000) - .unwrap(); - TRIPLE - .save(&mut store, (b"owner", 10u8, "recipient3"), &3000) - .unwrap(); - TRIPLE - .save(&mut store, (b"owner2", 9u8, "recipient"), &5000) - .unwrap(); - - // let's try to iterate! - let all: StdResult> = TRIPLE.range(&store, None, None, Order::Ascending).collect(); - let all = all.unwrap(); - assert_eq!(4, all.len()); - assert_eq!( - all, - vec![ - ((b"owner".to_vec(), 9, "recipient".to_string()), 1000), - ((b"owner".to_vec(), 9, "recipient2".to_string()), 3000), - ((b"owner".to_vec(), 10, "recipient3".to_string()), 3000), - ((b"owner2".to_vec(), 9, "recipient".to_string()), 5000) - ] - ); - - // let's iterate over a sub_prefix - let all: StdResult> = TRIPLE - .sub_prefix(b"owner") - .range(&store, None, None, Order::Ascending) - .collect(); - let all = all.unwrap(); - assert_eq!(3, all.len()); - assert_eq!( - all, - vec![ - ((9, "recipient".to_string()), 1000), - ((9, "recipient2".to_string()), 3000), - ((10, "recipient3".to_string()), 3000), - ] - ); - - // let's iterate over a prefix - let all: StdResult> = TRIPLE - .prefix((b"owner", 9)) - .range(&store, None, None, Order::Ascending) - .collect(); - let all = all.unwrap(); - assert_eq!(2, all.len()); - assert_eq!( - all, - vec![ - ("recipient".to_string(), 1000), - ("recipient2".to_string(), 3000), - ] - ); // let's try to iterate over a prefixed restricted inclusive range let all: StdResult> = TRIPLE From 2f8b9f97aaf460ceb901e0dc6f3fe14387504c5f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jan 2022 15:38:23 +0100 Subject: [PATCH 203/352] Update rust version in CI to current stable (1.58.1) Required for `edition2021` feature --- .circleci/config.yml | 140 +++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c991d2dd6..b10f55721 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,7 +52,7 @@ workflows: jobs: contract_cw1_subkeys: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/contracts/cw1-subkeys steps: - checkout: @@ -62,7 +62,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw1-subkeys-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw1-subkeys-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -75,11 +75,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw1-subkeys-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw1-subkeys-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} contract_cw1_whitelist: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/contracts/cw1-whitelist steps: - checkout: @@ -89,7 +89,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw1-whitelist-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw1-whitelist-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -102,11 +102,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw1-whitelist-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw1-whitelist-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} contract_cw1_whitelist_ng: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/contracts/cw1-whitelist-ng steps: - checkout: @@ -116,7 +116,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw1-whitelist-ng-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw1-whitelist-ng-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -129,11 +129,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw1-whitelist-ng-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw1-whitelist-ng-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} contract_cw3_fixed_multisig: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/contracts/cw3-fixed-multisig steps: - checkout: @@ -143,7 +143,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw3-fixed-multisig-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw3-fixed-multisig-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -156,11 +156,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw3-fixed-multisig-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw3-fixed-multisig-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} contract_cw3_flex_multisig: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/contracts/cw3-flex-multisig steps: - checkout: @@ -170,7 +170,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw3-flex-multisig-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw3-flex-multisig-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -183,11 +183,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw3-flex-multisig-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw3-flex-multisig-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} contract_cw4_group: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/contracts/cw4-group steps: - checkout: @@ -197,7 +197,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw4-group-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw4-group-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -210,11 +210,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw4-group-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw4-group-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} contract_cw4_stake: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/contracts/cw4-stake steps: - checkout: @@ -224,7 +224,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw4-stake-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw4-stake-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -237,11 +237,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw4-stake-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw4-stake-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} contract_cw20_base: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/contracts/cw20-base steps: - checkout: @@ -251,7 +251,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw20-base-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw20-base-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -264,11 +264,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw20-base-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw20-base-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} contract_cw20_ics20: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/contracts/cw20-ics20 steps: - checkout: @@ -278,7 +278,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw20-ics20-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw20-ics20-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -291,11 +291,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw20-ics20-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw20-ics20-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} contract_cw1155_base: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/contracts/cw1155-base steps: - checkout: @@ -305,7 +305,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-cw1155-base-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-cw1155-base-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Unit Tests environment: @@ -318,11 +318,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-cw1155-base-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-cw1155-base-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} package_controllers: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/packages/controllers steps: - checkout: @@ -332,7 +332,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-controllers:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-controllers:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -343,11 +343,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-controllers:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-controllers:1.58.1-{{ checksum "~/project/Cargo.lock" }} package_utils: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/packages/utils steps: - checkout: @@ -357,7 +357,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-utils:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-utils:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -368,11 +368,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-utils:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-utils:1.58.1-{{ checksum "~/project/Cargo.lock" }} package_cw1: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/packages/cw1 steps: - checkout: @@ -382,7 +382,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw1:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw1:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -396,11 +396,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw1:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw1:1.58.1-{{ checksum "~/project/Cargo.lock" }} package_cw2: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/packages/cw2 steps: - checkout: @@ -410,7 +410,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw2:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw2:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -422,11 +422,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw2:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw2:1.58.1-{{ checksum "~/project/Cargo.lock" }} package_cw3: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/packages/cw3 steps: - checkout: @@ -436,7 +436,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw3:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw3:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -450,11 +450,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw3:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw3:1.58.1-{{ checksum "~/project/Cargo.lock" }} package_cw4: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/packages/cw4 steps: - checkout: @@ -464,7 +464,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw4:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw4:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -478,11 +478,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw4:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw4:1.58.1-{{ checksum "~/project/Cargo.lock" }} package_cw20: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/packages/cw20 steps: - checkout: @@ -492,7 +492,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw20:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw20:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -506,11 +506,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw20:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw20:1.58.1-{{ checksum "~/project/Cargo.lock" }} package_cw1155: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/packages/cw1155 steps: - checkout: @@ -520,7 +520,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-cw1155:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-cw1155:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -534,11 +534,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-cw1155:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-cw1155:1.58.1-{{ checksum "~/project/Cargo.lock" }} lint: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 steps: - checkout - run: @@ -546,7 +546,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-lint-rust:1.54.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-lint-rust:1.58.1-{{ checksum "Cargo.lock" }} - run: name: Add rustfmt component command: rustup component add rustfmt @@ -565,7 +565,7 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-lint-rust:1.54.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-lint-rust:1.58.1-{{ checksum "Cargo.lock" }} # This runs one time on the top level to ensure all contracts compile properly into wasm. # We don't run the wasm build per contract build, and then reuse a lot of the same dependencies, so this speeds up CI time @@ -573,7 +573,7 @@ jobs: # We also sanity-check the resultant wasm files. wasm-build: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 steps: - checkout: path: ~/project @@ -582,7 +582,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-wasm-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-wasm-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Add wasm32 target command: rustup target add wasm32-unknown-unknown @@ -602,7 +602,7 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-wasm-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-wasm-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Check wasm contracts command: | @@ -614,7 +614,7 @@ jobs: package_multi_test: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/packages/multi-test steps: - checkout: @@ -624,7 +624,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-multi-test:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-multi-test:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target command: cargo build --locked @@ -638,11 +638,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-multi-test:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-multi-test:1.58.1-{{ checksum "~/project/Cargo.lock" }} package_storage_plus: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project/packages/storage-plus steps: - checkout: @@ -652,7 +652,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-storage-plus:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-storage-plus:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Build library for native target (no iterator) command: cargo build --locked --no-default-features @@ -669,11 +669,11 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-storage-plus:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-storage-plus:1.58.1-{{ checksum "~/project/Cargo.lock" }} benchmarking: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 environment: RUST_BACKTRACE: 1 steps: @@ -684,7 +684,7 @@ jobs: command: rustc --version && cargo --version - restore_cache: keys: - - cargocache-v2-benchmarking-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + - cargocache-v2-benchmarking-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - run: name: Run storage-plus benchmarks working_directory: ~/project/packages/storage-plus @@ -693,7 +693,7 @@ jobs: paths: - /usr/local/cargo/registry - target - key: cargocache-v2-benchmarking-rust:1.54.0-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-v2-benchmarking-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} # This job roughly follows the instructions from https://circleci.com/blog/publishing-to-github-releases-via-circleci/ build_and_upload_contracts: @@ -743,7 +743,7 @@ jobs: build_and_upload_schemas: docker: - - image: rust:1.54.0 + - image: rust:1.58.1 working_directory: ~/project steps: - checkout: From 5ec0762e1855cf144ba52516717c2c364b05ab70 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jan 2022 17:22:17 +0100 Subject: [PATCH 204/352] Avoid integer overflows by using math ops with wrapping semantics --- packages/storage-plus/benches/main.rs | 32 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/packages/storage-plus/benches/main.rs b/packages/storage-plus/benches/main.rs index cd02624c5..1b5e557b1 100644 --- a/packages/storage-plus/benches/main.rs +++ b/packages/storage-plus/benches/main.rs @@ -27,12 +27,15 @@ fn bench_signed_int_key(c: &mut Criterion) { assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check)); - assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); + assert_eq!( + to_cw_bytes(&k_check.wrapping_neg()), + i32::to_cw_bytes(&k_check.wrapping_neg()) + ); b.iter(|| { let k = k(); black_box(to_cw_bytes(&k)); - black_box(to_cw_bytes(&-k)); + black_box(to_cw_bytes(&k.wrapping_neg())); }); }); @@ -44,12 +47,15 @@ fn bench_signed_int_key(c: &mut Criterion) { assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check)); - assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); + assert_eq!( + to_cw_bytes(&k_check.wrapping_neg()), + i32::to_cw_bytes(&k_check.wrapping_neg()) + ); b.iter(|| { let k = k(); black_box(to_cw_bytes(&k)); - black_box(to_cw_bytes(&-k)); + black_box(to_cw_bytes(&k.wrapping_neg())); }); }); @@ -63,12 +69,15 @@ fn bench_signed_int_key(c: &mut Criterion) { assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check)); - assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); + assert_eq!( + to_cw_bytes(&k_check.wrapping_neg()), + i32::to_cw_bytes(&k_check.wrapping_neg()) + ); b.iter(|| { let k = k(); black_box(to_cw_bytes(&k)); - black_box(to_cw_bytes(&-k)); + black_box(to_cw_bytes(&k.wrapping_neg())); }); }); @@ -76,20 +85,23 @@ fn bench_signed_int_key(c: &mut Criterion) { #[inline] fn to_cw_bytes(value: &i32) -> Buf { if value >= &0i32 { - (*value as u32 - i32::MIN as u32).to_be_bytes() + ((*value as u32).wrapping_sub(i32::MIN as u32)).to_be_bytes() } else { - (*value as u32 + i32::MIN as u32).to_be_bytes() + ((*value as u32).wrapping_add(i32::MIN as u32)).to_be_bytes() } } assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0)); assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check)); - assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check)); + assert_eq!( + to_cw_bytes(&k_check.wrapping_neg()), + i32::to_cw_bytes(&k_check.wrapping_neg()) + ); b.iter(|| { let k = k(); black_box(to_cw_bytes(&k)); - black_box(to_cw_bytes(&-k)); + black_box(to_cw_bytes(&k.wrapping_neg())); }); }); From b4dbcb90cc1d5f0d55d16d3e4a069801dbe02c44 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 31 Jan 2022 13:47:45 +0100 Subject: [PATCH 205/352] Set version: 0.12.0-alpha2 --- Cargo.lock | 40 ++++++++++++------------- contracts/cw1-subkeys/Cargo.toml | 14 ++++----- contracts/cw1-whitelist-ng/Cargo.toml | 14 ++++----- contracts/cw1-whitelist/Cargo.toml | 12 ++++---- contracts/cw1155-base/Cargo.toml | 10 +++---- contracts/cw20-base/Cargo.toml | 10 +++---- contracts/cw20-ics20/Cargo.toml | 10 +++---- contracts/cw3-fixed-multisig/Cargo.toml | 16 +++++----- contracts/cw3-flex-multisig/Cargo.toml | 18 +++++------ contracts/cw4-group/Cargo.toml | 12 ++++---- contracts/cw4-stake/Cargo.toml | 14 ++++----- packages/controllers/Cargo.toml | 6 ++-- packages/cw1/Cargo.toml | 2 +- packages/cw1155/Cargo.toml | 4 +-- packages/cw2/Cargo.toml | 4 +-- packages/cw20/Cargo.toml | 4 +-- packages/cw3/Cargo.toml | 4 +-- packages/cw4/Cargo.toml | 4 +-- packages/multi-test/Cargo.toml | 6 ++-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 4 +-- 21 files changed, 105 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e241537d7..56eb22914 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -377,7 +377,7 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "anyhow", "cosmwasm-std", @@ -394,7 +394,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-std", "criterion", @@ -405,7 +405,7 @@ dependencies = [ [[package]] name = "cw-utils" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -417,7 +417,7 @@ dependencies = [ [[package]] name = "cw1" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -427,7 +427,7 @@ dependencies = [ [[package]] name = "cw1-subkeys" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -444,7 +444,7 @@ dependencies = [ [[package]] name = "cw1-whitelist" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "anyhow", "assert_matches", @@ -463,7 +463,7 @@ dependencies = [ [[package]] name = "cw1-whitelist-ng" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "anyhow", "assert_matches", @@ -482,7 +482,7 @@ dependencies = [ [[package]] name = "cw1155" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -493,7 +493,7 @@ dependencies = [ [[package]] name = "cw1155-base" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -508,7 +508,7 @@ dependencies = [ [[package]] name = "cw2" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -518,7 +518,7 @@ dependencies = [ [[package]] name = "cw20" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -529,7 +529,7 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -544,7 +544,7 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -559,7 +559,7 @@ dependencies = [ [[package]] name = "cw3" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -570,7 +570,7 @@ dependencies = [ [[package]] name = "cw3-fixed-multisig" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -588,7 +588,7 @@ dependencies = [ [[package]] name = "cw3-flex-multisig" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -607,7 +607,7 @@ dependencies = [ [[package]] name = "cw4" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -618,7 +618,7 @@ dependencies = [ [[package]] name = "cw4-group" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -634,7 +634,7 @@ dependencies = [ [[package]] name = "cw4-stake" -version = "0.11.1" +version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 7869846bc..6494b5ffa 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-subkeys" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Implement subkeys for authorizing native tokens as a cw1 proxy contract" @@ -19,12 +19,12 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw1 = { path = "../../packages/cw1", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.11.1", features = ["library"] } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw1 = { path = "../../packages/cw1", version = "0.12.0-alpha2" } +cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.0-alpha2", features = ["library"] } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.23" @@ -32,4 +32,4 @@ semver = "1" [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.11.1", features = ["library", "test-utils"] } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.0-alpha2", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index bf65ba592..b25c75182 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist-ng" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Bartłomiej Kuras "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -22,20 +22,20 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw1 = { path = "../../packages/cw1", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw1 = { path = "../../packages/cw1", version = "0.12.0-alpha2" } +cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1", optional = true } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0-alpha2", optional = true } anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0-alpha2" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index bc60dbb54..d2608ff9e 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw1 = { path = "../../packages/cw1", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw1 = { path = "../../packages/cw1", version = "0.12.0-alpha2" } +cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -32,5 +32,5 @@ thiserror = { version = "1.0.23" } anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0-alpha2" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 9890e29c6..e97d4b92c 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155-base" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Huang Yi "] edition = "2018" description = "Basic implementation of a CosmWasm-1155 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw1155 = { path = "../../packages/cw1155", version = "0.11.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } +cw1155 = { path = "../../packages/cw1155", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index 070e6c918..acf849c4a 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-base" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation of a CosmWasm-20 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw20 = { path = "../../packages/cw20", version = "0.11.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } +cw20 = { path = "../../packages/cw20", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 61875dcdd..fe31dd250 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain" @@ -18,11 +18,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw20 = { path = "../../packages/cw20", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } +cw20 = { path = "../../packages/cw20", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3", features = ["stargate"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index bc2649280..b3478efdc 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-fixed-multisig" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with an fixed group multisig" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw3 = { path = "../../packages/cw3", version = "0.11.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } +cw3 = { path = "../../packages/cw3", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -29,6 +29,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw20 = { path = "../../packages/cw20", version = "0.11.1" } -cw20-base = { path = "../cw20-base", version = "0.11.1", features = ["library"] } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1" } +cw20 = { path = "../../packages/cw20", version = "0.12.0-alpha2" } +cw20-base = { path = "../cw20-base", version = "0.12.0-alpha2", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0-alpha2" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 1fc778bd9..0d5c2fa8f 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-flex-multisig" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with multiple voting patterns and dynamic groups" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw3 = { path = "../../packages/cw3", version = "0.11.1" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.11.1", features = ["library"] } -cw4 = { path = "../../packages/cw4", version = "0.11.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } +cw3 = { path = "../../packages/cw3", version = "0.12.0-alpha2" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.12.0-alpha2", features = ["library"] } +cw4 = { path = "../../packages/cw4", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw4-group = { path = "../cw4-group", version = "0.11.1" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.11.1" } +cw4-group = { path = "../cw4-group", version = "0.12.0-alpha2" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0-alpha2" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index 8f6859053..378fbc7d9 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-group" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Simple cw4 implementation of group membership controlled by admin " @@ -26,11 +26,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw4 = { path = "../../packages/cw4", version = "0.11.1" } -cw-controllers = { path = "../../packages/controllers", version = "0.11.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } +cw4 = { path = "../../packages/cw4", version = "0.12.0-alpha2" } +cw-controllers = { path = "../../packages/controllers", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index c36847346..a6c662025 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-stake" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "CW4 implementation of group based on staked tokens" @@ -26,12 +26,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw2 = { path = "../../packages/cw2", version = "0.11.1" } -cw4 = { path = "../../packages/cw4", version = "0.11.1" } -cw20 = { path = "../../packages/cw20", version = "0.11.1" } -cw-controllers = { path = "../../packages/controllers", version = "0.11.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } +cw4 = { path = "../../packages/cw4", version = "0.12.0-alpha2" } +cw20 = { path = "../../packages/cw20", version = "0.12.0-alpha2" } +cw-controllers = { path = "../../packages/controllers", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index b2fe7dabd..1c45b919e 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-controllers" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Common controllers we can reuse in many contracts" @@ -13,8 +13,8 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta3" } -cw-utils = { path = "../utils", version = "0.11.1" } -cw-storage-plus = { path = "../storage-plus", version = "0.11.1" } +cw-utils = { path = "../utils", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../storage-plus", version = "0.12.0-alpha2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index 85f4a0a55..ad9b3130c 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-1 interface" diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 4f9ded91b..1eae1e014 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Huang Yi "] edition = "2018" description = "Definition and types for the CosmWasm-1155 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 649eb14c9..6acf2984a 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw2" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-2 interface" @@ -11,6 +11,6 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta3", default-features = false } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index 6675eeca5..a72bf47ec 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-20 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index 3f6426ff2..9594a1376 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-3 Interface: On-Chain MultiSig/Voting contracts" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index b87cfbdd6..a7baca6cd 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-4 Interface: Groups Members" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-storage-plus = { path = "../storage-plus", version = "0.11.1" } +cw-storage-plus = { path = "../storage-plus", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index f19d84b0d..fdc5b00d7 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-multi-test" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Test helpers for multi-contract interactions" @@ -18,8 +18,8 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.11.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1"} +cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2"} cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } cosmwasm-storage = { version = "1.0.0-beta3" } itertools = "0.10.1" diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index d2370031d..3f5b57a9d 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-storage-plus" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Enhanced/experimental storage engines" diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index ffc88f5a3..61013d1f0 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-utils" -version = "0.11.1" +version = "0.12.0-alpha2" authors = ["Ethan Frey "] edition = "2018" description = "Common helpers for other cw specs" @@ -18,5 +18,5 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } [dev-dependencies] -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.11.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } prost = "0.9" From f23e5c90a3d2dcbe5512079f4eeac29fba38e968 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Mon, 31 Jan 2022 20:01:40 +0100 Subject: [PATCH 206/352] flex-multisig: add a double execution test --- contracts/cw3-flex-multisig/src/contract.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 6b31f1071..d901917a9 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -1140,9 +1140,23 @@ mod tests { // In passing: Try to close Executed fails let err = app - .execute_contract(Addr::unchecked(OWNER), flex_addr, &closing, &[]) + .execute_contract(Addr::unchecked(OWNER), flex_addr.clone(), &closing, &[]) .unwrap_err(); assert_eq!(ContractError::WrongCloseStatus {}, err.downcast().unwrap()); + + // Trying to execute something that was already executed fails + let err = app + .execute_contract( + Addr::unchecked(SOMEBODY), + flex_addr.clone(), + &execution, + &[], + ) + .unwrap_err(); + assert_eq!( + ContractError::WrongExecuteStatus {}, + err.downcast().unwrap() + ); } #[test] From 3d851e843edf1516fbbbf58b6543261a87685fa8 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Mon, 31 Jan 2022 20:28:54 +0100 Subject: [PATCH 207/352] flex-multisig: test executing passed proposal --- contracts/cw3-flex-multisig/src/contract.rs | 81 +++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index d901917a9..1e2840032 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -1159,6 +1159,87 @@ mod tests { ); } + #[test] + fn proposal_pass_on_expiration() { + let init_funds = coins(10, "BTC"); + let mut app = mock_app(&init_funds); + + let threshold = Threshold::ThresholdQuorum { + threshold: Decimal::percent(51), + quorum: Decimal::percent(1), + }; + let voting_period = 2000000; + let (flex_addr, _) = setup_test_case( + &mut app, + threshold, + Duration::Time(voting_period), + init_funds, + true, + ); + + // ensure we have cash to cover the proposal + let contract_bal = app.wrap().query_balance(&flex_addr, "BTC").unwrap(); + assert_eq!(contract_bal, coin(10, "BTC")); + + // create proposal with 0 vote power + let proposal = pay_somebody_proposal(); + let res = app + .execute_contract(Addr::unchecked(OWNER), flex_addr.clone(), &proposal, &[]) + .unwrap(); + + // Get the proposal id from the logs + let proposal_id: u64 = res.custom_attrs(1)[2].value.parse().unwrap(); + + // Vote it, so it passes after voting period is over + let vote = ExecuteMsg::Vote { + proposal_id, + vote: Vote::Yes, + }; + let res = app + .execute_contract(Addr::unchecked(VOTER3), flex_addr.clone(), &vote, &[]) + .unwrap(); + assert_eq!( + res.custom_attrs(1), + [ + ("action", "vote"), + ("sender", VOTER3), + ("proposal_id", proposal_id.to_string().as_str()), + ("status", "Open"), + ], + ); + + // Wait until the voting period is over. + app.update_block(|block| { + block.time = block.time.plus_seconds(voting_period); + block.height += std::cmp::max(1, voting_period / 5); + }); + + // Proposal should now be passed. + let prop: ProposalResponse = app + .wrap() + .query_wasm_smart(&flex_addr, &QueryMsg::Proposal { proposal_id }) + .unwrap(); + assert_eq!(prop.status, Status::Passed); + + // Execution should now be possible. + let res = app + .execute_contract( + Addr::unchecked(SOMEBODY), + flex_addr.clone(), + &ExecuteMsg::Execute { proposal_id }, + &[], + ) + .unwrap(); + assert_eq!( + res.custom_attrs(1), + [ + ("action", "execute"), + ("sender", SOMEBODY), + ("proposal_id", proposal_id.to_string().as_str()), + ], + ); + } + #[test] fn test_close_works() { let init_funds = coins(10, "BTC"); From d3cc69a2221fe9569ba9eca02173c9a51ae4738a Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Mon, 31 Jan 2022 20:37:52 +0100 Subject: [PATCH 208/352] lints --- contracts/cw3-flex-multisig/src/contract.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 1e2840032..e42855627 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -1146,12 +1146,7 @@ mod tests { // Trying to execute something that was already executed fails let err = app - .execute_contract( - Addr::unchecked(SOMEBODY), - flex_addr.clone(), - &execution, - &[], - ) + .execute_contract(Addr::unchecked(SOMEBODY), flex_addr, &execution, &[]) .unwrap_err(); assert_eq!( ContractError::WrongExecuteStatus {}, @@ -1225,7 +1220,7 @@ mod tests { let res = app .execute_contract( Addr::unchecked(SOMEBODY), - flex_addr.clone(), + flex_addr, &ExecuteMsg::Execute { proposal_id }, &[], ) From d139119cff4286b720ba892839fa578bc42b5dcf Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Mon, 31 Jan 2022 20:44:38 +0100 Subject: [PATCH 209/352] flex-multisig: fix passed proposal execution --- contracts/cw3-flex-multisig/src/contract.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index e42855627..e5444c179 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -188,7 +188,7 @@ pub fn execute_vote( pub fn execute_execute( deps: DepsMut, - _env: Env, + env: Env, info: MessageInfo, proposal_id: u64, ) -> Result { @@ -197,7 +197,7 @@ pub fn execute_execute( let mut prop = PROPOSALS.load(deps.storage, proposal_id)?; // we allow execution even after the proposal "expiration" as long as all vote come in before // that point. If it was approved on time, it can be executed any time. - if prop.status != Status::Passed { + if prop.current_status(&env.block) != Status::Passed { return Err(ContractError::WrongExecuteStatus {}); } From 703c007103da65e1d7051a1f76e04bf0abfdec26 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 31 Jan 2022 12:48:56 +0100 Subject: [PATCH 210/352] Replace as_bytes() by into_bytes() --- contracts/cw20-base/src/enumerable.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw20-base/src/enumerable.rs b/contracts/cw20-base/src/enumerable.rs index aa5998d86..7f7991c93 100644 --- a/contracts/cw20-base/src/enumerable.rs +++ b/contracts/cw20-base/src/enumerable.rs @@ -16,7 +16,7 @@ pub fn query_all_allowances( ) -> StdResult { let owner_addr = deps.api.addr_validate(&owner)?; let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(|s| Bound::ExclusiveRaw(s.as_bytes().into())); + let start = start_after.map(|s| Bound::ExclusiveRaw(s.into_bytes())); let allowances = ALLOWANCES .prefix(&owner_addr) From bc6e804189f1c41d2e64a5e404206b250558e47d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 31 Jan 2022 12:58:28 +0100 Subject: [PATCH 211/352] Update CHANGELOG --- CHANGELOG.md | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a835fe6b1..02ba4d208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,48 @@ # Changelog -# Changelog - ## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.11.1...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0-alpha1...HEAD) + +**Closed issues:** + +- Incorrect Cw4ExecuteMsg used during remove\_hook [\#637](https://github.com/CosmWasm/cw-plus/issues/637) +- Make `Bound`s type safe [\#462](https://github.com/CosmWasm/cw-plus/issues/462) + +**Merged pull requests:** + +- Fix benchmarks \(after 1.58.1 update\) [\#639](https://github.com/CosmWasm/cw-plus/pull/639) ([maurolacy](https://github.com/maurolacy)) +- Fix `remove_hook` helper [\#638](https://github.com/CosmWasm/cw-plus/pull/638) ([maurolacy](https://github.com/maurolacy)) +- Type safe bounds [\#627](https://github.com/CosmWasm/cw-plus/pull/627) ([maurolacy](https://github.com/maurolacy)) + +## [v0.12.0-alpha1](https://github.com/CosmWasm/cw-plus/tree/v0.12.0-alpha1) (2022-01-27) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.11.1...v0.12.0-alpha1) + +**Deprecated:** + +- Remove `IntKey` with surrounding implementation [\#570](https://github.com/CosmWasm/cw-plus/issues/570) + +**Closed issues:** + +- Move all cw20 examples to new repo [\#578](https://github.com/CosmWasm/cw-plus/issues/578) +- Add more debug output from multi-test [\#575](https://github.com/CosmWasm/cw-plus/issues/575) + +**Merged pull requests:** + +- Update Rust to v1.54.0 in CI [\#636](https://github.com/CosmWasm/cw-plus/pull/636) ([maurolacy](https://github.com/maurolacy)) +- Refactor cw2 spec readme [\#635](https://github.com/CosmWasm/cw-plus/pull/635) ([orkunkl](https://github.com/orkunkl)) +- Fix tag consolidation for matching CHANGELOG entries [\#634](https://github.com/CosmWasm/cw-plus/pull/634) ([maurolacy](https://github.com/maurolacy)) +- Ics20 contract rollback [\#633](https://github.com/CosmWasm/cw-plus/pull/633) ([ethanfrey](https://github.com/ethanfrey)) +- Fix typo in README.md [\#632](https://github.com/CosmWasm/cw-plus/pull/632) ([josefrichter](https://github.com/josefrichter)) +- Update ics20 contract [\#631](https://github.com/CosmWasm/cw-plus/pull/631) ([ethanfrey](https://github.com/ethanfrey)) +- Publish snapshot map changelog [\#622](https://github.com/CosmWasm/cw-plus/pull/622) ([maurolacy](https://github.com/maurolacy)) +- Remove `IntKey` and `TimestampKey` [\#620](https://github.com/CosmWasm/cw-plus/pull/620) ([ueco-jb](https://github.com/ueco-jb)) +- Signed int key benchmarks [\#619](https://github.com/CosmWasm/cw-plus/pull/619) ([maurolacy](https://github.com/maurolacy)) +- fix readme update coralnet to sandynet-1 [\#617](https://github.com/CosmWasm/cw-plus/pull/617) ([yubrew](https://github.com/yubrew)) +- Publish `PrefixBound` [\#616](https://github.com/CosmWasm/cw-plus/pull/616) ([maurolacy](https://github.com/maurolacy)) +- Move contracts to cw-tokens [\#613](https://github.com/CosmWasm/cw-plus/pull/613) ([ethanfrey](https://github.com/ethanfrey)) +- Add context to multitest execution errors [\#597](https://github.com/CosmWasm/cw-plus/pull/597) ([uint](https://github.com/uint)) ## [v0.11.1](https://github.com/CosmWasm/cw-plus/tree/v0.11.1) (2021-12-28) From 19c0bfa5cd2ba327f3396ffcf4d128938fb677ea Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 31 Jan 2022 13:14:03 +0100 Subject: [PATCH 212/352] Add MIGRATING entry for upcoming 0.12.0 Type safe bounds migration. --- MIGRATING.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/MIGRATING.md b/MIGRATING.md index ea5b67c8d..11c6e9639 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -2,6 +2,50 @@ This guide lists API changes between *cw-plus* major releases. +## v0.11.0 -> v0.12.0 + +### Breaking Issues / PRs + +- Type safe `Bound`s [\#462](https://github.com/CosmWasm/cw-plus/issues/462) + +Bounds are now type-safe. That means the bound type must match the key / sub-key you are ranging over. + +Migration code example: + +```diff +fn list_allowed( + limit: Option, + ) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; +- let start = match start_after { +- Some(x) => Some(Bound::exclusive(deps.api.addr_validate(&x)?.into_string())), +- None => None, +- }; ++ let addr = maybe_addr(deps.api, start_after)?; ++ let start = addr.as_ref().map(Bound::exclusive); + + let allow = ALLOW_LIST + .range(deps.storage, start, None, Order::Ascending) +``` +Here the `ALLOW_LIST` key is of type `&Addr`. That's why we use `as_ref()` before the `map()` that builds the bound. +Notice also that this "forces" you to use `addr_validate()`, in order to build a bound over the proper type. + +You can still use untyped bounds, with the `ExclusiveRaw` and `InclusiveRaw` enum types. +Migration code example, in case you want to keep your raw bounds: + +```diff +pub fn query_all_allowances( + ) -> StdResult { + let limit = calc_limit(limit); + // we use raw addresses here.... +- let start = start_after.map(Bound::exclusive); ++ let start = start_after.map(|s| Bound::ExclusiveRaw(s.into())); + + let allowances = ALLOWANCES + .range(deps.storage, start, None, Order::Ascending) +``` +Notice that here we build a bound for an address, and using a raw bound allows us to skip address validation / build up. + ## v0.10.3 -> v0.11.0 ### Breaking Issues / PRs From fae49eb8bae461fa4ad832f0ba2c15356c062d8d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 31 Jan 2022 21:16:42 +0100 Subject: [PATCH 213/352] Fix migration code context --- MIGRATING.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index 11c6e9639..7dd66e185 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -14,8 +14,10 @@ Migration code example: ```diff fn list_allowed( - limit: Option, - ) -> StdResult { + deps: Deps, + start_after: Option, + limit: Option, +) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = match start_after { - Some(x) => Some(Bound::exclusive(deps.api.addr_validate(&x)?.into_string())), @@ -35,7 +37,11 @@ Migration code example, in case you want to keep your raw bounds: ```diff pub fn query_all_allowances( - ) -> StdResult { + deps: Deps, + env: Env, + start_after: Option, + limit: Option, +) -> StdResult { let limit = calc_limit(limit); // we use raw addresses here.... - let start = start_after.map(Bound::exclusive); From 214fdc47b1cd89ca1b639d3b458dae86712a14c5 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 31 Jan 2022 22:02:55 +0100 Subject: [PATCH 214/352] Update storage-plus README.md --- packages/storage-plus/README.md | 43 +++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/packages/storage-plus/README.md b/packages/storage-plus/README.md index 214228bd5..edb17d8ed 100644 --- a/packages/storage-plus/README.md +++ b/packages/storage-plus/README.md @@ -314,7 +314,7 @@ fn demo() -> StdResult<()> { In addition to getting one particular item out of a map, we can iterate over the map (or a subset of the map). This let us answer questions like "show me all tokens", -and we provide some nice `Bound`s helpers to easily allow pagination or custom ranges. +and we provide some nice [`Bound`](#Bound) helpers to easily allow pagination or custom ranges. The general format is to get a `Prefix` by calling `map.prefix(k)`, where `k` is exactly one less item than the normal key (If `map.key()` took `(&[u8], &[u8])`, then `map.prefix()` takes `&[u8]`. @@ -322,21 +322,28 @@ If `map.key()` took `&[u8]`, `map.prefix()` takes `()`). Once we have a prefix s over all items with `range(store, min, max, order)`. It supports `Order::Ascending` or `Order::Descending`. `min` is the lower bound and `max` is the higher bound. +If the `min` and `max` bounds are `None`, `range` will return all items under the prefix. You can use `.take(n)` to +limit the results to `n` items and start doing pagination. You can also set the `min` bound to +eg. `Bound::exclusive(last_value)` to start iterating over all items *after* the last value. Combined with +`take`, we easily have pagination support. You can also use `Bound::inclusive(x)` when you want to include any +perfect matches. + +### Bound + +`Bound` is a helper to build type-safe bounds on the keys or sub-keys you want to iterate over. +It also supports a raw (`Vec`) bounds specification, for the cases you don't want or can't use typed bounds. + ```rust -#[derive(Copy, Clone, Debug)] -pub enum Bound { - Inclusive(Vec), - Exclusive(Vec), - None, +#[derive(Clone, Debug)] +pub enum Bound<'a, K: PrimaryKey<'a>> { + Inclusive((K, PhantomData<&'a bool>)), + Exclusive((K, PhantomData<&'a bool>)), + InclusiveRaw(Vec), + ExclusiveRaw(Vec), } ``` -If the `min` and `max` bounds, it will return all items under this prefix. You can use `.take(n)` to -limit the results to `n` items and start doing pagination. You can also set the `min` bound to -eg. `Bound::Exclusive(last_value)` to start iterating over all items *after* the last value. Combined with -`take`, we easily have pagination support. You can also use `Bound::Inclusive(x)` when you want to include any -perfect matches. To better understand the API, please read the following example: - +To better understand the API, please read the following example: ```rust #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] struct Data { @@ -358,7 +365,7 @@ fn demo() -> StdResult<()> { // iterate over them all let all: StdResult> = PEOPLE - .range(&store, Bound::None, Bound::None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); assert_eq!( all?, @@ -369,8 +376,8 @@ fn demo() -> StdResult<()> { let all: StdResult> = PEOPLE .range( &store, - Bound::Exclusive("jim"), - Bound::None, + Some(Bound::exclusive("jim")), + None, Order::Ascending, ) .collect(); @@ -384,7 +391,7 @@ fn demo() -> StdResult<()> { // get all under one key let all: StdResult> = ALLOWANCE .prefix("owner") - .range(&store, Bound::None, Bound::None, Order::Ascending) + .range(&store, None, None, Order::Ascending) .collect(); assert_eq!( all?, @@ -396,8 +403,8 @@ fn demo() -> StdResult<()> { .prefix("owner") .range( &store, - Bound::Exclusive("spender1"), - Bound::Inclusive("spender2"), + Some(Bound::exclusive("spender1")), + Some(Bound::inclusive("spender2")), Order::Descending, ) .collect(); From 291cc41495e875e97651030374a3bbfa8c51e5d0 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 31 Jan 2022 22:05:40 +0100 Subject: [PATCH 215/352] Add link to storage-plus README --- MIGRATING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MIGRATING.md b/MIGRATING.md index 7dd66e185..8fe761275 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -52,6 +52,8 @@ pub fn query_all_allowances( ``` Notice that here we build a bound for an address, and using a raw bound allows us to skip address validation / build up. +See storage-plus [README.md](./packages/storage-plus/README.md#Bound) for more information on `Bound`. + ## v0.10.3 -> v0.11.0 ### Breaking Issues / PRs From 652411cd8dfa14a90b720bfc07fb8f8ee597562f Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 2 Feb 2022 20:41:02 +0100 Subject: [PATCH 216/352] Use ContractInfoResponse from cosmwasm_std --- packages/multi-test/src/wasm.rs | 38 ++++++--------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index 49646d876..9a30d47e7 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -4,9 +4,9 @@ use std::ops::Deref; use cosmwasm_std::{ to_binary, Addr, Api, Attribute, BankMsg, Binary, BlockInfo, Coin, ContractInfo, - ContractResult, CustomQuery, Deps, DepsMut, Env, Event, MessageInfo, Order, Querier, - QuerierWrapper, Reply, ReplyOn, Response, StdResult, Storage, SubMsg, SubMsgExecutionResponse, - TransactionInfo, WasmMsg, WasmQuery, + ContractInfoResponse, ContractResult, CustomQuery, Deps, DepsMut, Env, Event, MessageInfo, + Order, Querier, QuerierWrapper, Reply, ReplyOn, Response, StdResult, Storage, SubMsg, + SubMsgExecutionResponse, TransactionInfo, WasmMsg, WasmQuery, }; use cosmwasm_storage::{prefixed, prefixed_read, PrefixedStorage, ReadonlyPrefixedStorage}; use prost::Message; @@ -25,20 +25,6 @@ use cosmwasm_std::testing::mock_wasmd_attr; use anyhow::{bail, Context, Result as AnyResult}; -// TODO: we should import this from cosmwasm-std, but cannot due to non_exhaustive so copy here -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct ContractInfoResponse { - pub code_id: u64, - /// address that instantiated this contract - pub creator: String, - /// admin who can run migrations (if any) - pub admin: Option, - /// if set, the contract is pinned to the cache, and thus uses less gas when called - pub pinned: bool, - /// set if this contract has bound an IBC port - pub ibc_port: Option, -} - // Contract state is kept in Storage, separate from the contracts themselves const CONTRACTS: Map<&Addr, ContractData> = Map::new("contracts"); @@ -152,13 +138,8 @@ where WasmQuery::ContractInfo { contract_addr } => { let addr = api.addr_validate(&contract_addr)?; let contract = self.load_contract(storage, &addr)?; - let res = ContractInfoResponse { - code_id: contract.code_id as u64, - creator: contract.creator.to_string(), - admin: contract.admin.map(|x| x.to_string()), - pinned: false, - ibc_port: None, - }; + let mut res = ContractInfoResponse::new(contract.code_id as u64, contract.creator); + res.admin = contract.admin.map(|x| x.into()); to_binary(&res).map_err(Into::into) } query => bail!(Error::UnsupportedWasmQuery(query)), @@ -1063,13 +1044,8 @@ mod test { .query(&api, &wasm_storage, &querier, &block, query) .unwrap(); - let expected = ContractInfoResponse { - code_id: code_id as u64, - creator: "foobar".to_owned(), - admin: Some("admin".to_owned()), - pinned: false, - ibc_port: None, - }; + let mut expected = ContractInfoResponse::new(code_id as u64, "foobar"); + expected.admin = Some("admin".to_owned()); assert_eq!(expected, from_slice(&info).unwrap()); } From f285c674e55c552138556fe3254d5d5162bc0934 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 31 Jan 2022 11:28:51 +0100 Subject: [PATCH 217/352] Use ADMIN to control ics20 access, allow updates --- Cargo.lock | 1 + contracts/cw20-ics20/Cargo.toml | 1 + contracts/cw20-ics20/src/contract.rs | 23 +++++++++++++++-------- contracts/cw20-ics20/src/error.rs | 4 ++++ contracts/cw20-ics20/src/msg.rs | 6 +++++- contracts/cw20-ics20/src/state.rs | 7 +++++-- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 56eb22914..1c7e38bc2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,6 +548,7 @@ version = "0.12.0-alpha2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", + "cw-controllers", "cw-storage-plus", "cw-utils", "cw2", diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index fe31dd250..ca7a1bc00 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -23,6 +23,7 @@ cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } cw20 = { path = "../../packages/cw20", version = "0.12.0-alpha2" } cosmwasm-std = { version = "1.0.0-beta3", features = ["stargate"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-controllers = { path = "../../packages/controllers", version = "0.12.0-alpha2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 82133c6a7..3182a3e62 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -1,8 +1,8 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - ensure_eq, from_binary, to_binary, Addr, Binary, Deps, DepsMut, Env, IbcMsg, IbcQuery, - MessageInfo, Order, PortIdResponse, Response, StdResult, + from_binary, to_binary, Addr, Binary, Deps, DepsMut, Env, IbcMsg, IbcQuery, MessageInfo, Order, + PortIdResponse, Response, StdResult, }; use cw2::{get_contract_version, set_contract_version}; @@ -16,7 +16,7 @@ use crate::msg::{ AllowMsg, AllowedInfo, AllowedResponse, ChannelResponse, ConfigResponse, ExecuteMsg, InitMsg, ListAllowedResponse, ListChannelsResponse, MigrateMsg, PortResponse, QueryMsg, TransferMsg, }; -use crate::state::{AllowInfo, Config, ALLOW_LIST, CHANNEL_INFO, CHANNEL_STATE, CONFIG}; +use crate::state::{AllowInfo, Config, ADMIN, ALLOW_LIST, CHANNEL_INFO, CHANNEL_STATE, CONFIG}; use cw_utils::{maybe_addr, nonpayable, one_coin}; // version info for migration info @@ -25,7 +25,7 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( - deps: DepsMut, + mut deps: DepsMut, _env: Env, _info: MessageInfo, msg: InitMsg, @@ -33,10 +33,12 @@ pub fn instantiate( set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; let cfg = Config { default_timeout: msg.default_timeout, - gov_contract: deps.api.addr_validate(&msg.gov_contract)?, }; CONFIG.save(deps.storage, &cfg)?; + let admin = deps.api.addr_validate(&msg.gov_contract)?; + ADMIN.set(deps.branch(), Some(admin))?; + // add all allows for allowed in msg.allowlist { let contract = deps.api.addr_validate(&allowed.contract)?; @@ -62,6 +64,10 @@ pub fn execute( execute_transfer(deps, env, msg, Amount::Native(coin), info.sender) } ExecuteMsg::Allow(allow) => execute_allow(deps, env, info, allow), + ExecuteMsg::UpdateAdmin { admin } => { + let admin = deps.api.addr_validate(&admin)?; + Ok(ADMIN.execute_update_admin(deps, info, Some(admin))?) + } } } @@ -151,8 +157,7 @@ pub fn execute_allow( info: MessageInfo, allow: AllowMsg, ) -> Result { - let cfg = CONFIG.load(deps.storage)?; - ensure_eq!(info.sender, cfg.gov_contract, ContractError::Unauthorized); + ADMIN.assert_admin(deps.as_ref(), &info.sender)?; let contract = deps.api.addr_validate(&allow.contract)?; let set = AllowInfo { @@ -207,6 +212,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { QueryMsg::ListAllowed { start_after, limit } => { to_binary(&list_allowed(deps, start_after, limit)?) } + QueryMsg::Admin {} => to_binary(&ADMIN.query_admin(deps)?), } } @@ -251,9 +257,10 @@ pub fn query_channel(deps: Deps, id: String) -> StdResult { fn query_config(deps: Deps) -> StdResult { let cfg = CONFIG.load(deps.storage)?; + let admin = ADMIN.get(deps)?.unwrap_or_else(|| Addr::unchecked("")); let res = ConfigResponse { default_timeout: cfg.default_timeout, - gov_contract: cfg.gov_contract.into(), + gov_contract: admin.into(), }; Ok(res) } diff --git a/contracts/cw20-ics20/src/error.rs b/contracts/cw20-ics20/src/error.rs index cdd3b0574..c9a6966a6 100644 --- a/contracts/cw20-ics20/src/error.rs +++ b/contracts/cw20-ics20/src/error.rs @@ -3,6 +3,7 @@ use std::string::FromUtf8Error; use thiserror::Error; use cosmwasm_std::StdError; +use cw_controllers::AdminError; use cw_utils::PaymentError; /// Never is a placeholder to ensure we don't return any errors @@ -17,6 +18,9 @@ pub enum ContractError { #[error("{0}")] Payment(#[from] PaymentError), + #[error("{0}")] + Admin(#[from] AdminError), + #[error("Channel doesn't exist: {id}")] NoSuchChannel { id: String }, diff --git a/contracts/cw20-ics20/src/msg.rs b/contracts/cw20-ics20/src/msg.rs index 044cbf2f6..c5330dd97 100644 --- a/contracts/cw20-ics20/src/msg.rs +++ b/contracts/cw20-ics20/src/msg.rs @@ -34,6 +34,8 @@ pub enum ExecuteMsg { Transfer(TransferMsg), /// This must be called by gov_contract, will allow a new cw20 token to be sent Allow(AllowMsg), + /// Change the admin (must be called by current admin) + UpdateAdmin { admin: String }, } /// This is the message we accept via Receive @@ -59,8 +61,10 @@ pub enum QueryMsg { /// Returns the details of the name channel, error if not created. /// Return type: ChannelResponse. Channel { id: String }, - /// Show the Config. Returns ConfigResponse + /// Show the Config. Returns ConfigResponse (currently including admin as well) Config {}, + /// Return AdminResponse + Admin {}, /// Query if a given cw20 contract is allowed. Returns AllowedResponse Allowed { contract: String }, /// List all allowed cw20 contracts. Returns ListAllowedResponse diff --git a/contracts/cw20-ics20/src/state.rs b/contracts/cw20-ics20/src/state.rs index 79c127d8c..20277035a 100644 --- a/contracts/cw20-ics20/src/state.rs +++ b/contracts/cw20-ics20/src/state.rs @@ -1,10 +1,14 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::ContractError; use cosmwasm_std::{Addr, IbcEndpoint, StdResult, Storage, Uint128}; +use cw_controllers::Admin; use cw_storage_plus::{Item, Map}; +use crate::ContractError; + +pub const ADMIN: Admin = Admin::new("admin"); + pub const CONFIG: Item = Item::new("ics20_config"); // Used to pass info from the ibc_packet_receive to the reply handler @@ -28,7 +32,6 @@ pub struct ChannelState { #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { pub default_timeout: u64, - pub gov_contract: Addr, } #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] From 783f0d5fecf6ef0c810812b0be28a46f5b248c77 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 31 Jan 2022 13:36:58 +0100 Subject: [PATCH 218/352] Prepare better migrate function --- Cargo.lock | 1 + contracts/cw20-ics20/Cargo.toml | 1 + contracts/cw20-ics20/src/contract.rs | 34 ++++++++++++++++++++++++---- contracts/cw20-ics20/src/error.rs | 3 +++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c7e38bc2..e2ee01f14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -554,6 +554,7 @@ dependencies = [ "cw2", "cw20", "schemars", + "semver", "serde", "thiserror", ] diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index ca7a1bc00..765cc7035 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -25,6 +25,7 @@ cosmwasm-std = { version = "1.0.0-beta3", features = ["stargate"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } cw-controllers = { path = "../../packages/controllers", version = "0.12.0-alpha2" } schemars = "0.8.1" +semver = "1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 3182a3e62..dbb52f015 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -2,8 +2,9 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ from_binary, to_binary, Addr, Binary, Deps, DepsMut, Env, IbcMsg, IbcQuery, MessageInfo, Order, - PortIdResponse, Response, StdResult, + PortIdResponse, Response, StdError, StdResult, }; +use semver::Version; use cw2::{get_contract_version, set_contract_version}; use cw20::{Cw20Coin, Cw20ReceiveMsg}; @@ -192,13 +193,36 @@ pub fn execute_allow( #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { - let version = get_contract_version(deps.storage)?; - if version.contract != CONTRACT_NAME { + let version: Version = CONTRACT_VERSION.parse().map_err(from_semver)?; + let stored = get_contract_version(deps.storage)?; + let storage_version: Version = stored.version.parse().map_err(from_semver)?; + + if CONTRACT_NAME != stored.contract { return Err(ContractError::CannotMigrate { - previous_contract: version.contract, + previous_contract: stored.contract, }); } - Ok(Response::default()) + if storage_version > version { + return Err(ContractError::CannotMigrateVersion { + previous_version: stored.version, + }); + } + + // for 0.12.0-alpha1 or earlier, migrate from the config.gov_contract to ADMIN + if storage_version <= "0.12.0-alpha1".parse().map_err(from_semver)? { + // DO migration + } + + if storage_version < version { + // we don't need to save anything if migrating from the same version + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + } + + Ok(Response::new()) +} + +fn from_semver(err: semver::Error) -> StdError { + StdError::generic_err(format!("Semver: {}", err)) } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/cw20-ics20/src/error.rs b/contracts/cw20-ics20/src/error.rs index c9a6966a6..286ba4a62 100644 --- a/contracts/cw20-ics20/src/error.rs +++ b/contracts/cw20-ics20/src/error.rs @@ -51,6 +51,9 @@ pub enum ContractError { #[error("Cannot migrate from different contract type: {previous_contract}")] CannotMigrate { previous_contract: String }, + #[error("Cannot migrate from unsupported version: {previous_version}")] + CannotMigrateVersion { previous_version: String }, + #[error("Got a submessage reply with unknown id: {id}")] UnknownReplyId { id: u64 }, From 8d5524f8e40f650929c820f9771ffe64b7157f2f Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 31 Jan 2022 13:45:08 +0100 Subject: [PATCH 219/352] Perform proper migration logic --- contracts/cw20-ics20/src/contract.rs | 21 +++++++++++++++++++-- contracts/cw20-ics20/src/lib.rs | 1 + contracts/cw20-ics20/src/migrations.rs | 16 ++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 contracts/cw20-ics20/src/migrations.rs diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index dbb52f015..cbcd8767b 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -192,26 +192,43 @@ pub fn execute_allow( } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { +pub fn migrate(mut deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { let version: Version = CONTRACT_VERSION.parse().map_err(from_semver)?; let stored = get_contract_version(deps.storage)?; let storage_version: Version = stored.version.parse().map_err(from_semver)?; + // First, ensure we are working from an equal or older version of this contract + // wrong type if CONTRACT_NAME != stored.contract { return Err(ContractError::CannotMigrate { previous_contract: stored.contract, }); } + // existing one is newer if storage_version > version { return Err(ContractError::CannotMigrateVersion { previous_version: stored.version, }); } + // Then, run the proper migration + // unsupported old version + if storage_version < "0.11.1".parse().map_err(from_semver)? { + return Err(ContractError::CannotMigrateVersion { + previous_version: stored.version, + }); + } // for 0.12.0-alpha1 or earlier, migrate from the config.gov_contract to ADMIN if storage_version <= "0.12.0-alpha1".parse().map_err(from_semver)? { - // DO migration + // Do v1 migration + let old_config = crate::migrations::v1::CONFIG.load(deps.storage)?; + ADMIN.set(deps.branch(), Some(old_config.gov_contract))?; + let config = Config { + default_timeout: old_config.default_timeout, + }; + CONFIG.save(deps.storage, &config)?; } + // otherwise no migration (yet) if storage_version < version { // we don't need to save anything if migrating from the same version diff --git a/contracts/cw20-ics20/src/lib.rs b/contracts/cw20-ics20/src/lib.rs index 5e579aafa..b9ceef245 100644 --- a/contracts/cw20-ics20/src/lib.rs +++ b/contracts/cw20-ics20/src/lib.rs @@ -2,6 +2,7 @@ pub mod amount; pub mod contract; mod error; pub mod ibc; +mod migrations; pub mod msg; pub mod state; mod test_helpers; diff --git a/contracts/cw20-ics20/src/migrations.rs b/contracts/cw20-ics20/src/migrations.rs new file mode 100644 index 000000000..888df9418 --- /dev/null +++ b/contracts/cw20-ics20/src/migrations.rs @@ -0,0 +1,16 @@ +// v1 format is anything older than 0.12.0 +pub mod v1 { + use schemars::JsonSchema; + use serde::{Deserialize, Serialize}; + + use cosmwasm_std::Addr; + use cw_storage_plus::Item; + + #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] + pub struct ConfigV1 { + pub default_timeout: u64, + pub gov_contract: Addr, + } + + pub const CONFIG: Item = Item::new("ics20_config"); +} From 20c21779b082794ef30333ade457c20fe62a8f04 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 2 Feb 2022 20:53:28 +0100 Subject: [PATCH 220/352] Cleanup from pr review --- contracts/cw20-ics20/src/contract.rs | 18 ++++++++++-------- contracts/cw20-ics20/src/migrations.rs | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index cbcd8767b..35f946fd4 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -13,6 +13,7 @@ use cw_storage_plus::Bound; use crate::amount::Amount; use crate::error::ContractError; use crate::ibc::Ics20Packet; +use crate::migrations::v1; use crate::msg::{ AllowMsg, AllowedInfo, AllowedResponse, ChannelResponse, ConfigResponse, ExecuteMsg, InitMsg, ListAllowedResponse, ListChannelsResponse, MigrateMsg, PortResponse, QueryMsg, TransferMsg, @@ -191,6 +192,9 @@ pub fn execute_allow( Ok(res) } +const MIGRATE_MIN_VERSION: &str = "0.11.1"; +const MIGRATE_VERSION_2: &str = "0.12.0-alpha1"; + #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(mut deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { let version: Version = CONTRACT_VERSION.parse().map_err(from_semver)?; @@ -212,26 +216,24 @@ pub fn migrate(mut deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Resultv2 converstion if we are v1 style + if storage_version <= MIGRATE_VERSION_2.parse().map_err(from_semver)? { + let old_config = v1::CONFIG.load(deps.storage)?; ADMIN.set(deps.branch(), Some(old_config.gov_contract))?; let config = Config { default_timeout: old_config.default_timeout, }; CONFIG.save(deps.storage, &config)?; } - // otherwise no migration (yet) + // otherwise no migration (yet) - add them here + // we don't need to save anything if migrating from the same version if storage_version < version { - // we don't need to save anything if migrating from the same version set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; } diff --git a/contracts/cw20-ics20/src/migrations.rs b/contracts/cw20-ics20/src/migrations.rs index 888df9418..e874569a0 100644 --- a/contracts/cw20-ics20/src/migrations.rs +++ b/contracts/cw20-ics20/src/migrations.rs @@ -7,10 +7,10 @@ pub mod v1 { use cw_storage_plus::Item; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] - pub struct ConfigV1 { + pub struct Config { pub default_timeout: u64, pub gov_contract: Addr, } - pub const CONFIG: Item = Item::new("ics20_config"); + pub const CONFIG: Item = Item::new("ics20_config"); } From bb4bac178cf5e499b4f65f78ef8af0b4a335ccd8 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Fri, 4 Feb 2022 12:51:22 +0100 Subject: [PATCH 221/352] CW3: Add proposal_id field to VoteInfo structure --- contracts/cw3-fixed-multisig/src/contract.rs | 2 ++ contracts/cw3-flex-multisig/src/contract.rs | 4 ++++ packages/cw3/src/query.rs | 1 + 3 files changed, 7 insertions(+) diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 5928bcf82..8c2f530c7 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -337,6 +337,7 @@ fn query_vote(deps: Deps, proposal_id: u64, voter: String) -> StdResult StdResult Date: Sun, 6 Feb 2022 13:42:33 -0800 Subject: [PATCH 222/352] fix contract url link --- contracts/cw20-base/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw20-base/README.md b/contracts/cw20-base/README.md index 328b26742..01db9e054 100644 --- a/contracts/cw20-base/README.md +++ b/contracts/cw20-base/README.md @@ -44,5 +44,5 @@ calls, but then use the underlying implementation for the standard cw20 messages you want to support. The same with `QueryMsg`. You *could* reuse `instantiate` as it, but it is likely you will want to change it. And it is rather simple. -Look at [`cw20-staking`](../cw20-staking/README.md) for an example of how to "inherit" +Look at [`cw20-staking`](https://github.com/CosmWasm/cw-tokens/tree/main/contracts/cw20-staking) for an example of how to "inherit" all this token functionality and combine it with custom logic. From d3cdead992203a5720ea107fdc9ad4e95dcd5409 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 8 Feb 2022 15:19:46 +0100 Subject: [PATCH 223/352] controllers: support custom queries --- packages/controllers/src/admin.rs | 24 +++++++++++++++--------- packages/controllers/src/claim.rs | 8 ++++++-- packages/controllers/src/hooks.rs | 13 +++++++------ 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/packages/controllers/src/admin.rs b/packages/controllers/src/admin.rs index 61e0edf94..49cef71cf 100644 --- a/packages/controllers/src/admin.rs +++ b/packages/controllers/src/admin.rs @@ -3,7 +3,9 @@ use serde::{Deserialize, Serialize}; use std::fmt; use thiserror::Error; -use cosmwasm_std::{attr, Addr, Deps, DepsMut, MessageInfo, Response, StdError, StdResult}; +use cosmwasm_std::{ + attr, Addr, CustomQuery, Deps, DepsMut, MessageInfo, Response, StdError, StdResult, +}; use cw_storage_plus::Item; // TODO: should the return values end up in utils, so eg. cw4 can import them as well as this module? @@ -32,17 +34,17 @@ impl<'a> Admin<'a> { Admin(Item::new(namespace)) } - pub fn set(&self, deps: DepsMut, admin: Option) -> StdResult<()> { + pub fn set(&self, deps: DepsMut, admin: Option) -> StdResult<()> { self.0.save(deps.storage, &admin) } - pub fn get(&self, deps: Deps) -> StdResult> { + pub fn get(&self, deps: Deps) -> StdResult> { self.0.load(deps.storage) } /// Returns Ok(true) if this is an admin, Ok(false) if not and an Error if /// we hit an error with Api or Storage usage - pub fn is_admin(&self, deps: Deps, caller: &Addr) -> StdResult { + pub fn is_admin(&self, deps: Deps, caller: &Addr) -> StdResult { match self.0.load(deps.storage)? { Some(owner) => Ok(caller == &owner), None => Ok(false), @@ -51,7 +53,11 @@ impl<'a> Admin<'a> { /// Like is_admin but returns AdminError::NotAdmin if not admin. /// Helper for a nice one-line auth check. - pub fn assert_admin(&self, deps: Deps, caller: &Addr) -> Result<(), AdminError> { + pub fn assert_admin( + &self, + deps: Deps, + caller: &Addr, + ) -> Result<(), AdminError> { if !self.is_admin(deps, caller)? { Err(AdminError::NotAdmin {}) } else { @@ -59,9 +65,9 @@ impl<'a> Admin<'a> { } } - pub fn execute_update_admin( + pub fn execute_update_admin( &self, - deps: DepsMut, + deps: DepsMut, info: MessageInfo, new_admin: Option, ) -> Result, AdminError> @@ -160,14 +166,14 @@ mod tests { let info = mock_info(imposter.as_ref(), &[]); let new_admin = Some(friend.clone()); let err = control - .execute_update_admin::(deps.as_mut(), info, new_admin.clone()) + .execute_update_admin::(deps.as_mut(), info, new_admin.clone()) .unwrap_err(); assert_eq!(AdminError::NotAdmin {}, err); // owner can update let info = mock_info(owner.as_ref(), &[]); let res = control - .execute_update_admin::(deps.as_mut(), info, new_admin) + .execute_update_admin::(deps.as_mut(), info, new_admin) .unwrap(); assert_eq!(0, res.messages.len()); diff --git a/packages/controllers/src/claim.rs b/packages/controllers/src/claim.rs index a6d6c3d25..60025fce3 100644 --- a/packages/controllers/src/claim.rs +++ b/packages/controllers/src/claim.rs @@ -1,7 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{Addr, BlockInfo, Deps, StdResult, Storage, Uint128}; +use cosmwasm_std::{Addr, BlockInfo, CustomQuery, Deps, StdResult, Storage, Uint128}; use cw_storage_plus::Map; use cw_utils::Expiration; @@ -86,7 +86,11 @@ impl<'a> Claims<'a> { Ok(to_send) } - pub fn query_claims(&self, deps: Deps, address: &Addr) -> StdResult { + pub fn query_claims( + &self, + deps: Deps, + address: &Addr, + ) -> StdResult { let claims = self.0.may_load(deps.storage, address)?.unwrap_or_default(); Ok(ClaimsResponse { claims }) } diff --git a/packages/controllers/src/hooks.rs b/packages/controllers/src/hooks.rs index c42af5b85..673b8c8de 100644 --- a/packages/controllers/src/hooks.rs +++ b/packages/controllers/src/hooks.rs @@ -4,7 +4,8 @@ use std::fmt; use thiserror::Error; use cosmwasm_std::{ - attr, Addr, Deps, DepsMut, MessageInfo, Response, StdError, StdResult, Storage, SubMsg, + attr, Addr, CustomQuery, Deps, DepsMut, MessageInfo, Response, StdError, StdResult, Storage, + SubMsg, }; use cw_storage_plus::Item; @@ -73,10 +74,10 @@ impl<'a> Hooks<'a> { .collect() } - pub fn execute_add_hook( + pub fn execute_add_hook( &self, admin: &Admin, - deps: DepsMut, + deps: DepsMut, info: MessageInfo, addr: Addr, ) -> Result, HookError> @@ -94,10 +95,10 @@ impl<'a> Hooks<'a> { Ok(Response::new().add_attributes(attributes)) } - pub fn execute_remove_hook( + pub fn execute_remove_hook( &self, admin: &Admin, - deps: DepsMut, + deps: DepsMut, info: MessageInfo, addr: Addr, ) -> Result, HookError> @@ -115,7 +116,7 @@ impl<'a> Hooks<'a> { Ok(Response::new().add_attributes(attributes)) } - pub fn query_hooks(&self, deps: Deps) -> StdResult { + pub fn query_hooks(&self, deps: Deps) -> StdResult { let hooks = self.0.may_load(deps.storage)?.unwrap_or_default(); let hooks = hooks.into_iter().map(String::from).collect(); Ok(HooksResponse { hooks }) From f014234c257604147dd24bf685ab53d8a03874d6 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 8 Feb 2022 22:23:50 +0100 Subject: [PATCH 224/352] cw20: support custom queries --- packages/cw20/src/helpers.rs | 52 +++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/packages/cw20/src/helpers.rs b/packages/cw20/src/helpers.rs index 82bcafc4a..f1e3df19b 100644 --- a/packages/cw20/src/helpers.rs +++ b/packages/cw20/src/helpers.rs @@ -2,7 +2,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{ - to_binary, Addr, CosmosMsg, Empty, Querier, QuerierWrapper, StdResult, Uint128, WasmMsg, + to_binary, Addr, CosmosMsg, CustomQuery, Querier, QuerierWrapper, StdResult, Uint128, WasmMsg, WasmQuery, }; @@ -34,11 +34,12 @@ impl Cw20Contract { } /// Get token balance for the given address - pub fn balance>( - &self, - querier: &Q, - address: T, - ) -> StdResult { + pub fn balance(&self, querier: &Q, address: T) -> StdResult + where + Q: Querier, + T: Into, + CQ: CustomQuery, + { let msg = Cw20QueryMsg::Balance { address: address.into(), }; @@ -47,29 +48,39 @@ impl Cw20Contract { msg: to_binary(&msg)?, } .into(); - let res: BalanceResponse = QuerierWrapper::::new(querier).query(&query)?; + let res: BalanceResponse = QuerierWrapper::::new(querier).query(&query)?; Ok(res.balance) } /// Get metadata from the contract. This is a good check that the address /// is a valid Cw20 contract. - pub fn meta(&self, querier: &Q) -> StdResult { + pub fn meta(&self, querier: &Q) -> StdResult + where + Q: Querier, + CQ: CustomQuery, + { let msg = Cw20QueryMsg::TokenInfo {}; let query = WasmQuery::Smart { contract_addr: self.addr().into(), msg: to_binary(&msg)?, } .into(); - QuerierWrapper::::new(querier).query(&query) + QuerierWrapper::::new(querier).query(&query) } /// Get allowance of spender to use owner's account - pub fn allowance, U: Into>( + pub fn allowance( &self, querier: &Q, owner: T, spender: U, - ) -> StdResult { + ) -> StdResult + where + Q: Querier, + T: Into, + U: Into, + CQ: CustomQuery, + { let msg = Cw20QueryMsg::Allowance { owner: owner.into(), spender: spender.into(), @@ -79,27 +90,32 @@ impl Cw20Contract { msg: to_binary(&msg)?, } .into(); - QuerierWrapper::::new(querier).query(&query) + QuerierWrapper::::new(querier).query(&query) } /// Find info on who can mint, and how much - pub fn minter(&self, querier: &Q) -> StdResult> { + pub fn minter(&self, querier: &Q) -> StdResult> + where + Q: Querier, + CQ: CustomQuery, + { let msg = Cw20QueryMsg::Minter {}; let query = WasmQuery::Smart { contract_addr: self.addr().into(), msg: to_binary(&msg)?, } .into(); - QuerierWrapper::::new(querier).query(&query) + QuerierWrapper::::new(querier).query(&query) } /// returns true if the contract supports the allowance extension - pub fn has_allowance(&self, querier: &Q) -> bool { - self.allowance(querier, self.addr(), self.addr()).is_ok() + pub fn has_allowance(&self, querier: &Q) -> bool { + self.allowance::<_, _, _, CQ>(querier, self.addr(), self.addr()) + .is_ok() } /// returns true if the contract supports the mintable extension - pub fn is_mintable(&self, querier: &Q) -> bool { - self.minter(querier).is_ok() + pub fn is_mintable(&self, querier: &Q) -> bool { + self.minter::<_, CQ>(querier).is_ok() } } From 6be3f6ee89f9047a2e2c645dcad111d4b2ee1d61 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 8 Feb 2022 22:23:58 +0100 Subject: [PATCH 225/352] cw4: support custom queries --- packages/cw4/src/helpers.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cw4/src/helpers.rs b/packages/cw4/src/helpers.rs index c692f29e7..0761e5c39 100644 --- a/packages/cw4/src/helpers.rs +++ b/packages/cw4/src/helpers.rs @@ -2,7 +2,8 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{ - to_binary, Addr, CosmosMsg, Empty, QuerierWrapper, QueryRequest, StdResult, WasmMsg, WasmQuery, + to_binary, Addr, CosmosMsg, CustomQuery, QuerierWrapper, QueryRequest, StdResult, WasmMsg, + WasmQuery, }; use crate::msg::Cw4ExecuteMsg; @@ -54,7 +55,7 @@ impl Cw4Contract { self.encode_msg(msg) } - fn encode_smart_query(&self, msg: Cw4QueryMsg) -> StdResult> { + fn encode_smart_query(&self, msg: Cw4QueryMsg) -> StdResult> { Ok(WasmQuery::Smart { contract_addr: self.addr().into(), msg: to_binary(&msg)?, @@ -63,7 +64,7 @@ impl Cw4Contract { } /// Show the hooks - pub fn hooks(&self, querier: &QuerierWrapper) -> StdResult> { + pub fn hooks(&self, querier: &QuerierWrapper) -> StdResult> { let query = self.encode_smart_query(Cw4QueryMsg::Hooks {})?; let res: HooksResponse = querier.query(&query)?; Ok(res.hooks) From 3edbdc75dfa3c3f72c2273a7488881d1362ac626 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 8 Feb 2022 22:25:35 +0100 Subject: [PATCH 226/352] multi-test: support custom queries --- packages/multi-test/src/app.rs | 2 +- packages/multi-test/src/contracts.rs | 130 ++++++++++++++------------- packages/multi-test/src/wasm.rs | 8 +- 3 files changed, 75 insertions(+), 65 deletions(-) diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index c23e6873a..f06ba6ac4 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -557,7 +557,7 @@ where { /// This registers contract code (like uploading wasm bytecode on a chain), /// so it can later be used to instantiate a contract. - pub fn store_code(&mut self, code: Box>) -> u64 { + pub fn store_code(&mut self, code: Box>) -> u64 { self.init_modules(|router, _, _| router.wasm.store_code(code) as u64) } diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index e703b75a8..72bf76950 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -4,19 +4,21 @@ use std::error::Error; use std::fmt::{self, Debug, Display}; use cosmwasm_std::{ - from_slice, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Reply, Response, SubMsg, + from_slice, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Empty, Env, MessageInfo, Reply, + Response, SubMsg, }; use anyhow::{anyhow, bail, Context, Result as AnyResult}; /// Interface to call into a Contract -pub trait Contract +pub trait Contract where T: Clone + fmt::Debug + PartialEq + JsonSchema, + Q: CustomQuery, { fn execute( &self, - deps: DepsMut, + deps: DepsMut, env: Env, info: MessageInfo, msg: Vec, @@ -24,31 +26,32 @@ where fn instantiate( &self, - deps: DepsMut, + deps: DepsMut, env: Env, info: MessageInfo, msg: Vec, ) -> AnyResult>; - fn query(&self, deps: Deps, env: Env, msg: Vec) -> AnyResult; + fn query(&self, deps: Deps, env: Env, msg: Vec) -> AnyResult; - fn sudo(&self, deps: DepsMut, env: Env, msg: Vec) -> AnyResult>; + fn sudo(&self, deps: DepsMut, env: Env, msg: Vec) -> AnyResult>; - fn reply(&self, deps: DepsMut, env: Env, msg: Reply) -> AnyResult>; + fn reply(&self, deps: DepsMut, env: Env, msg: Reply) -> AnyResult>; - fn migrate(&self, deps: DepsMut, env: Env, msg: Vec) -> AnyResult>; + fn migrate(&self, deps: DepsMut, env: Env, msg: Vec) -> AnyResult>; } -type ContractFn = - fn(deps: DepsMut, env: Env, info: MessageInfo, msg: T) -> Result, E>; -type PermissionedFn = fn(deps: DepsMut, env: Env, msg: T) -> Result, E>; -type ReplyFn = fn(deps: DepsMut, env: Env, msg: Reply) -> Result, E>; -type QueryFn = fn(deps: Deps, env: Env, msg: T) -> Result; +type ContractFn = + fn(deps: DepsMut, env: Env, info: MessageInfo, msg: T) -> Result, E>; +type PermissionedFn = fn(deps: DepsMut, env: Env, msg: T) -> Result, E>; +type ReplyFn = fn(deps: DepsMut, env: Env, msg: Reply) -> Result, E>; +type QueryFn = fn(deps: Deps, env: Env, msg: T) -> Result; -type ContractClosure = Box Result, E>>; -type PermissionedClosure = Box Result, E>>; -type ReplyClosure = Box Result, E>>; -type QueryClosure = Box Result>; +type ContractClosure = + Box, Env, MessageInfo, T) -> Result, E>>; +type PermissionedClosure = Box, Env, T) -> Result, E>>; +type ReplyClosure = Box, Env, Reply) -> Result, E>>; +type QueryClosure = Box, Env, T) -> Result>; /// Wraps the exported functions from a contract and provides the normalized format /// Place T4 and E4 at the end, as we just want default placeholders for most contracts that don't have sudo @@ -60,6 +63,7 @@ pub struct ContractWrapper< E2, E3, C = Empty, + Q = Empty, T4 = Empty, E4 = anyhow::Error, E5 = anyhow::Error, @@ -78,16 +82,17 @@ pub struct ContractWrapper< E5: Display + Debug + Send + Sync + 'static, E6: Display + Debug + Send + Sync + 'static, C: Clone + fmt::Debug + PartialEq + JsonSchema, + Q: CustomQuery + DeserializeOwned + 'static, { - execute_fn: ContractClosure, - instantiate_fn: ContractClosure, - query_fn: QueryClosure, - sudo_fn: Option>, - reply_fn: Option>, - migrate_fn: Option>, + execute_fn: ContractClosure, + instantiate_fn: ContractClosure, + query_fn: QueryClosure, + sudo_fn: Option>, + reply_fn: Option>, + migrate_fn: Option>, } -impl ContractWrapper +impl ContractWrapper where T1: DeserializeOwned + Debug + 'static, T2: DeserializeOwned + 'static, @@ -96,13 +101,14 @@ where E2: Display + Debug + Send + Sync + 'static, E3: Display + Debug + Send + Sync + 'static, C: Clone + fmt::Debug + PartialEq + JsonSchema + 'static, + Q: CustomQuery + DeserializeOwned + 'static, { pub fn new( - execute_fn: ContractFn, - instantiate_fn: ContractFn, - query_fn: QueryFn, + execute_fn: ContractFn, + instantiate_fn: ContractFn, + query_fn: QueryFn, ) -> Self { - ContractWrapper { + Self { execute_fn: Box::new(execute_fn), instantiate_fn: Box::new(instantiate_fn), query_fn: Box::new(query_fn), @@ -115,11 +121,11 @@ where /// this will take a contract that returns Response and will "upgrade" it /// to Response if needed to be compatible with a chain-specific extension pub fn new_with_empty( - execute_fn: ContractFn, - instantiate_fn: ContractFn, - query_fn: QueryFn, + execute_fn: ContractFn, + instantiate_fn: ContractFn, + query_fn: QueryFn, ) -> Self { - ContractWrapper { + Self { execute_fn: customize_fn(execute_fn), instantiate_fn: customize_fn(instantiate_fn), query_fn: Box::new(query_fn), @@ -130,8 +136,8 @@ where } } -impl - ContractWrapper +impl + ContractWrapper where T1: DeserializeOwned + Debug + 'static, T2: DeserializeOwned + 'static, @@ -145,11 +151,12 @@ where E5: Display + Debug + Send + Sync + 'static, E6: Display + Debug + Send + Sync + 'static, C: Clone + fmt::Debug + PartialEq + JsonSchema + 'static, + Q: CustomQuery + DeserializeOwned + 'static, { pub fn with_sudo( self, - sudo_fn: PermissionedFn, - ) -> ContractWrapper + sudo_fn: PermissionedFn, + ) -> ContractWrapper where T4A: DeserializeOwned + 'static, E4A: Display + Debug + Send + Sync + 'static, @@ -166,8 +173,8 @@ where pub fn with_sudo_empty( self, - sudo_fn: PermissionedFn, - ) -> ContractWrapper + sudo_fn: PermissionedFn, + ) -> ContractWrapper where T4A: DeserializeOwned + 'static, E4A: Display + Debug + Send + Sync + 'static, @@ -184,8 +191,8 @@ where pub fn with_reply( self, - reply_fn: ReplyFn, - ) -> ContractWrapper + reply_fn: ReplyFn, + ) -> ContractWrapper where E5A: Display + Debug + Send + Sync + 'static, { @@ -202,8 +209,8 @@ where /// A correlate of new_with_empty pub fn with_reply_empty( self, - reply_fn: ReplyFn, - ) -> ContractWrapper + reply_fn: ReplyFn, + ) -> ContractWrapper where E5A: Display + Debug + Send + Sync + 'static, { @@ -219,8 +226,8 @@ where pub fn with_migrate( self, - migrate_fn: PermissionedFn, - ) -> ContractWrapper + migrate_fn: PermissionedFn, + ) -> ContractWrapper where T6A: DeserializeOwned + 'static, E6A: Display + Debug + Send + Sync + 'static, @@ -237,8 +244,8 @@ where pub fn with_migrate_empty( self, - migrate_fn: PermissionedFn, - ) -> ContractWrapper + migrate_fn: PermissionedFn, + ) -> ContractWrapper where T6A: DeserializeOwned + 'static, E6A: Display + Debug + Send + Sync + 'static, @@ -254,28 +261,30 @@ where } } -fn customize_fn(raw_fn: ContractFn) -> ContractClosure +fn customize_fn(raw_fn: ContractFn) -> ContractClosure where T: DeserializeOwned + 'static, E: Display + Debug + Send + Sync + 'static, C: Clone + fmt::Debug + PartialEq + JsonSchema + 'static, + Q: CustomQuery + DeserializeOwned + 'static, { let customized = - move |deps: DepsMut, env: Env, info: MessageInfo, msg: T| -> Result, E> { + move |deps: DepsMut, env: Env, info: MessageInfo, msg: T| -> Result, E> { raw_fn(deps, env, info, msg).map(customize_response::) }; Box::new(customized) } -fn customize_permissioned_fn( - raw_fn: PermissionedFn, -) -> PermissionedClosure +fn customize_permissioned_fn( + raw_fn: PermissionedFn, +) -> PermissionedClosure where T: DeserializeOwned + 'static, E: Display + Debug + Send + Sync + 'static, C: Clone + fmt::Debug + PartialEq + JsonSchema + 'static, + Q: CustomQuery + DeserializeOwned + 'static, { - let customized = move |deps: DepsMut, env: Env, msg: T| -> Result, E> { + let customized = move |deps: DepsMut, env: Env, msg: T| -> Result, E> { raw_fn(deps, env, msg).map(customize_response::) }; Box::new(customized) @@ -315,8 +324,8 @@ where } } -impl Contract - for ContractWrapper +impl Contract + for ContractWrapper where T1: DeserializeOwned + Debug + Clone, T2: DeserializeOwned + Debug + Clone, @@ -330,10 +339,11 @@ where E5: Display + Debug + Send + Sync + 'static, E6: Display + Debug + Send + Sync + 'static, C: Clone + fmt::Debug + PartialEq + JsonSchema, + Q: CustomQuery + DeserializeOwned, { fn execute( &self, - deps: DepsMut, + deps: DepsMut, env: Env, info: MessageInfo, msg: Vec, @@ -349,7 +359,7 @@ where fn instantiate( &self, - deps: DepsMut, + deps: DepsMut, env: Env, info: MessageInfo, msg: Vec, @@ -363,7 +373,7 @@ where )) } - fn query(&self, deps: Deps, env: Env, msg: Vec) -> AnyResult { + fn query(&self, deps: Deps, env: Env, msg: Vec) -> AnyResult { let msg: T3 = from_slice(&msg)?; (self.query_fn)(deps, env, msg.clone()) .map_err(anyhow::Error::from) @@ -374,7 +384,7 @@ where } // this returns an error if the contract doesn't implement sudo - fn sudo(&self, deps: DepsMut, env: Env, msg: Vec) -> AnyResult> { + fn sudo(&self, deps: DepsMut, env: Env, msg: Vec) -> AnyResult> { let msg = from_slice(&msg)?; match &self.sudo_fn { Some(sudo) => sudo(deps, env, msg).map_err(|err| anyhow!(err)), @@ -383,7 +393,7 @@ where } // this returns an error if the contract doesn't implement reply - fn reply(&self, deps: DepsMut, env: Env, reply_data: Reply) -> AnyResult> { + fn reply(&self, deps: DepsMut, env: Env, reply_data: Reply) -> AnyResult> { match &self.reply_fn { Some(reply) => reply(deps, env, reply_data).map_err(|err| anyhow!(err)), None => bail!("reply not implemented for contract"), @@ -391,7 +401,7 @@ where } // this returns an error if the contract doesn't implement migrate - fn migrate(&self, deps: DepsMut, env: Env, msg: Vec) -> AnyResult> { + fn migrate(&self, deps: DepsMut, env: Env, msg: Vec) -> AnyResult> { let msg = from_slice(&msg)?; match &self.migrate_fn { Some(migrate) => migrate(deps, env, msg).map_err(|err| anyhow!(err)), diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index 9a30d47e7..ce793c3af 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -99,7 +99,7 @@ pub trait Wasm { pub struct WasmKeeper { /// code is in-memory lookup that stands in for wasm code /// this can only be edited on the WasmRouter, and just read in caches - codes: HashMap>>, + codes: HashMap>>, /// Just markers to make type elision fork when using it as `Wasm` trait _p: std::marker::PhantomData, } @@ -180,7 +180,7 @@ where } impl WasmKeeper { - pub fn store_code(&mut self, code: Box>) -> usize { + pub fn store_code(&mut self, code: Box>) -> usize { let idx = self.codes.len() + 1; self.codes.insert(idx, code); idx @@ -706,7 +706,7 @@ where action: F, ) -> AnyResult where - F: FnOnce(&Box>, Deps, Env) -> AnyResult, + F: FnOnce(&Box>, Deps, Env) -> AnyResult, { let contract = self.load_contract(storage, &address)?; let handler = self @@ -734,7 +734,7 @@ where action: F, ) -> AnyResult where - F: FnOnce(&Box>, DepsMut, Env) -> AnyResult, + F: FnOnce(&Box>, DepsMut, Env) -> AnyResult, ExecC: DeserializeOwned, { let contract = self.load_contract(storage, &address)?; From bc08740e9dffacf51ed2fb5b9ccb9c063e49b453 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 8 Feb 2022 22:40:45 +0100 Subject: [PATCH 227/352] lints --- packages/multi-test/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/multi-test/src/lib.rs b/packages/multi-test/src/lib.rs index a2071a08e..0ee12f501 100644 --- a/packages/multi-test/src/lib.rs +++ b/packages/multi-test/src/lib.rs @@ -6,6 +6,8 @@ //! //! To understand the design of this module, please refer to `../DESIGN.md` +#![allow(clippy::type_complexity)] + mod app; mod bank; mod contracts; From 03a3d0cf96a14709e81d8dcd1a38ca89bdda833f Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Tue, 8 Feb 2022 22:43:05 +0100 Subject: [PATCH 228/352] storage-plus: support custom queries --- packages/storage-plus/src/helpers.rs | 8 ++++---- packages/storage-plus/src/item.rs | 10 ++++++++-- packages/storage-plus/src/map.rs | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/storage-plus/src/helpers.rs b/packages/storage-plus/src/helpers.rs index 6f566ea2e..701b014fe 100644 --- a/packages/storage-plus/src/helpers.rs +++ b/packages/storage-plus/src/helpers.rs @@ -10,7 +10,7 @@ use std::any::type_name; use crate::keys::Key; use cosmwasm_std::{ - from_slice, to_vec, Addr, Binary, ContractResult, Empty, QuerierWrapper, QueryRequest, + from_slice, to_vec, Addr, Binary, ContractResult, CustomQuery, QuerierWrapper, QueryRequest, StdError, StdResult, SystemResult, WasmQuery, }; @@ -93,12 +93,12 @@ pub(crate) fn encode_length(namespace: &[u8]) -> [u8; 2] { /// This is similar to querier.query(WasmQuery::Raw{}), except it does NOT parse the /// result, but return a possibly empty Binary to be handled by the calling code. /// That is essential to handle b"" as None. -pub(crate) fn query_raw( - querier: &QuerierWrapper, +pub(crate) fn query_raw( + querier: &QuerierWrapper, contract_addr: Addr, key: Binary, ) -> StdResult { - let request: QueryRequest = WasmQuery::Raw { + let request: QueryRequest = WasmQuery::Raw { contract_addr: contract_addr.into(), key, } diff --git a/packages/storage-plus/src/item.rs b/packages/storage-plus/src/item.rs index 93b202bbf..312a87fef 100644 --- a/packages/storage-plus/src/item.rs +++ b/packages/storage-plus/src/item.rs @@ -2,7 +2,9 @@ use serde::de::DeserializeOwned; use serde::Serialize; use std::marker::PhantomData; -use cosmwasm_std::{to_vec, Addr, QuerierWrapper, StdError, StdResult, Storage, WasmQuery}; +use cosmwasm_std::{ + to_vec, Addr, CustomQuery, QuerierWrapper, StdError, StdResult, Storage, WasmQuery, +}; use crate::helpers::{may_deserialize, must_deserialize}; @@ -77,7 +79,11 @@ where /// from a remote contract in a type-safe way using WasmQuery::RawQuery. /// /// Note that we expect an Item to be set, and error if there is no data there - pub fn query(&self, querier: &QuerierWrapper, remote_contract: Addr) -> StdResult { + pub fn query( + &self, + querier: &QuerierWrapper, + remote_contract: Addr, + ) -> StdResult { let request = WasmQuery::Raw { contract_addr: remote_contract.into(), key: self.storage_key.into(), diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 0b50944ab..398521f3a 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -15,7 +15,7 @@ use crate::keys::{Key, PrimaryKey}; use crate::path::Path; #[cfg(feature = "iterator")] use crate::prefix::{namespaced_prefix_range, Prefix}; -use cosmwasm_std::{from_slice, Addr, QuerierWrapper, StdError, StdResult, Storage}; +use cosmwasm_std::{from_slice, Addr, CustomQuery, QuerierWrapper, StdError, StdResult, Storage}; #[derive(Debug, Clone)] pub struct Map<'a, K, T> { @@ -95,9 +95,9 @@ where /// If you import the proper Map from the remote contract, this will let you read the data /// from a remote contract in a type-safe way using WasmQuery::RawQuery - pub fn query( + pub fn query( &self, - querier: &QuerierWrapper, + querier: &QuerierWrapper, remote_contract: Addr, k: K, ) -> StdResult> { From 13464aa289c688bb1710f8526dbc2ec3f4a29275 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 8 Feb 2022 21:15:20 +0100 Subject: [PATCH 229/352] Update balance in transfer, reduce on_packet_failure, like ibctransfer --- contracts/cw20-ics20/src/contract.rs | 13 +++++++++---- contracts/cw20-ics20/src/ibc.rs | 13 +++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 35f946fd4..706a16073 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -18,7 +18,10 @@ use crate::msg::{ AllowMsg, AllowedInfo, AllowedResponse, ChannelResponse, ConfigResponse, ExecuteMsg, InitMsg, ListAllowedResponse, ListChannelsResponse, MigrateMsg, PortResponse, QueryMsg, TransferMsg, }; -use crate::state::{AllowInfo, Config, ADMIN, ALLOW_LIST, CHANNEL_INFO, CHANNEL_STATE, CONFIG}; +use crate::state::{ + increase_channel_balance, AllowInfo, Config, ADMIN, ALLOW_LIST, CHANNEL_INFO, CHANNEL_STATE, + CONFIG, +}; use cw_utils::{maybe_addr, nonpayable, one_coin}; // version info for migration info @@ -130,6 +133,11 @@ pub fn execute_transfer( ); packet.validate()?; + // Update the balance now (optimistically) like ibctransfer modules. + // In on_packet_failure (ack with error message or a timeout), we reduce the balance appropriately. + // This means the channel works fine if success acks are not relayed. + increase_channel_balance(deps.storage, &msg.channel, &amount.denom(), amount.amount())?; + // prepare ibc message let msg = IbcMsg::SendPacket { channel_id: msg.channel, @@ -137,9 +145,6 @@ pub fn execute_transfer( timeout: timeout.into(), }; - // Note: we update local state when we get ack - do not count this transfer towards anything until acked - // similar event messages like ibctransfer module - // send response let res = Response::new() .add_message(msg) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index ebc3139cb..d1a4da259 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -11,8 +11,8 @@ use cosmwasm_std::{ use crate::amount::Amount; use crate::error::{ContractError, Never}; use crate::state::{ - increase_channel_balance, reduce_channel_balance, undo_reduce_channel_balance, ChannelInfo, - ReplyArgs, ALLOW_LIST, CHANNEL_INFO, REPLY_ARGS, + reduce_channel_balance, undo_reduce_channel_balance, ChannelInfo, ReplyArgs, ALLOW_LIST, + CHANNEL_INFO, REPLY_ARGS, }; use cw20::Cw20ExecuteMsg; @@ -312,8 +312,9 @@ pub fn ibc_packet_timeout( } // update the balance stored on this (channel, denom) index -fn on_packet_success(deps: DepsMut, packet: IbcPacket) -> Result { +fn on_packet_success(_deps: DepsMut, packet: IbcPacket) -> Result { let msg: Ics20Packet = from_binary(&packet.data)?; + // similar event messages like ibctransfer module let attributes = vec![ attr("action", "acknowledge"), @@ -324,9 +325,6 @@ fn on_packet_success(deps: DepsMut, packet: IbcPacket) -> Result Result { let msg: Ics20Packet = from_binary(&packet.data)?; + // undo the balance update + reduce_channel_balance(deps.storage, &packet.src.channel_id, &msg.denom, msg.amount)?; + let to_send = Amount::from_parts(msg.denom.clone(), msg.amount); let gas_limit = check_gas_limit(deps.as_ref(), &to_send)?; let send = send_amount(to_send, msg.sender.clone()); From 3696e600716e131ca01cd14cabbf14bdc28ed3f6 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 8 Feb 2022 21:26:26 +0100 Subject: [PATCH 230/352] Update tests --- contracts/cw20-ics20/src/ibc.rs | 45 ++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index d1a4da259..f7e6abb3f 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -386,9 +386,11 @@ mod test { use super::*; use crate::test_helpers::*; - use crate::contract::query_channel; - use cosmwasm_std::testing::mock_env; - use cosmwasm_std::{coins, to_vec, IbcAcknowledgement, IbcEndpoint, IbcTimeout, Timestamp}; + use crate::contract::{execute, query_channel}; + use crate::msg::{ExecuteMsg, TransferMsg}; + use cosmwasm_std::testing::{mock_env, mock_info}; + use cosmwasm_std::{coins, to_vec, IbcEndpoint, IbcTimeout, Timestamp}; + use cw20::Cw20ReceiveMsg; #[test] fn check_ack_json() { @@ -447,6 +449,7 @@ mod test { ) } + #[allow(dead_code)] fn mock_sent_packet(my_channel: &str, amount: u128, denom: &str, sender: &str) -> IbcPacket { let data = Ics20Packet { denom: denom.into(), @@ -468,6 +471,7 @@ mod test { IbcTimeout::with_timestamp(Timestamp::from_seconds(1665321069)), ) } + fn mock_receive_packet( my_channel: &str, amount: u128, @@ -509,23 +513,31 @@ mod test { ); // prepare some mock packets - let sent_packet = mock_sent_packet(send_channel, 987654321, cw20_denom, "local-sender"); let recv_packet = mock_receive_packet(send_channel, 876543210, cw20_denom, "local-rcpt"); let recv_high_packet = mock_receive_packet(send_channel, 1876543210, cw20_denom, "local-rcpt"); - let msg = IbcPacketReceiveMsg::new(recv_packet.clone()); // cannot receive this denom yet + let msg = IbcPacketReceiveMsg::new(recv_packet.clone()); let res = ibc_packet_receive(deps.as_mut(), mock_env(), msg).unwrap(); assert!(res.messages.is_empty()); let ack: Ics20Ack = from_binary(&res.acknowledgement).unwrap(); let no_funds = Ics20Ack::Error(ContractError::InsufficientFunds {}.to_string()); assert_eq!(ack, no_funds); - // we get a success cache (ack) for a send - let msg = IbcPacketAckMsg::new(IbcAcknowledgement::new(ack_success()), sent_packet); - let res = ibc_packet_ack(deps.as_mut(), mock_env(), msg).unwrap(); - assert_eq!(0, res.messages.len()); + // we send some cw20 tokens over + let transfer = TransferMsg { + channel: send_channel.to_string(), + remote_address: "remote-rcpt".to_string(), + timeout: None, + }; + let msg = ExecuteMsg::Receive(Cw20ReceiveMsg { + sender: "local-sender".to_string(), + amount: Uint128::new(987654321), + msg: to_binary(&transfer).unwrap(), + }); + let info = mock_info(cw20_addr, &[]); + execute(deps.as_mut(), mock_env(), info, msg).unwrap(); // query channel state|_| let state = query_channel(deps.as_ref(), send_channel.to_string()).unwrap(); @@ -566,7 +578,6 @@ mod test { let denom = "uatom"; // prepare some mock packets - let sent_packet = mock_sent_packet(send_channel, 987654321, denom, "local-sender"); let recv_packet = mock_receive_packet(send_channel, 876543210, denom, "local-rcpt"); let recv_high_packet = mock_receive_packet(send_channel, 1876543210, denom, "local-rcpt"); @@ -578,10 +589,14 @@ mod test { let no_funds = Ics20Ack::Error(ContractError::InsufficientFunds {}.to_string()); assert_eq!(ack, no_funds); - // we get a success cache (ack) for a send - let msg = IbcPacketAckMsg::new(IbcAcknowledgement::new(ack_success()), sent_packet); - let res = ibc_packet_ack(deps.as_mut(), mock_env(), msg).unwrap(); - assert_eq!(0, res.messages.len()); + // we transfer some tokens + let msg = ExecuteMsg::Transfer(TransferMsg { + channel: send_channel.to_string(), + remote_address: "my-remote-address".to_string(), + timeout: None, + }); + let info = mock_info("local-sender", &coins(987654321, denom)); + execute(deps.as_mut(), mock_env(), info, msg).unwrap(); // query channel state|_| let state = query_channel(deps.as_ref(), send_channel.to_string()).unwrap(); @@ -606,7 +621,7 @@ mod test { let ack: Ics20Ack = from_binary(&res.acknowledgement).unwrap(); matches!(ack, Ics20Ack::Result(_)); - // TODO: we must call the reply block + // only need to call reply block on error case // query channel state let state = query_channel(deps.as_ref(), send_channel.to_string()).unwrap(); From 82094c82274e399f47792042c64f37672e38ea2c Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 8 Feb 2022 21:45:13 +0100 Subject: [PATCH 231/352] Check sent ibc packet in tests --- contracts/cw20-ics20/src/ibc.rs | 43 ++++++++++++++------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index f7e6abb3f..7538d84bd 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -389,7 +389,7 @@ mod test { use crate::contract::{execute, query_channel}; use crate::msg::{ExecuteMsg, TransferMsg}; use cosmwasm_std::testing::{mock_env, mock_info}; - use cosmwasm_std::{coins, to_vec, IbcEndpoint, IbcTimeout, Timestamp}; + use cosmwasm_std::{coins, to_vec, IbcEndpoint, IbcMsg, IbcTimeout, Timestamp}; use cw20::Cw20ReceiveMsg; #[test] @@ -449,29 +449,6 @@ mod test { ) } - #[allow(dead_code)] - fn mock_sent_packet(my_channel: &str, amount: u128, denom: &str, sender: &str) -> IbcPacket { - let data = Ics20Packet { - denom: denom.into(), - amount: amount.into(), - sender: sender.to_string(), - receiver: "remote-rcpt".to_string(), - }; - IbcPacket::new( - to_binary(&data).unwrap(), - IbcEndpoint { - port_id: CONTRACT_PORT.to_string(), - channel_id: my_channel.to_string(), - }, - IbcEndpoint { - port_id: REMOTE_PORT.to_string(), - channel_id: "channel-1234".to_string(), - }, - 2, - IbcTimeout::with_timestamp(Timestamp::from_seconds(1665321069)), - ) - } - fn mock_receive_packet( my_channel: &str, amount: u128, @@ -537,7 +514,23 @@ mod test { msg: to_binary(&transfer).unwrap(), }); let info = mock_info(cw20_addr, &[]); - execute(deps.as_mut(), mock_env(), info, msg).unwrap(); + let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); + assert_eq!(1, res.messages.len()); + let expected = Ics20Packet { + denom: cw20_denom.into(), + amount: Uint128::new(987654321), + sender: "local-sender".to_string(), + receiver: "remote-rcpt".to_string(), + }; + let timeout = mock_env().block.time.plus_seconds(DEFAULT_TIMEOUT); + assert_eq!( + &res.messages[0], + &SubMsg::new(IbcMsg::SendPacket { + channel_id: send_channel.to_string(), + data: to_binary(&expected).unwrap(), + timeout: IbcTimeout::with_timestamp(timeout), + }) + ); // query channel state|_| let state = query_channel(deps.as_ref(), send_channel.to_string()).unwrap(); From 2ea606be2e9af33a4f23baf24506a798711cb2d7 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 9 Feb 2022 12:35:41 +0100 Subject: [PATCH 232/352] Add version on packet, so we can use old ack handling for in-flight packets --- contracts/cw20-ics20/src/ibc.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index 7538d84bd..f666db322 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -11,8 +11,8 @@ use cosmwasm_std::{ use crate::amount::Amount; use crate::error::{ContractError, Never}; use crate::state::{ - reduce_channel_balance, undo_reduce_channel_balance, ChannelInfo, ReplyArgs, ALLOW_LIST, - CHANNEL_INFO, REPLY_ARGS, + increase_channel_balance, reduce_channel_balance, undo_reduce_channel_balance, ChannelInfo, + ReplyArgs, ALLOW_LIST, CHANNEL_INFO, REPLY_ARGS, }; use cw20::Cw20ExecuteMsg; @@ -32,8 +32,12 @@ pub struct Ics20Packet { pub receiver: String, /// the sender address pub sender: String, + /// used only by us to control ack handling + pub v: Option, } +const V2: u32 = 2; + impl Ics20Packet { pub fn new>(amount: Uint128, denom: T, sender: &str, receiver: &str) -> Self { Ics20Packet { @@ -41,6 +45,7 @@ impl Ics20Packet { amount, sender: sender.to_string(), receiver: receiver.to_string(), + v: Some(V2), } } @@ -312,9 +317,15 @@ pub fn ibc_packet_timeout( } // update the balance stored on this (channel, denom) index -fn on_packet_success(_deps: DepsMut, packet: IbcPacket) -> Result { +fn on_packet_success(deps: DepsMut, packet: IbcPacket) -> Result { let msg: Ics20Packet = from_binary(&packet.data)?; + // if this was for an older (pre-v2) packet we send continue with old behavior + // (this is needed for transitioning on a system with pending packet) + if msg.v.is_none() { + increase_channel_balance(deps.storage, &packet.src.channel_id, &msg.denom, msg.amount)?; + } + // similar event messages like ibctransfer module let attributes = vec![ attr("action", "acknowledge"), @@ -336,8 +347,10 @@ fn on_packet_failure( ) -> Result { let msg: Ics20Packet = from_binary(&packet.data)?; - // undo the balance update - reduce_channel_balance(deps.storage, &packet.src.channel_id, &msg.denom, msg.amount)?; + // undo the balance update (but not for pre-v2/None packets which didn't add before sending) + if msg.v.is_some() { + reduce_channel_balance(deps.storage, &packet.src.channel_id, &msg.denom, msg.amount)?; + } let to_send = Amount::from_parts(msg.denom.clone(), msg.amount); let gas_limit = check_gas_limit(deps.as_ref(), &to_send)?; @@ -413,7 +426,7 @@ mod test { "wasm1fucynrfkrt684pm8jrt8la5h2csvs5cnldcgqc", ); // Example message generated from the SDK - let expected = r#"{"amount":"12345","denom":"ucosm","receiver":"wasm1fucynrfkrt684pm8jrt8la5h2csvs5cnldcgqc","sender":"cosmos1zedxv25ah8fksmg2lzrndrpkvsjqgk4zt5ff7n"}"#; + let expected = r#"{"amount":"12345","denom":"ucosm","receiver":"wasm1fucynrfkrt684pm8jrt8la5h2csvs5cnldcgqc","sender":"cosmos1zedxv25ah8fksmg2lzrndrpkvsjqgk4zt5ff7n","v":2}"#; let encdoded = String::from_utf8(to_vec(&packet).unwrap()).unwrap(); assert_eq!(expected, encdoded.as_str()); @@ -461,6 +474,7 @@ mod test { amount: amount.into(), sender: "remote-sender".to_string(), receiver: receiver.to_string(), + v: Some(V2), }; print!("Packet denom: {}", &data.denom); IbcPacket::new( @@ -521,6 +535,7 @@ mod test { amount: Uint128::new(987654321), sender: "local-sender".to_string(), receiver: "remote-rcpt".to_string(), + v: Some(V2), }; let timeout = mock_env().block.time.plus_seconds(DEFAULT_TIMEOUT); assert_eq!( From ada7d114b837313ff95f2d7a9e29a8c3d904d1d9 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Wed, 9 Feb 2022 14:39:53 +0100 Subject: [PATCH 233/352] multi-test: allow type-complexity more granularly --- packages/multi-test/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/multi-test/src/lib.rs b/packages/multi-test/src/lib.rs index 0ee12f501..543f07d3a 100644 --- a/packages/multi-test/src/lib.rs +++ b/packages/multi-test/src/lib.rs @@ -6,10 +6,9 @@ //! //! To understand the design of this module, please refer to `../DESIGN.md` -#![allow(clippy::type_complexity)] - mod app; mod bank; +#[allow(clippy::type_complexity)] mod contracts; pub mod custom_handler; pub mod error; From 6a396ffc8b2b8862d0e6ffe96c6ee5d3191a5830 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Wed, 9 Feb 2022 15:53:21 +0100 Subject: [PATCH 234/352] Set version: 0.12.0 --- Cargo.lock | 40 ++++++++++++------------- contracts/cw1-subkeys/Cargo.toml | 14 ++++----- contracts/cw1-whitelist-ng/Cargo.toml | 14 ++++----- contracts/cw1-whitelist/Cargo.toml | 12 ++++---- contracts/cw1155-base/Cargo.toml | 10 +++---- contracts/cw20-base/Cargo.toml | 10 +++---- contracts/cw20-ics20/Cargo.toml | 12 ++++---- contracts/cw3-fixed-multisig/Cargo.toml | 16 +++++----- contracts/cw3-flex-multisig/Cargo.toml | 18 +++++------ contracts/cw4-group/Cargo.toml | 12 ++++---- contracts/cw4-stake/Cargo.toml | 14 ++++----- packages/controllers/Cargo.toml | 6 ++-- packages/cw1/Cargo.toml | 2 +- packages/cw1155/Cargo.toml | 4 +-- packages/cw2/Cargo.toml | 4 +-- packages/cw20/Cargo.toml | 4 +-- packages/cw3/Cargo.toml | 4 +-- packages/cw4/Cargo.toml | 4 +-- packages/multi-test/Cargo.toml | 6 ++-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 4 +-- 21 files changed, 106 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2ee01f14..5cf6e06fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -377,7 +377,7 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "anyhow", "cosmwasm-std", @@ -394,7 +394,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-std", "criterion", @@ -405,7 +405,7 @@ dependencies = [ [[package]] name = "cw-utils" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -417,7 +417,7 @@ dependencies = [ [[package]] name = "cw1" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -427,7 +427,7 @@ dependencies = [ [[package]] name = "cw1-subkeys" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -444,7 +444,7 @@ dependencies = [ [[package]] name = "cw1-whitelist" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "anyhow", "assert_matches", @@ -463,7 +463,7 @@ dependencies = [ [[package]] name = "cw1-whitelist-ng" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "anyhow", "assert_matches", @@ -482,7 +482,7 @@ dependencies = [ [[package]] name = "cw1155" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -493,7 +493,7 @@ dependencies = [ [[package]] name = "cw1155-base" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -508,7 +508,7 @@ dependencies = [ [[package]] name = "cw2" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -518,7 +518,7 @@ dependencies = [ [[package]] name = "cw20" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -529,7 +529,7 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -544,7 +544,7 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -561,7 +561,7 @@ dependencies = [ [[package]] name = "cw3" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -572,7 +572,7 @@ dependencies = [ [[package]] name = "cw3-fixed-multisig" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -590,7 +590,7 @@ dependencies = [ [[package]] name = "cw3-flex-multisig" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -609,7 +609,7 @@ dependencies = [ [[package]] name = "cw4" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -620,7 +620,7 @@ dependencies = [ [[package]] name = "cw4-group" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -636,7 +636,7 @@ dependencies = [ [[package]] name = "cw4-stake" -version = "0.12.0-alpha2" +version = "0.12.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 6494b5ffa..03d923b1d 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-subkeys" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Implement subkeys for authorizing native tokens as a cw1 proxy contract" @@ -19,12 +19,12 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw1 = { path = "../../packages/cw1", version = "0.12.0-alpha2" } -cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.0-alpha2", features = ["library"] } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw1 = { path = "../../packages/cw1", version = "0.12.0" } +cw2 = { path = "../../packages/cw2", version = "0.12.0" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.0", features = ["library"] } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.23" @@ -32,4 +32,4 @@ semver = "1" [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.0-alpha2", features = ["library", "test-utils"] } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.0", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index b25c75182..b7e9a3b61 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist-ng" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Bartłomiej Kuras "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -22,20 +22,20 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw1 = { path = "../../packages/cw1", version = "0.12.0-alpha2" } -cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw1 = { path = "../../packages/cw1", version = "0.12.0" } +cw2 = { path = "../../packages/cw2", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0-alpha2", optional = true } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0", optional = true } anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0-alpha2" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index d2608ff9e..8410d0bee 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw1 = { path = "../../packages/cw1", version = "0.12.0-alpha2" } -cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw1 = { path = "../../packages/cw1", version = "0.12.0" } +cw2 = { path = "../../packages/cw2", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -32,5 +32,5 @@ thiserror = { version = "1.0.23" } anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0-alpha2" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index e97d4b92c..9debe3838 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155-base" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Huang Yi "] edition = "2018" description = "Basic implementation of a CosmWasm-1155 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } -cw1155 = { path = "../../packages/cw1155", version = "0.12.0-alpha2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw2 = { path = "../../packages/cw2", version = "0.12.0" } +cw1155 = { path = "../../packages/cw1155", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index acf849c4a..f921749f4 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-base" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation of a CosmWasm-20 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } -cw20 = { path = "../../packages/cw20", version = "0.12.0-alpha2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw2 = { path = "../../packages/cw2", version = "0.12.0" } +cw20 = { path = "../../packages/cw20", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 765cc7035..4b7d932c1 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } -cw20 = { path = "../../packages/cw20", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw2 = { path = "../../packages/cw2", version = "0.12.0" } +cw20 = { path = "../../packages/cw20", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3", features = ["stargate"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } -cw-controllers = { path = "../../packages/controllers", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-controllers = { path = "../../packages/controllers", version = "0.12.0" } schemars = "0.8.1" semver = "1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index b3478efdc..549945d60 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-fixed-multisig" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with an fixed group multisig" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } -cw3 = { path = "../../packages/cw3", version = "0.12.0-alpha2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw2 = { path = "../../packages/cw2", version = "0.12.0" } +cw3 = { path = "../../packages/cw3", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -29,6 +29,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw20 = { path = "../../packages/cw20", version = "0.12.0-alpha2" } -cw20-base = { path = "../cw20-base", version = "0.12.0-alpha2", features = ["library"] } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0-alpha2" } +cw20 = { path = "../../packages/cw20", version = "0.12.0" } +cw20-base = { path = "../cw20-base", version = "0.12.0", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 0d5c2fa8f..3d1363329 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-flex-multisig" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with multiple voting patterns and dynamic groups" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } -cw3 = { path = "../../packages/cw3", version = "0.12.0-alpha2" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.12.0-alpha2", features = ["library"] } -cw4 = { path = "../../packages/cw4", version = "0.12.0-alpha2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw2 = { path = "../../packages/cw2", version = "0.12.0" } +cw3 = { path = "../../packages/cw3", version = "0.12.0" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.12.0", features = ["library"] } +cw4 = { path = "../../packages/cw4", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta3" } -cw4-group = { path = "../cw4-group", version = "0.12.0-alpha2" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0-alpha2" } +cw4-group = { path = "../cw4-group", version = "0.12.0" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index 378fbc7d9..f0ac370da 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-group" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Simple cw4 implementation of group membership controlled by admin " @@ -26,11 +26,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } -cw4 = { path = "../../packages/cw4", version = "0.12.0-alpha2" } -cw-controllers = { path = "../../packages/controllers", version = "0.12.0-alpha2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw2 = { path = "../../packages/cw2", version = "0.12.0" } +cw4 = { path = "../../packages/cw4", version = "0.12.0" } +cw-controllers = { path = "../../packages/controllers", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index a6c662025..22236aa80 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-stake" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "CW4 implementation of group based on staked tokens" @@ -26,12 +26,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw2 = { path = "../../packages/cw2", version = "0.12.0-alpha2" } -cw4 = { path = "../../packages/cw4", version = "0.12.0-alpha2" } -cw20 = { path = "../../packages/cw20", version = "0.12.0-alpha2" } -cw-controllers = { path = "../../packages/controllers", version = "0.12.0-alpha2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw2 = { path = "../../packages/cw2", version = "0.12.0" } +cw4 = { path = "../../packages/cw4", version = "0.12.0" } +cw20 = { path = "../../packages/cw20", version = "0.12.0" } +cw-controllers = { path = "../../packages/controllers", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index 1c45b919e..90441dde6 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-controllers" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Common controllers we can reuse in many contracts" @@ -13,8 +13,8 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta3" } -cw-utils = { path = "../utils", version = "0.12.0-alpha2" } -cw-storage-plus = { path = "../storage-plus", version = "0.12.0-alpha2" } +cw-utils = { path = "../utils", version = "0.12.0" } +cw-storage-plus = { path = "../storage-plus", version = "0.12.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index ad9b3130c..b1fe8ab9e 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-1 interface" diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 1eae1e014..77ecaba69 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Huang Yi "] edition = "2018" description = "Definition and types for the CosmWasm-1155 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 6acf2984a..988f9ec33 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw2" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-2 interface" @@ -11,6 +11,6 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta3", default-features = false } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index a72bf47ec..8968aeaf8 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-20 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index 9594a1376..c5666cf58 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-3 Interface: On-Chain MultiSig/Voting contracts" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } +cw-utils = { path = "../../packages/utils", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index a7baca6cd..1149f89c0 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-4 Interface: Groups Members" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-storage-plus = { path = "../storage-plus", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../storage-plus", version = "0.12.0" } cosmwasm-std = { version = "1.0.0-beta3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index fdc5b00d7..fb3d94f56 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-multi-test" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Test helpers for multi-contract interactions" @@ -18,8 +18,8 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0-alpha2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2"} +cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0"} cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } cosmwasm-storage = { version = "1.0.0-beta3" } itertools = "0.10.1" diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 3f5b57a9d..09dd27f7a 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-storage-plus" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Enhanced/experimental storage engines" diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index 61013d1f0..e248bc12b 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-utils" -version = "0.12.0-alpha2" +version = "0.12.0" authors = ["Ethan Frey "] edition = "2018" description = "Common helpers for other cw specs" @@ -18,5 +18,5 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } [dev-dependencies] -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0-alpha2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } prost = "0.9" From 83ec69dfd3ac7d3f809ae9845085bc430d396f63 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Wed, 9 Feb 2022 16:25:33 +0100 Subject: [PATCH 235/352] Update CHANGELOG.md --- CHANGELOG.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02ba4d208..850c883cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,19 +2,44 @@ ## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0-alpha1...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0-alpha2...HEAD) + +**Breaking changes:** + +- Add `proposal_id` field to `VoteInfo` structure [\#647](https://github.com/CosmWasm/cw-plus/issues/647) + +**Merged pull requests:** + +- Ics20 same ack handling as ibctransfer [\#653](https://github.com/CosmWasm/cw-plus/pull/653) ([ethanfrey](https://github.com/ethanfrey)) +- packages: support custom queries [\#652](https://github.com/CosmWasm/cw-plus/pull/652) ([uint](https://github.com/uint)) +- CW20 - Fix Docs URL [\#649](https://github.com/CosmWasm/cw-plus/pull/649) ([entrancedjames](https://github.com/entrancedjames)) + +## [v0.12.0-alpha2](https://github.com/CosmWasm/cw-plus/tree/v0.12.0-alpha2) (2022-02-07) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/juno-ics20...v0.12.0-alpha2) **Closed issues:** - Incorrect Cw4ExecuteMsg used during remove\_hook [\#637](https://github.com/CosmWasm/cw-plus/issues/637) +- \[cw3-flex/fixed-multisig\] Status changes after voting and proposal expiration [\#630](https://github.com/CosmWasm/cw-plus/issues/630) - Make `Bound`s type safe [\#462](https://github.com/CosmWasm/cw-plus/issues/462) **Merged pull requests:** +- CW3: Add proposal\_id field to VoteInfo structure [\#648](https://github.com/CosmWasm/cw-plus/pull/648) ([ueco-jb](https://github.com/ueco-jb)) +- Use ContractInfoResponse from cosmwasm\_std [\#646](https://github.com/CosmWasm/cw-plus/pull/646) ([webmaster128](https://github.com/webmaster128)) +- Fix status/execution bugs in flex-multisig [\#643](https://github.com/CosmWasm/cw-plus/pull/643) ([uint](https://github.com/uint)) +- Set version: 0.12.0-alpha2 [\#642](https://github.com/CosmWasm/cw-plus/pull/642) ([ethanfrey](https://github.com/ethanfrey)) +- Allow modifying admin of Ics20 contract [\#641](https://github.com/CosmWasm/cw-plus/pull/641) ([ethanfrey](https://github.com/ethanfrey)) +- `MIGRATING.md` update / examples for type safe bounds [\#640](https://github.com/CosmWasm/cw-plus/pull/640) ([maurolacy](https://github.com/maurolacy)) - Fix benchmarks \(after 1.58.1 update\) [\#639](https://github.com/CosmWasm/cw-plus/pull/639) ([maurolacy](https://github.com/maurolacy)) - Fix `remove_hook` helper [\#638](https://github.com/CosmWasm/cw-plus/pull/638) ([maurolacy](https://github.com/maurolacy)) - Type safe bounds [\#627](https://github.com/CosmWasm/cw-plus/pull/627) ([maurolacy](https://github.com/maurolacy)) +## [juno-ics20](https://github.com/CosmWasm/cw-plus/tree/juno-ics20) (2022-01-27) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0-alpha1...juno-ics20) + ## [v0.12.0-alpha1](https://github.com/CosmWasm/cw-plus/tree/v0.12.0-alpha1) (2022-01-27) [Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.11.1...v0.12.0-alpha1) From c9870f2f8fecfff566d952fbeb3f87174528aa45 Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Wed, 9 Feb 2022 18:43:55 +0100 Subject: [PATCH 236/352] Correct CHANGELOG --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 850c883cf..951033905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,10 +36,6 @@ - Fix `remove_hook` helper [\#638](https://github.com/CosmWasm/cw-plus/pull/638) ([maurolacy](https://github.com/maurolacy)) - Type safe bounds [\#627](https://github.com/CosmWasm/cw-plus/pull/627) ([maurolacy](https://github.com/maurolacy)) -## [juno-ics20](https://github.com/CosmWasm/cw-plus/tree/juno-ics20) (2022-01-27) - -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0-alpha1...juno-ics20) - ## [v0.12.0-alpha1](https://github.com/CosmWasm/cw-plus/tree/v0.12.0-alpha1) (2022-01-27) [Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.11.1...v0.12.0-alpha1) From 35bc319c01a5a331238e34535e274b96dce0fba8 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 12 Feb 2022 14:44:31 +0100 Subject: [PATCH 237/352] query_admin: support custom queries --- packages/controllers/src/admin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/controllers/src/admin.rs b/packages/controllers/src/admin.rs index 49cef71cf..e503747a1 100644 --- a/packages/controllers/src/admin.rs +++ b/packages/controllers/src/admin.rs @@ -91,7 +91,7 @@ impl<'a> Admin<'a> { Ok(Response::new().add_attributes(attributes)) } - pub fn query_admin(&self, deps: Deps) -> StdResult { + pub fn query_admin(&self, deps: Deps) -> StdResult { let admin = self.get(deps)?.map(String::from); Ok(AdminResponse { admin }) } From 47d10aaa57186120b8205dc26000f92b4b2fade6 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 12 Feb 2022 15:37:01 +0100 Subject: [PATCH 238/352] Fix: Forward original errors through anyhow in instantiate, execute, query --- packages/multi-test/src/app.rs | 24 ++++++++++++------------ packages/multi-test/src/contracts.rs | 23 ++++------------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index f06ba6ac4..24f9be992 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -2604,9 +2604,9 @@ mod test { panic!("wrong StdError variant"); } - // we're expecting exactly 3 nested error types - // (the original error, initiate msg context, WasmMsg context) - assert_eq!(err.chain().count(), 3); + // We're expecting exactly 2 nested error types + // (the original error, WasmMsg context) + assert_eq!(err.chain().count(), 2); } #[test] @@ -2634,9 +2634,9 @@ mod test { panic!("wrong StdError variant"); } - // we're expecting exactly 3 nested error types - // (the original error, execute msg context, WasmMsg context) - assert_eq!(err.chain().count(), 3); + // We're expecting exactly 2 nested error types + // (the original error, WasmMsg context) + assert_eq!(err.chain().count(), 2); } #[test] @@ -2674,9 +2674,9 @@ mod test { panic!("wrong StdError variant"); } - // we're expecting exactly 4 nested error types - // (the original error, execute msg context, 2 WasmMsg contexts) - assert_eq!(err.chain().count(), 4); + // We're expecting exactly 3 nested error types + // (the original error, 2 WasmMsg contexts) + assert_eq!(err.chain().count(), 3); } #[test] @@ -2725,9 +2725,9 @@ mod test { panic!("wrong StdError variant"); } - // we're expecting exactly 5 nested error types - // (the original error, execute msg context, 3 WasmMsg contexts) - assert_eq!(err.chain().count(), 5); + // We're expecting exactly 4 nested error types + // (the original error, 3 WasmMsg contexts) + assert_eq!(err.chain().count(), 4); } } } diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index 72bf76950..03c06bdc6 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -8,7 +8,7 @@ use cosmwasm_std::{ Response, SubMsg, }; -use anyhow::{anyhow, bail, Context, Result as AnyResult}; +use anyhow::{anyhow, bail, Result as AnyResult}; /// Interface to call into a Contract pub trait Contract @@ -349,12 +349,7 @@ where msg: Vec, ) -> AnyResult> { let msg: T1 = from_slice(&msg)?; - (self.execute_fn)(deps, env, info, msg.clone()) - .map_err(anyhow::Error::from) - .context(format!( - "Contract returned an error on execute msg:\n{:?}", - msg, - )) + (self.execute_fn)(deps, env, info, msg).map_err(|err| anyhow!(err)) } fn instantiate( @@ -365,22 +360,12 @@ where msg: Vec, ) -> AnyResult> { let msg: T2 = from_slice(&msg)?; - (self.instantiate_fn)(deps, env, info, msg.clone()) - .map_err(anyhow::Error::from) - .context(format!( - "Contract returned an error on instantiate msg:\n{:?}", - msg, - )) + (self.instantiate_fn)(deps, env, info, msg).map_err(|err| anyhow!(err)) } fn query(&self, deps: Deps, env: Env, msg: Vec) -> AnyResult { let msg: T3 = from_slice(&msg)?; - (self.query_fn)(deps, env, msg.clone()) - .map_err(anyhow::Error::from) - .context(format!( - "Contract returned an error on query msg:\n{:?}", - msg, - )) + (self.query_fn)(deps, env, msg).map_err(|err| anyhow!(err)) } // this returns an error if the contract doesn't implement sudo From 3da0e9058d1b80effbe51cef67043ce48328ed22 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 11 Feb 2022 22:54:00 +0100 Subject: [PATCH 239/352] Fix type annotations for IndexedMap/IndexedSnapshotMap prefixes --- packages/storage-plus/src/indexed_map.rs | 4 ++-- packages/storage-plus/src/indexed_snapshot.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 4033f2606..ee68c7549 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -172,11 +172,11 @@ where K: PrimaryKey<'a>, I: IndexList, { - pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { + pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { Prefix::new(self.pk_namespace, &p.prefix()) } - pub fn prefix(&self, p: K::Prefix) -> Prefix { + pub fn prefix(&self, p: K::Prefix) -> Prefix { Prefix::new(self.pk_namespace, &p.prefix()) } } diff --git a/packages/storage-plus/src/indexed_snapshot.rs b/packages/storage-plus/src/indexed_snapshot.rs index 60029b1b0..2b152abb3 100644 --- a/packages/storage-plus/src/indexed_snapshot.rs +++ b/packages/storage-plus/src/indexed_snapshot.rs @@ -225,11 +225,11 @@ where K: PrimaryKey<'a>, I: IndexList, { - pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { + pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix { Prefix::new(self.pk_namespace, &p.prefix()) } - pub fn prefix(&self, p: K::Prefix) -> Prefix { + pub fn prefix(&self, p: K::Prefix) -> Prefix { Prefix::new(self.pk_namespace, &p.prefix()) } } From ea6601ebfc694839b42f20dd33a2aa1fa215b1c8 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sat, 12 Feb 2022 19:32:34 +0100 Subject: [PATCH 240/352] Fix type annotations for MultiIndex prefixes --- packages/storage-plus/src/indexes/multi.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 89209718a..7cd7b4ebd 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -250,7 +250,7 @@ where T: Serialize + DeserializeOwned + Clone, IK: PrimaryKey<'a> + Prefixer<'a>, { - pub fn prefix(&self, p: IK) -> Prefix { + pub fn prefix(&self, p: IK) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), @@ -260,7 +260,7 @@ where ) } - pub fn sub_prefix(&self, p: IK::Prefix) -> Prefix { + pub fn sub_prefix(&self, p: IK::Prefix) -> Prefix { Prefix::with_deserialization_functions( self.idx_namespace, &p.prefix(), From 4dccbc45a49605e38d1879b2731a3a96c95fa9f0 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 13 Feb 2022 19:51:45 +0100 Subject: [PATCH 241/352] Update cosmwasm deps to latest version --- Cargo.lock | 20 ++++++++++---------- contracts/cw1-subkeys/Cargo.toml | 4 ++-- contracts/cw1-whitelist-ng/Cargo.toml | 4 ++-- contracts/cw1-whitelist/Cargo.toml | 4 ++-- contracts/cw1155-base/Cargo.toml | 4 ++-- contracts/cw20-base/Cargo.toml | 4 ++-- contracts/cw20-ics20/Cargo.toml | 4 ++-- contracts/cw3-fixed-multisig/Cargo.toml | 4 ++-- contracts/cw3-flex-multisig/Cargo.toml | 4 ++-- contracts/cw4-group/Cargo.toml | 4 ++-- contracts/cw4-stake/Cargo.toml | 4 ++-- packages/controllers/Cargo.toml | 2 +- packages/cw1/Cargo.toml | 4 ++-- packages/cw1155/Cargo.toml | 4 ++-- packages/cw2/Cargo.toml | 2 +- packages/cw20/Cargo.toml | 4 ++-- packages/cw3/Cargo.toml | 4 ++-- packages/cw4/Cargo.toml | 4 ++-- packages/multi-test/Cargo.toml | 4 ++-- packages/storage-plus/Cargo.toml | 4 ++-- packages/utils/Cargo.toml | 2 +- 21 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5cf6e06fe..559efead0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -155,9 +155,9 @@ checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" [[package]] name = "cosmwasm-crypto" -version = "1.0.0-beta3" +version = "1.0.0-beta5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a380b87642204557629c9b72988c47b55fbfe6d474960adba56b22331504956a" +checksum = "8904127a5b9e325ef5d6b2b3f997dcd74943cd35097139b1a4d15b1b6bccae66" dependencies = [ "digest", "ed25519-zebra", @@ -168,18 +168,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.0.0-beta3" +version = "1.0.0-beta5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "866713b2fe13f23038c7d8824c3059d1f28dd94685fb406d1533c4eeeefeefae" +checksum = "a14364ac4d9d085867929d0cf3e94b1d2100121ce02c33c72961406830002613" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.0.0-beta3" +version = "1.0.0-beta5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "818b928263c09a3269c2bed22494a62107a43ef87900e273af8ad2cb9f7e4440" +checksum = "3b2941b87c42620d348e96ed05876bfda0dc1d5454a646d780d32f114c04921d" dependencies = [ "schemars", "serde_json", @@ -187,9 +187,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.0.0-beta3" +version = "1.0.0-beta5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dbb9939b31441dfa9af3ec9740c8a24d585688401eff1b6b386abb7ad0d10a8" +checksum = "e2ece12e5bbde434b93937d7b2107e6291f11d69ffa72398c50e8bab41d451d3" dependencies = [ "base64", "cosmwasm-crypto", @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.0.0-beta3" +version = "1.0.0-beta5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4a4e55f0d64fed54cd2202301b8d466af8de044589247dabd77a4222f52f749" +checksum = "e7e4338d8e9934effa4594f139ce4e5f4b426796b70e2d53bb7e8605e9adf68c" dependencies = [ "cosmwasm-std", "serde", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 03d923b1d..a4d7abeae 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -23,7 +23,7 @@ cw-utils = { path = "../../packages/utils", version = "0.12.0" } cw1 = { path = "../../packages/cw1", version = "0.12.0" } cw2 = { path = "../../packages/cw2", version = "0.12.0" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.0", features = ["library"] } -cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = "1.0.23" semver = "1" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.0", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index b7e9a3b61..30684f583 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -25,7 +25,7 @@ multitest = ["cw-multi-test", "anyhow"] cw-utils = { path = "../../packages/utils", version = "0.12.0" } cw1 = { path = "../../packages/cw1", version = "0.12.0" } cw2 = { path = "../../packages/cw2", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -36,6 +36,6 @@ anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index 8410d0bee..d05c32ad0 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -22,7 +22,7 @@ test-utils = [] cw-utils = { path = "../../packages/utils", version = "0.12.0" } cw1 = { path = "../../packages/cw1", version = "0.12.0" } cw2 = { path = "../../packages/cw2", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,6 +31,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] anyhow = "1" assert_matches = "1" -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 9debe3838..9b736dab9 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -22,10 +22,10 @@ cw-utils = { path = "../../packages/utils", version = "0.12.0" } cw2 = { path = "../../packages/cw2", version = "0.12.0" } cw1155 = { path = "../../packages/cw1155", version = "0.12.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index f921749f4..2e28c0ede 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -22,10 +22,10 @@ cw-utils = { path = "../../packages/utils", version = "0.12.0" } cw2 = { path = "../../packages/cw2", version = "0.12.0" } cw20 = { path = "../../packages/cw20", version = "0.12.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 4b7d932c1..e86437de4 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -21,7 +21,7 @@ library = [] cw-utils = { path = "../../packages/utils", version = "0.12.0" } cw2 = { path = "../../packages/cw2", version = "0.12.0" } cw20 = { path = "../../packages/cw20", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3", features = ["stargate"] } +cosmwasm-std = { version = "1.0.0-beta5", features = ["stargate"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } cw-controllers = { path = "../../packages/controllers", version = "0.12.0" } schemars = "0.8.1" @@ -30,4 +30,4 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index 549945d60..8f46b3d23 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -22,13 +22,13 @@ cw-utils = { path = "../../packages/utils", version = "0.12.0" } cw2 = { path = "../../packages/cw2", version = "0.12.0" } cw3 = { path = "../../packages/cw3", version = "0.12.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } cw20 = { path = "../../packages/cw20", version = "0.12.0" } cw20-base = { path = "../cw20-base", version = "0.12.0", features = ["library"] } cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 3d1363329..bc75ce90a 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -24,12 +24,12 @@ cw3 = { path = "../../packages/cw3", version = "0.12.0" } cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.12.0", features = ["library"] } cw4 = { path = "../../packages/cw4", version = "0.12.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } cw4-group = { path = "../cw4-group", version = "0.12.0" } cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index f0ac370da..e64646d4c 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -31,10 +31,10 @@ cw2 = { path = "../../packages/cw2", version = "0.12.0" } cw4 = { path = "../../packages/cw4", version = "0.12.0" } cw-controllers = { path = "../../packages/controllers", version = "0.12.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index 22236aa80..27b1b90c5 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -32,10 +32,10 @@ cw4 = { path = "../../packages/cw4", version = "0.12.0" } cw20 = { path = "../../packages/cw20", version = "0.12.0" } cw-controllers = { path = "../../packages/controllers", version = "0.12.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index 90441dde6..e72af5a7c 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -12,7 +12,7 @@ documentation = "https://docs.cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } cw-utils = { path = "../utils", version = "0.12.0" } cw-storage-plus = { path = "../storage-plus", version = "0.12.0" } schemars = "0.8.1" diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index b1fe8ab9e..1dc3a5eec 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -10,9 +10,9 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 77ecaba69..ec3f4d82b 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 988f9ec33..462b15b1a 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0-beta3", default-features = false } +cosmwasm-std = { version = "1.0.0-beta5", default-features = false } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index 8968aeaf8..a1584f630 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index c5666cf58..e42adfe8b 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index 1149f89c0..0c2783953 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-storage-plus = { path = "../storage-plus", version = "0.12.0" } -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta3" } +cosmwasm-schema = { version = "1.0.0-beta5" } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index fb3d94f56..52d33e018 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -20,8 +20,8 @@ backtrace = ["anyhow/backtrace"] [dependencies] cw-utils = { path = "../../packages/utils", version = "0.12.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0"} -cosmwasm-std = { version = "1.0.0-beta3", features = ["staking"] } -cosmwasm-storage = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } +cosmwasm-storage = { version = "1.0.0-beta5" } itertools = "0.10.1" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 09dd27f7a..926b7ad33 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -18,7 +18,7 @@ iterator = ["cosmwasm-std/iterator"] bench = false [dependencies] -cosmwasm-std = { version = "1.0.0-beta3", default-features = false } +cosmwasm-std = { version = "1.0.0-beta5", default-features = false } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -28,4 +28,4 @@ rand = "0.8" [[bench]] name = "main" -harness = false \ No newline at end of file +harness = false diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index e248bc12b..e452bc7e8 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -12,7 +12,7 @@ documentation = "https://docs.cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0-beta3" } +cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } From d8961d746f93b9f09dbe140320ab0d5d77367ed0 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 14 Feb 2022 09:33:27 +0100 Subject: [PATCH 242/352] Set version: 0.12.1 --- Cargo.lock | 40 ++++++++++++------------- contracts/cw1-subkeys/Cargo.toml | 14 ++++----- contracts/cw1-whitelist-ng/Cargo.toml | 14 ++++----- contracts/cw1-whitelist/Cargo.toml | 12 ++++---- contracts/cw1155-base/Cargo.toml | 10 +++---- contracts/cw20-base/Cargo.toml | 10 +++---- contracts/cw20-ics20/Cargo.toml | 12 ++++---- contracts/cw3-fixed-multisig/Cargo.toml | 16 +++++----- contracts/cw3-flex-multisig/Cargo.toml | 18 +++++------ contracts/cw4-group/Cargo.toml | 12 ++++---- contracts/cw4-stake/Cargo.toml | 14 ++++----- packages/controllers/Cargo.toml | 6 ++-- packages/cw1/Cargo.toml | 2 +- packages/cw1155/Cargo.toml | 4 +-- packages/cw2/Cargo.toml | 4 +-- packages/cw20/Cargo.toml | 4 +-- packages/cw3/Cargo.toml | 4 +-- packages/cw4/Cargo.toml | 4 +-- packages/multi-test/Cargo.toml | 6 ++-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 4 +-- 21 files changed, 106 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 559efead0..b8c948bff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -377,7 +377,7 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.12.0" +version = "0.12.1" dependencies = [ "anyhow", "cosmwasm-std", @@ -394,7 +394,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-std", "criterion", @@ -405,7 +405,7 @@ dependencies = [ [[package]] name = "cw-utils" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -417,7 +417,7 @@ dependencies = [ [[package]] name = "cw1" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -427,7 +427,7 @@ dependencies = [ [[package]] name = "cw1-subkeys" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -444,7 +444,7 @@ dependencies = [ [[package]] name = "cw1-whitelist" -version = "0.12.0" +version = "0.12.1" dependencies = [ "anyhow", "assert_matches", @@ -463,7 +463,7 @@ dependencies = [ [[package]] name = "cw1-whitelist-ng" -version = "0.12.0" +version = "0.12.1" dependencies = [ "anyhow", "assert_matches", @@ -482,7 +482,7 @@ dependencies = [ [[package]] name = "cw1155" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -493,7 +493,7 @@ dependencies = [ [[package]] name = "cw1155-base" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -508,7 +508,7 @@ dependencies = [ [[package]] name = "cw2" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -518,7 +518,7 @@ dependencies = [ [[package]] name = "cw20" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -529,7 +529,7 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -544,7 +544,7 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -561,7 +561,7 @@ dependencies = [ [[package]] name = "cw3" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -572,7 +572,7 @@ dependencies = [ [[package]] name = "cw3-fixed-multisig" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -590,7 +590,7 @@ dependencies = [ [[package]] name = "cw3-flex-multisig" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -609,7 +609,7 @@ dependencies = [ [[package]] name = "cw4" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -620,7 +620,7 @@ dependencies = [ [[package]] name = "cw4-group" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -636,7 +636,7 @@ dependencies = [ [[package]] name = "cw4-stake" -version = "0.12.0" +version = "0.12.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index a4d7abeae..db313da0a 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-subkeys" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Implement subkeys for authorizing native tokens as a cw1 proxy contract" @@ -19,12 +19,12 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw1 = { path = "../../packages/cw1", version = "0.12.0" } -cw2 = { path = "../../packages/cw2", version = "0.12.0" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.0", features = ["library"] } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw1 = { path = "../../packages/cw1", version = "0.12.1" } +cw2 = { path = "../../packages/cw2", version = "0.12.1" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.1", features = ["library"] } cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.23" @@ -32,4 +32,4 @@ semver = "1" [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta5" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.0", features = ["library", "test-utils"] } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.1", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index 30684f583..89e20e1e9 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist-ng" -version = "0.12.0" +version = "0.12.1" authors = ["Bartłomiej Kuras "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -22,20 +22,20 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw1 = { path = "../../packages/cw1", version = "0.12.0" } -cw2 = { path = "../../packages/cw2", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw1 = { path = "../../packages/cw1", version = "0.12.1" } +cw2 = { path = "../../packages/cw2", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0", optional = true } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1", optional = true } anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta5" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index d05c32ad0..ac7e9ed28 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw1 = { path = "../../packages/cw1", version = "0.12.0" } -cw2 = { path = "../../packages/cw2", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw1 = { path = "../../packages/cw1", version = "0.12.1" } +cw2 = { path = "../../packages/cw2", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -32,5 +32,5 @@ thiserror = { version = "1.0.23" } anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta5" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 9b736dab9..e6197e527 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155-base" -version = "0.12.0" +version = "0.12.1" authors = ["Huang Yi "] edition = "2018" description = "Basic implementation of a CosmWasm-1155 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw2 = { path = "../../packages/cw2", version = "0.12.0" } -cw1155 = { path = "../../packages/cw1155", version = "0.12.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw2 = { path = "../../packages/cw2", version = "0.12.1" } +cw1155 = { path = "../../packages/cw1155", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index 2e28c0ede..03acef104 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-base" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation of a CosmWasm-20 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw2 = { path = "../../packages/cw2", version = "0.12.0" } -cw20 = { path = "../../packages/cw20", version = "0.12.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw2 = { path = "../../packages/cw2", version = "0.12.1" } +cw20 = { path = "../../packages/cw20", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index e86437de4..2b10d4857 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw2 = { path = "../../packages/cw2", version = "0.12.0" } -cw20 = { path = "../../packages/cw20", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw2 = { path = "../../packages/cw2", version = "0.12.1" } +cw20 = { path = "../../packages/cw20", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5", features = ["stargate"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } -cw-controllers = { path = "../../packages/controllers", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-controllers = { path = "../../packages/controllers", version = "0.12.1" } schemars = "0.8.1" semver = "1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index 8f46b3d23..b1388a00b 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-fixed-multisig" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with an fixed group multisig" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw2 = { path = "../../packages/cw2", version = "0.12.0" } -cw3 = { path = "../../packages/cw3", version = "0.12.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw2 = { path = "../../packages/cw2", version = "0.12.1" } +cw3 = { path = "../../packages/cw3", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -29,6 +29,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta5" } -cw20 = { path = "../../packages/cw20", version = "0.12.0" } -cw20-base = { path = "../cw20-base", version = "0.12.0", features = ["library"] } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } +cw20 = { path = "../../packages/cw20", version = "0.12.1" } +cw20-base = { path = "../cw20-base", version = "0.12.1", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index bc75ce90a..e4f032420 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-flex-multisig" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with multiple voting patterns and dynamic groups" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw2 = { path = "../../packages/cw2", version = "0.12.0" } -cw3 = { path = "../../packages/cw3", version = "0.12.0" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.12.0", features = ["library"] } -cw4 = { path = "../../packages/cw4", version = "0.12.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw2 = { path = "../../packages/cw2", version = "0.12.1" } +cw3 = { path = "../../packages/cw3", version = "0.12.1" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.12.1", features = ["library"] } +cw4 = { path = "../../packages/cw4", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta5" } -cw4-group = { path = "../cw4-group", version = "0.12.0" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.0" } +cw4-group = { path = "../cw4-group", version = "0.12.1" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index e64646d4c..b2038f155 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-group" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Simple cw4 implementation of group membership controlled by admin " @@ -26,11 +26,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw2 = { path = "../../packages/cw2", version = "0.12.0" } -cw4 = { path = "../../packages/cw4", version = "0.12.0" } -cw-controllers = { path = "../../packages/controllers", version = "0.12.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw2 = { path = "../../packages/cw2", version = "0.12.1" } +cw4 = { path = "../../packages/cw4", version = "0.12.1" } +cw-controllers = { path = "../../packages/controllers", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index 27b1b90c5..a3086f48c 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-stake" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "CW4 implementation of group based on staked tokens" @@ -26,12 +26,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw2 = { path = "../../packages/cw2", version = "0.12.0" } -cw4 = { path = "../../packages/cw4", version = "0.12.0" } -cw20 = { path = "../../packages/cw20", version = "0.12.0" } -cw-controllers = { path = "../../packages/controllers", version = "0.12.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw2 = { path = "../../packages/cw2", version = "0.12.1" } +cw4 = { path = "../../packages/cw4", version = "0.12.1" } +cw20 = { path = "../../packages/cw20", version = "0.12.1" } +cw-controllers = { path = "../../packages/controllers", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index e72af5a7c..17ee89281 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-controllers" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Common controllers we can reuse in many contracts" @@ -13,8 +13,8 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta5" } -cw-utils = { path = "../utils", version = "0.12.0" } -cw-storage-plus = { path = "../storage-plus", version = "0.12.0" } +cw-utils = { path = "../utils", version = "0.12.1" } +cw-storage-plus = { path = "../storage-plus", version = "0.12.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index 1dc3a5eec..8b3017c2d 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-1 interface" diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index ec3f4d82b..e81f36c92 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155" -version = "0.12.0" +version = "0.12.1" authors = ["Huang Yi "] edition = "2018" description = "Definition and types for the CosmWasm-1155 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 462b15b1a..675d2ecfe 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw2" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-2 interface" @@ -11,6 +11,6 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta5", default-features = false } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index a1584f630..c24708e85 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-20 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index e42adfe8b..98dcc64af 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-3 Interface: On-Chain MultiSig/Voting contracts" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } +cw-utils = { path = "../../packages/utils", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index 0c2783953..77c20b649 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-4 Interface: Groups Members" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-storage-plus = { path = "../storage-plus", version = "0.12.0" } +cw-storage-plus = { path = "../storage-plus", version = "0.12.1" } cosmwasm-std = { version = "1.0.0-beta5" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index 52d33e018..f39042c1d 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-multi-test" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Test helpers for multi-contract interactions" @@ -18,8 +18,8 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0"} +cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1"} cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } cosmwasm-storage = { version = "1.0.0-beta5" } itertools = "0.10.1" diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 926b7ad33..1e22dd983 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-storage-plus" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Enhanced/experimental storage engines" diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index e452bc7e8..f2ab10026 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-utils" -version = "0.12.0" +version = "0.12.1" authors = ["Ethan Frey "] edition = "2018" description = "Common helpers for other cw specs" @@ -18,5 +18,5 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } [dev-dependencies] -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } prost = "0.9" From fbf5617099f65d12b50f19b41ad3b455c241c505 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 14 Feb 2022 09:38:10 +0100 Subject: [PATCH 243/352] cargo update --- Cargo.lock | 110 ++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8c948bff..b8c4ce5e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "anyhow" -version = "1.0.51" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" +checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" dependencies = [ "backtrace", ] @@ -45,15 +45,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" +checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f" dependencies = [ "addr2line", "cc", @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.8.0" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" [[package]] name = "byteorder" @@ -258,9 +258,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" dependencies = [ "cfg-if", "crossbeam-utils", @@ -279,9 +279,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9" dependencies = [ "cfg-if", "crossbeam-utils", @@ -292,9 +292,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" dependencies = [ "cfg-if", "lazy_static", @@ -746,9 +746,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" dependencies = [ "typenum", "version_check", @@ -767,9 +767,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" dependencies = [ "cfg-if", "libc", @@ -847,9 +847,9 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "js-sys" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" dependencies = [ "wasm-bindgen", ] @@ -874,9 +874,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.112" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" [[package]] name = "log" @@ -998,9 +998,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "proc-macro2" -version = "1.0.34" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] @@ -1030,9 +1030,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.10" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" dependencies = [ "proc-macro2", ] @@ -1074,7 +1074,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.3", + "getrandom 0.2.4", ] [[package]] @@ -1194,15 +1194,15 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" +checksum = "0486718e92ec9a68fbed73bb5ef687d71103b142595b406835649bebd33f72c7" [[package]] name = "serde" -version = "1.0.132" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" dependencies = [ "serde_derive", ] @@ -1228,9 +1228,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.132" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -1250,9 +1250,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.73" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ "itoa 1.0.1", "ryu", @@ -1261,9 +1261,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer", "cfg-if", @@ -1305,9 +1305,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" dependencies = [ "proc-macro2", "quote", @@ -1355,9 +1355,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "uint" @@ -1385,9 +1385,9 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" @@ -1414,9 +1414,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1424,9 +1424,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" dependencies = [ "bumpalo", "lazy_static", @@ -1439,9 +1439,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1449,9 +1449,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" dependencies = [ "proc-macro2", "quote", @@ -1462,15 +1462,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" +checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" [[package]] name = "web-sys" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" dependencies = [ "js-sys", "wasm-bindgen", From b6d804c687b4d27f86d265270c77537ef527f5de Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 14 Feb 2022 09:44:34 +0100 Subject: [PATCH 244/352] Update CHANGELOG --- CHANGELOG.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 951033905..e42ea3b2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,39 @@ ## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0-alpha2...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0-alpha3...HEAD) + +**Merged pull requests:** + +- Fix missing custom query [\#657](https://github.com/CosmWasm/cw-plus/pull/657) ([maurolacy](https://github.com/maurolacy)) +- Forward original errors in multitest `instantiate`, `execute` and `query` [\#656](https://github.com/CosmWasm/cw-plus/pull/656) ([maurolacy](https://github.com/maurolacy)) +- Fix missing prefix bound types [\#655](https://github.com/CosmWasm/cw-plus/pull/655) ([maurolacy](https://github.com/maurolacy)) + +## [v0.12.0-alpha3](https://github.com/CosmWasm/cw-plus/tree/v0.12.0-alpha3) (2022-02-10) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0...v0.12.0-alpha3) + +## [v0.12.0](https://github.com/CosmWasm/cw-plus/tree/v0.12.0) (2022-02-09) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0-alpha2...v0.12.0) **Breaking changes:** - Add `proposal_id` field to `VoteInfo` structure [\#647](https://github.com/CosmWasm/cw-plus/issues/647) +**Deprecated:** + +- Remove `IntKey` with surrounding implementation [\#570](https://github.com/CosmWasm/cw-plus/issues/570) + +**Closed issues:** + +- Move all cw20 examples to new repo [\#578](https://github.com/CosmWasm/cw-plus/issues/578) +- Add more debug output from multi-test [\#575](https://github.com/CosmWasm/cw-plus/issues/575) +- Make `Bound`s type safe [\#462](https://github.com/CosmWasm/cw-plus/issues/462) + **Merged pull requests:** +- Prepare release v0.12.0 [\#654](https://github.com/CosmWasm/cw-plus/pull/654) ([uint](https://github.com/uint)) - Ics20 same ack handling as ibctransfer [\#653](https://github.com/CosmWasm/cw-plus/pull/653) ([ethanfrey](https://github.com/ethanfrey)) - packages: support custom queries [\#652](https://github.com/CosmWasm/cw-plus/pull/652) ([uint](https://github.com/uint)) - CW20 - Fix Docs URL [\#649](https://github.com/CosmWasm/cw-plus/pull/649) ([entrancedjames](https://github.com/entrancedjames)) From 0383c6462bb463f82fe08af566863b803d97cc29 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 14 Feb 2022 09:47:24 +0100 Subject: [PATCH 245/352] Consolidate v0.12.0 entries --- CHANGELOG.md | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e42ea3b2b..5d7701510 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0-alpha3...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0...HEAD) **Merged pull requests:** @@ -10,13 +10,9 @@ - Forward original errors in multitest `instantiate`, `execute` and `query` [\#656](https://github.com/CosmWasm/cw-plus/pull/656) ([maurolacy](https://github.com/maurolacy)) - Fix missing prefix bound types [\#655](https://github.com/CosmWasm/cw-plus/pull/655) ([maurolacy](https://github.com/maurolacy)) -## [v0.12.0-alpha3](https://github.com/CosmWasm/cw-plus/tree/v0.12.0-alpha3) (2022-02-10) - -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0...v0.12.0-alpha3) - ## [v0.12.0](https://github.com/CosmWasm/cw-plus/tree/v0.12.0) (2022-02-09) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0-alpha2...v0.12.0) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.11.1...v0.12.0) **Breaking changes:** @@ -31,6 +27,11 @@ - Move all cw20 examples to new repo [\#578](https://github.com/CosmWasm/cw-plus/issues/578) - Add more debug output from multi-test [\#575](https://github.com/CosmWasm/cw-plus/issues/575) - Make `Bound`s type safe [\#462](https://github.com/CosmWasm/cw-plus/issues/462) +- Incorrect Cw4ExecuteMsg used during remove\_hook [\#637](https://github.com/CosmWasm/cw-plus/issues/637) +- \[cw3-flex/fixed-multisig\] Status changes after voting and proposal expiration [\#630](https://github.com/CosmWasm/cw-plus/issues/630) +- Make `Bound`s type safe [\#462](https://github.com/CosmWasm/cw-plus/issues/462) +- Move all cw20 examples to new repo [\#578](https://github.com/CosmWasm/cw-plus/issues/578) +- Add more debug output from multi-test [\#575](https://github.com/CosmWasm/cw-plus/issues/575) **Merged pull requests:** @@ -38,19 +39,6 @@ - Ics20 same ack handling as ibctransfer [\#653](https://github.com/CosmWasm/cw-plus/pull/653) ([ethanfrey](https://github.com/ethanfrey)) - packages: support custom queries [\#652](https://github.com/CosmWasm/cw-plus/pull/652) ([uint](https://github.com/uint)) - CW20 - Fix Docs URL [\#649](https://github.com/CosmWasm/cw-plus/pull/649) ([entrancedjames](https://github.com/entrancedjames)) - -## [v0.12.0-alpha2](https://github.com/CosmWasm/cw-plus/tree/v0.12.0-alpha2) (2022-02-07) - -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/juno-ics20...v0.12.0-alpha2) - -**Closed issues:** - -- Incorrect Cw4ExecuteMsg used during remove\_hook [\#637](https://github.com/CosmWasm/cw-plus/issues/637) -- \[cw3-flex/fixed-multisig\] Status changes after voting and proposal expiration [\#630](https://github.com/CosmWasm/cw-plus/issues/630) -- Make `Bound`s type safe [\#462](https://github.com/CosmWasm/cw-plus/issues/462) - -**Merged pull requests:** - - CW3: Add proposal\_id field to VoteInfo structure [\#648](https://github.com/CosmWasm/cw-plus/pull/648) ([ueco-jb](https://github.com/ueco-jb)) - Use ContractInfoResponse from cosmwasm\_std [\#646](https://github.com/CosmWasm/cw-plus/pull/646) ([webmaster128](https://github.com/webmaster128)) - Fix status/execution bugs in flex-multisig [\#643](https://github.com/CosmWasm/cw-plus/pull/643) ([uint](https://github.com/uint)) @@ -60,22 +48,6 @@ - Fix benchmarks \(after 1.58.1 update\) [\#639](https://github.com/CosmWasm/cw-plus/pull/639) ([maurolacy](https://github.com/maurolacy)) - Fix `remove_hook` helper [\#638](https://github.com/CosmWasm/cw-plus/pull/638) ([maurolacy](https://github.com/maurolacy)) - Type safe bounds [\#627](https://github.com/CosmWasm/cw-plus/pull/627) ([maurolacy](https://github.com/maurolacy)) - -## [v0.12.0-alpha1](https://github.com/CosmWasm/cw-plus/tree/v0.12.0-alpha1) (2022-01-27) - -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.11.1...v0.12.0-alpha1) - -**Deprecated:** - -- Remove `IntKey` with surrounding implementation [\#570](https://github.com/CosmWasm/cw-plus/issues/570) - -**Closed issues:** - -- Move all cw20 examples to new repo [\#578](https://github.com/CosmWasm/cw-plus/issues/578) -- Add more debug output from multi-test [\#575](https://github.com/CosmWasm/cw-plus/issues/575) - -**Merged pull requests:** - - Update Rust to v1.54.0 in CI [\#636](https://github.com/CosmWasm/cw-plus/pull/636) ([maurolacy](https://github.com/maurolacy)) - Refactor cw2 spec readme [\#635](https://github.com/CosmWasm/cw-plus/pull/635) ([orkunkl](https://github.com/orkunkl)) - Fix tag consolidation for matching CHANGELOG entries [\#634](https://github.com/CosmWasm/cw-plus/pull/634) ([maurolacy](https://github.com/maurolacy)) From d2ff1083c986ff0fe186db494e8ebaf295938cfe Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 14 Feb 2022 09:48:21 +0100 Subject: [PATCH 246/352] Add entry for upcoming v0.12.1 --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7701510..731c7c808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,11 @@ ## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.1...HEAD) + +## [v0.12.1](https://github.com/CosmWasm/cw-plus/tree/v0.12.1) (2022-02-14) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0...v0.12.1) **Merged pull requests:** From 94bcbc600d6bdace4ddc69d7b93fea3c7b354fb3 Mon Sep 17 00:00:00 2001 From: Harry Scholes Date: Tue, 15 Feb 2022 12:51:48 +0200 Subject: [PATCH 247/352] cw20-base: validate addresses are unique in initial balances --- contracts/cw20-base/src/contract.rs | 49 ++++++++++++++++++++++++++--- contracts/cw20-base/src/error.rs | 3 ++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/contracts/cw20-base/src/contract.rs b/contracts/cw20-base/src/contract.rs index 32076c451..72f7b3d53 100644 --- a/contracts/cw20-base/src/contract.rs +++ b/contracts/cw20-base/src/contract.rs @@ -151,16 +151,34 @@ pub fn instantiate( Ok(Response::default()) } -pub fn create_accounts(deps: &mut DepsMut, accounts: &[Cw20Coin]) -> StdResult { +pub fn create_accounts( + deps: &mut DepsMut, + accounts: &[Cw20Coin], +) -> Result { + validate_accounts(accounts)?; + let mut total_supply = Uint128::zero(); for row in accounts { let address = deps.api.addr_validate(&row.address)?; BALANCES.save(deps.storage, &address, &row.amount)?; total_supply += row.amount; } + Ok(total_supply) } +pub fn validate_accounts(accounts: &[Cw20Coin]) -> Result<(), ContractError> { + let mut addresses = accounts.iter().map(|c| &c.address).collect::>(); + addresses.sort(); + addresses.dedup(); + + if addresses.len() != accounts.len() { + Err(ContractError::DuplicateInitialBalanceAddresses {}) + } else { + Ok(()) + } +} + #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, @@ -875,6 +893,32 @@ mod tests { let addr1 = String::from("addr0001"); let amount2 = Uint128::from(7890987u128); let addr2 = String::from("addr0002"); + let info = mock_info("creator", &[]); + let env = mock_env(); + + // Fails with duplicate addresses + let instantiate_msg = InstantiateMsg { + name: "Bash Shell".to_string(), + symbol: "BASH".to_string(), + decimals: 6, + initial_balances: vec![ + Cw20Coin { + address: addr1.clone(), + amount: amount1, + }, + Cw20Coin { + address: addr1.clone(), + amount: amount2, + }, + ], + mint: None, + marketing: None, + }; + let err = + instantiate(deps.as_mut(), env.clone(), info.clone(), instantiate_msg).unwrap_err(); + assert_eq!(err, ContractError::DuplicateInitialBalanceAddresses {}); + + // Works with unique addresses let instantiate_msg = InstantiateMsg { name: "Bash Shell".to_string(), symbol: "BASH".to_string(), @@ -892,11 +936,8 @@ mod tests { mint: None, marketing: None, }; - let info = mock_info("creator", &[]); - let env = mock_env(); let res = instantiate(deps.as_mut(), env, info, instantiate_msg).unwrap(); assert_eq!(0, res.messages.len()); - assert_eq!( query_token_info(deps.as_ref()).unwrap(), TokenInfoResponse { diff --git a/contracts/cw20-base/src/error.rs b/contracts/cw20-base/src/error.rs index 264f3756d..a1a63967d 100644 --- a/contracts/cw20-base/src/error.rs +++ b/contracts/cw20-base/src/error.rs @@ -32,4 +32,7 @@ pub enum ContractError { #[error("Invalid png header")] InvalidPngHeader {}, + + #[error("Duplicate initial balance addresses")] + DuplicateInitialBalanceAddresses {}, } From f16f391f46aa5253b0ea57feef514f5b743eec19 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Feb 2022 22:24:50 +0100 Subject: [PATCH 248/352] Make ContractWrapper::new_with_empty convert Deps to Deps --- packages/multi-test/src/contracts.rs | 51 ++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index 03c06bdc6..8ed6e507e 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -2,10 +2,11 @@ use schemars::JsonSchema; use serde::de::DeserializeOwned; use std::error::Error; use std::fmt::{self, Debug, Display}; +use std::ops::Deref; use cosmwasm_std::{ - from_slice, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Empty, Env, MessageInfo, Reply, - Response, SubMsg, + from_slice, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Empty, Env, MessageInfo, + QuerierWrapper, Reply, Response, SubMsg, }; use anyhow::{anyhow, bail, Result as AnyResult}; @@ -121,14 +122,14 @@ where /// this will take a contract that returns Response and will "upgrade" it /// to Response if needed to be compatible with a chain-specific extension pub fn new_with_empty( - execute_fn: ContractFn, - instantiate_fn: ContractFn, - query_fn: QueryFn, + execute_fn: ContractFn, + instantiate_fn: ContractFn, + query_fn: QueryFn, ) -> Self { Self { execute_fn: customize_fn(execute_fn), instantiate_fn: customize_fn(instantiate_fn), - query_fn: Box::new(query_fn), + query_fn: customize_query(query_fn), sudo_fn: None, reply_fn: None, migrate_fn: None, @@ -261,7 +262,7 @@ where } } -fn customize_fn(raw_fn: ContractFn) -> ContractClosure +fn customize_fn(raw_fn: ContractFn) -> ContractClosure where T: DeserializeOwned + 'static, E: Display + Debug + Send + Sync + 'static, @@ -270,11 +271,47 @@ where { let customized = move |deps: DepsMut, env: Env, info: MessageInfo, msg: T| -> Result, E> { + let deps = decustomize_deps_mut(deps); raw_fn(deps, env, info, msg).map(customize_response::) }; Box::new(customized) } +fn customize_query(raw_fn: QueryFn) -> QueryClosure +where + T: DeserializeOwned + 'static, + E: Display + Debug + Send + Sync + 'static, + Q: CustomQuery + DeserializeOwned + 'static, +{ + let customized = move |deps: Deps, env: Env, msg: T| -> Result { + let deps = decustomize_deps(deps); + raw_fn(deps, env, msg) + }; + Box::new(customized) +} + +fn decustomize_deps_mut(deps: DepsMut) -> DepsMut +where + Q: CustomQuery + DeserializeOwned + 'static, +{ + DepsMut { + storage: deps.storage, + api: deps.api, + querier: QuerierWrapper::new(deps.querier.deref()), + } +} + +fn decustomize_deps(deps: Deps) -> Deps +where + Q: CustomQuery + DeserializeOwned + 'static, +{ + Deps { + storage: deps.storage, + api: deps.api, + querier: QuerierWrapper::new(deps.querier.deref()), + } +} + fn customize_permissioned_fn( raw_fn: PermissionedFn, ) -> PermissionedClosure From 290a87f284d141ef852c0da4bfec2f7a9ddc63f4 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 16 Feb 2022 22:29:27 +0100 Subject: [PATCH 249/352] Fixed lifetime issues --- packages/multi-test/src/contracts.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index 8ed6e507e..182e335b1 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -270,8 +270,8 @@ where Q: CustomQuery + DeserializeOwned + 'static, { let customized = - move |deps: DepsMut, env: Env, info: MessageInfo, msg: T| -> Result, E> { - let deps = decustomize_deps_mut(deps); + move |mut deps: DepsMut, env: Env, info: MessageInfo, msg: T| -> Result, E> { + let deps = decustomize_deps_mut(&mut deps); raw_fn(deps, env, info, msg).map(customize_response::) }; Box::new(customized) @@ -284,13 +284,13 @@ where Q: CustomQuery + DeserializeOwned + 'static, { let customized = move |deps: Deps, env: Env, msg: T| -> Result { - let deps = decustomize_deps(deps); + let deps = decustomize_deps(&deps); raw_fn(deps, env, msg) }; Box::new(customized) } -fn decustomize_deps_mut(deps: DepsMut) -> DepsMut +fn decustomize_deps_mut<'a, Q>(deps: &'a mut DepsMut) -> DepsMut<'a, Empty> where Q: CustomQuery + DeserializeOwned + 'static, { @@ -301,7 +301,7 @@ where } } -fn decustomize_deps(deps: Deps) -> Deps +fn decustomize_deps<'a, Q>(deps: &'a Deps<'a, Q>) -> Deps<'a, Empty> where Q: CustomQuery + DeserializeOwned + 'static, { From 775439476a5b353b38e287163482dff20b2bd010 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 17 Feb 2022 10:05:42 +0100 Subject: [PATCH 250/352] cargo fmt --- packages/multi-test/src/contracts.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/multi-test/src/contracts.rs b/packages/multi-test/src/contracts.rs index 182e335b1..68ef4c30b 100644 --- a/packages/multi-test/src/contracts.rs +++ b/packages/multi-test/src/contracts.rs @@ -269,11 +269,14 @@ where C: Clone + fmt::Debug + PartialEq + JsonSchema + 'static, Q: CustomQuery + DeserializeOwned + 'static, { - let customized = - move |mut deps: DepsMut, env: Env, info: MessageInfo, msg: T| -> Result, E> { - let deps = decustomize_deps_mut(&mut deps); - raw_fn(deps, env, info, msg).map(customize_response::) - }; + let customized = move |mut deps: DepsMut, + env: Env, + info: MessageInfo, + msg: T| + -> Result, E> { + let deps = decustomize_deps_mut(&mut deps); + raw_fn(deps, env, info, msg).map(customize_response::) + }; Box::new(customized) } From 94d879fe259a85670c9547996a3a81e4ba40d023 Mon Sep 17 00:00:00 2001 From: Sturdy Date: Thu, 17 Feb 2022 16:07:31 +0100 Subject: [PATCH 251/352] fix: Remove old TODO comment in cw3-flex README --- contracts/cw3-flex-multisig/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/contracts/cw3-flex-multisig/README.md b/contracts/cw3-flex-multisig/README.md index 8ca79ccb6..3225d94d1 100644 --- a/contracts/cw3-flex-multisig/README.md +++ b/contracts/cw3-flex-multisig/README.md @@ -64,10 +64,6 @@ be reverted, and it will remain "Passed", so you can try again). Once a proposal has expired without passing, anyone can submit a "Close" message to mark it closed. This has no effect beyond cleaning up the UI/database. -TODO: this contract currently assumes the group membership is static during -the lifetime of one proposal. If the membership changes when a proposal is -open, this will calculate incorrect values (future PR). - ## Running this contract You will need Rust 1.44.1+ with `wasm32-unknown-unknown` target installed. From f48dbce8ad4f3656f93996fb386b1bae95b45cfa Mon Sep 17 00:00:00 2001 From: Callum Anderson Date: Tue, 22 Feb 2022 15:06:33 +0000 Subject: [PATCH 252/352] Reject proposals when they cannot pass. --- contracts/cw3-fixed-multisig/src/contract.rs | 50 +++++ contracts/cw3-fixed-multisig/src/state.rs | 203 +++++++++++++++++-- 2 files changed, 241 insertions(+), 12 deletions(-) diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 8c2f530c7..ca7ff955a 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -764,6 +764,56 @@ mod tests { let info = mock_info(VOTER5, &[]); let err = execute(deps.as_mut(), mock_env(), info, yes_vote).unwrap_err(); assert_eq!(err, ContractError::NotOpen {}); + + // Propose + let info = mock_info(OWNER, &[]); + let bank_msg = BankMsg::Send { + to_address: SOMEBODY.into(), + amount: vec![coin(1, "BTC")], + }; + let msgs = vec![CosmosMsg::Bank(bank_msg)]; + let proposal = ExecuteMsg::Propose { + title: "Pay somebody".to_string(), + description: "Do I pay her?".to_string(), + msgs, + latest: None, + }; + let res = execute(deps.as_mut(), mock_env(), info.clone(), proposal).unwrap(); + + // Get the proposal id from the logs + let proposal_id: u64 = res.attributes[2].value.parse().unwrap(); + + // Cast a No vote + let no_vote = ExecuteMsg::Vote { + proposal_id, + vote: Vote::No, + }; + // Voter1 vote no + let info = mock_info(VOTER1, &[]); + let res = execute(deps.as_mut(), mock_env(), info, no_vote.clone()).unwrap(); + + // Verify it is not enough to reject yet + assert_eq!( + res, + Response::new() + .add_attribute("action", "vote") + .add_attribute("sender", VOTER1) + .add_attribute("proposal_id", proposal_id.to_string()) + .add_attribute("status", "Open") + ); + + let info = mock_info(VOTER4, &[]); + let res = execute(deps.as_mut(), mock_env(), info, no_vote).unwrap(); + + // Verify it is now rejected due to reaching threshold + assert_eq!( + res, + Response::new() + .add_attribute("action", "vote") + .add_attribute("sender", VOTER4) + .add_attribute("proposal_id", proposal_id.to_string()) + .add_attribute("status", "Rejected") + ); } #[test] diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index 92dbbe62f..6e1eacb04 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -47,6 +47,9 @@ impl Proposal { if status == Status::Open && self.expires.is_expired(block) { status = Status::Rejected; } + if status == Status::Open && self.is_rejected(block) { + status = Status::Rejected; + } status } @@ -57,17 +60,24 @@ impl Proposal { self.status = self.current_status(block); } - // returns true iff this proposal is sure to pass (even before expiration if no future - // sequence of possible votes can cause it to fail) - pub fn is_passed(&self, block: &BlockInfo) -> bool { + /// Helper function to check if a certain vote count has reached threshold. + /// Only called from is_rejected and is_passed for no and yes votes + /// Handles the different threshold types accordingly. + /// This function returns true if and only if vote_count is greater than the threshold which + /// is calculated. + /// In the case where we use yes votes, this function will return true if and only if the + /// proposal will pass. + /// In the case where we use no votes, this function will return true if and only if the + /// proposal will be rejected regardless of other votes. + fn does_vote_count_reach_threshold(&self, vote_count: u64, block: &BlockInfo) -> bool { match self.threshold { Threshold::AbsoluteCount { weight: weight_needed, - } => self.votes.yes >= weight_needed, + } => vote_count >= weight_needed, Threshold::AbsolutePercentage { percentage: percentage_needed, } => { - self.votes.yes + vote_count >= votes_needed(self.total_weight - self.votes.abstain, percentage_needed) } Threshold::ThresholdQuorum { threshold, quorum } => { @@ -76,18 +86,30 @@ impl Proposal { return false; } if self.expires.is_expired(block) { - // If expired, we compare Yes votes against the total number of votes (minus abstain). + // If expired, we compare vote_count against the total number of votes (minus abstain). let opinions = self.votes.total() - self.votes.abstain; - self.votes.yes >= votes_needed(opinions, threshold) + vote_count >= votes_needed(opinions, threshold) } else { - // If not expired, we must assume all non-votes will be cast as No. - // We compare threshold against the total weight (minus abstain). + // If not expired, we must assume all non-votes will be cast against + // vote_count let possible_opinions = self.total_weight - self.votes.abstain; - self.votes.yes >= votes_needed(possible_opinions, threshold) + vote_count >= votes_needed(possible_opinions, threshold) } } } } + + /// returns true iff this proposal is sure to pass (even before expiration if no future + /// sequence of possible votes can cause it to fail) + pub fn is_passed(&self, block: &BlockInfo) -> bool { + self.does_vote_count_reach_threshold(self.votes.yes, block) + } + + /// As above for the rejected check, used to check if a proposal is + /// already rejected. + pub fn is_rejected(&self, block: &BlockInfo) -> bool { + self.does_vote_count_reach_threshold(self.votes.no, block) + } } // weight of votes for each option @@ -192,12 +214,12 @@ mod test { assert_eq!(12, votes_needed(48, Decimal::percent(25))); } - fn check_is_passed( + fn setup_prop( threshold: Threshold, votes: Votes, total_weight: u64, is_expired: bool, - ) -> bool { + ) -> (Proposal, BlockInfo) { let block = mock_env().block; let expires = match is_expired { true => Expiration::AtHeight(block.height - 5), @@ -214,9 +236,30 @@ mod test { total_weight, votes, }; + + (prop, block) + } + + fn check_is_passed( + threshold: Threshold, + votes: Votes, + total_weight: u64, + is_expired: bool, + ) -> bool { + let (prop, block) = setup_prop(threshold, votes, total_weight, is_expired); prop.is_passed(&block) } + fn check_is_rejected( + threshold: Threshold, + votes: Votes, + total_weight: u64, + is_expired: bool, + ) -> bool { + let (prop, block) = setup_prop(threshold, votes, total_weight, is_expired); + prop.is_rejected(&block) + } + #[test] fn proposal_passed_absolute_count() { let fixed = Threshold::AbsoluteCount { weight: 10 }; @@ -231,6 +274,21 @@ mod test { assert!(check_is_passed(fixed, votes, 30, true)); } + #[test] + fn proposal_rejected_absolute_count() { + let fixed = Threshold::AbsoluteCount { weight: 10 }; + let mut votes = Votes::yes(0); + votes.add_vote(Vote::Veto, 4); + votes.add_vote(Vote::No, 7); + // same expired or not, total_weight or whatever + assert!(!check_is_rejected(fixed.clone(), votes.clone(), 30, false)); + assert!(!check_is_rejected(fixed.clone(), votes.clone(), 30, true)); + // a few more no votes and we have rejected the prop + votes.add_vote(Vote::No, 3); + assert!(check_is_rejected(fixed.clone(), votes.clone(), 30, false)); + assert!(check_is_rejected(fixed, votes, 30, true)); + } + #[test] fn proposal_passed_absolute_percentage() { let percent = Threshold::AbsolutePercentage { @@ -251,6 +309,38 @@ mod test { assert!(check_is_passed(percent, votes, 14, true)); } + #[test] + fn proposal_rejected_absolute_percentage() { + let percent = Threshold::AbsolutePercentage { + percentage: Decimal::percent(50), + }; + + // 4 YES, 7 NO, 2 ABSTAIN + let mut votes = Votes::yes(4); + votes.add_vote(Vote::No, 7); + votes.add_vote(Vote::Abstain, 2); + + // 15 total voting power + // 7 / (15 - 2) > 50% + // Expiry does not matter + assert!(check_is_rejected(percent.clone(), votes.clone(), 15, false)); + assert!(check_is_rejected(percent.clone(), votes.clone(), 15, true)); + + // 17 total voting power + // 7 / (17 - 2) < 50% + assert!(!check_is_rejected( + percent.clone(), + votes.clone(), + 17, + false + )); + assert!(!check_is_rejected(percent.clone(), votes.clone(), 17, true)); + + // Rejected if total was lower + assert!(check_is_rejected(percent.clone(), votes.clone(), 14, false)); + assert!(check_is_rejected(percent, votes.clone(), 14, true)); + } + #[test] fn proposal_passed_quorum() { let quorum = Threshold::ThresholdQuorum { @@ -318,6 +408,95 @@ mod test { assert!(check_is_passed(quorum, passing, 16, false)); } + #[test] + fn proposal_rejected_quorum() { + let quorum = Threshold::ThresholdQuorum { + threshold: Decimal::percent(50), + quorum: Decimal::percent(40), + }; + // all non-yes votes are counted for quorum + let rejecting = Votes { + yes: 3, + no: 7, + abstain: 2, + veto: 1, + }; + // abstain votes are not counted for threshold => yes / (yes + no + veto) + let rejected_ignoring_abstain = Votes { + yes: 4, + no: 6, + abstain: 5, + veto: 2, + }; + // fails any way you look at it + let failing = Votes { + yes: 5, + no: 6, + abstain: 2, + veto: 2, + }; + + // first, expired (voting period over) + // over quorum (40% of 30 = 12), over threshold (7/11 > 50%) + assert!(check_is_rejected( + quorum.clone(), + rejecting.clone(), + 30, + true + )); + // Under quorum means it cannot be rejected + assert!(!check_is_rejected( + quorum.clone(), + rejecting.clone(), + 33, + true + )); + + // over quorum, threshold passes if we ignore abstain + // 17 total votes w/ abstain => 40% quorum of 40 total + // 6 no / (6 no + 4 yes + 2 votes) => 50% threshold + assert!(check_is_rejected( + quorum.clone(), + rejected_ignoring_abstain.clone(), + 40, + true + )); + + // over quorum, but under threshold fails also + assert!(!check_is_rejected(quorum.clone(), failing, 20, true)); + + // Voting is still open so assume rest of votes are yes + // threshold not reached + assert!(!check_is_rejected( + quorum.clone(), + rejecting.clone(), + 30, + false + )); + assert!(!check_is_rejected( + quorum.clone(), + rejected_ignoring_abstain.clone(), + 40, + false + )); + // if we have threshold * total_weight as no votes this must reject + assert!(check_is_rejected( + quorum.clone(), + rejecting.clone(), + 14, + false + )); + // all votes have been cast, some abstain + assert!(check_is_rejected( + quorum.clone(), + rejected_ignoring_abstain, + 17, + false + )); + // 3 votes uncast, if they all vote yes, we have 7 no, 7 yes+veto, 2 abstain (out of 16) + assert!(check_is_rejected(quorum, rejecting, 16, false)); + } + #[test] fn quorum_edge_cases() { // when we pass absolute threshold (everyone else voting no, we pass), but still don't hit quorum From a46886e1c524c9b9d4eb91d8f812694d530de557 Mon Sep 17 00:00:00 2001 From: Callum Anderson Date: Tue, 22 Feb 2022 15:13:08 +0000 Subject: [PATCH 253/352] lint --- contracts/cw3-fixed-multisig/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index ca7ff955a..f55609bfe 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -778,7 +778,7 @@ mod tests { msgs, latest: None, }; - let res = execute(deps.as_mut(), mock_env(), info.clone(), proposal).unwrap(); + let res = execute(deps.as_mut(), mock_env(), info, proposal).unwrap(); // Get the proposal id from the logs let proposal_id: u64 = res.attributes[2].value.parse().unwrap(); From f770502a3f0b0d22ad973301e42429ffe8c8dde5 Mon Sep 17 00:00:00 2001 From: Callum Anderson Date: Tue, 22 Feb 2022 15:19:57 +0000 Subject: [PATCH 254/352] Add flex tests --- contracts/cw3-flex-multisig/src/contract.rs | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 236358c66..bd6a78dbd 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -1056,6 +1056,39 @@ mod tests { .query_wasm_smart(&flex_addr, &QueryMsg::Vote { proposal_id, voter }) .unwrap(); assert!(vote.vote.is_none()); + + // create proposal with 0 vote power + let proposal = pay_somebody_proposal(); + let res = app + .execute_contract(Addr::unchecked(OWNER), flex_addr.clone(), &proposal, &[]) + .unwrap(); + + // Get the proposal id from the logs + let proposal_id: u64 = res.custom_attrs(1)[2].value.parse().unwrap(); + + // Cast a No vote + let no_vote = ExecuteMsg::Vote { + proposal_id, + vote: Vote::No, + }; + let _ = app + .execute_contract(Addr::unchecked(VOTER2), flex_addr.clone(), &no_vote, &[]) + .unwrap(); + + // Powerful voter supports it, so it rejects + let res = app + .execute_contract(Addr::unchecked(VOTER4), flex_addr, &no_vote, &[]) + .unwrap(); + + assert_eq!( + res.custom_attrs(1), + [ + ("action", "vote"), + ("sender", VOTER4), + ("proposal_id", proposal_id.to_string().as_str()), + ("status", "Rejected"), + ], + ); } #[test] From 8cb9e80e472a37a30f31fa8d1aa3091315d7411f Mon Sep 17 00:00:00 2001 From: Callum Anderson Date: Tue, 22 Feb 2022 16:54:53 +0000 Subject: [PATCH 255/352] Address feedback --- contracts/cw3-fixed-multisig/src/state.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index 6e1eacb04..361187dc4 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -44,10 +44,7 @@ impl Proposal { if status == Status::Open && self.is_passed(block) { status = Status::Passed; } - if status == Status::Open && self.expires.is_expired(block) { - status = Status::Rejected; - } - if status == Status::Open && self.is_rejected(block) { + if status == Status::Open && (self.is_rejected(block) || self.expires.is_expired(block)) { status = Status::Rejected; } @@ -65,9 +62,8 @@ impl Proposal { /// Handles the different threshold types accordingly. /// This function returns true if and only if vote_count is greater than the threshold which /// is calculated. - /// In the case where we use yes votes, this function will return true if and only if the - /// proposal will pass. - /// In the case where we use no votes, this function will return true if and only if the + /// In the case where we use yes votes, this function will return true if the proposal will pass. + /// In the case where we use no votes, this function will return true if the /// proposal will be rejected regardless of other votes. fn does_vote_count_reach_threshold(&self, vote_count: u64, block: &BlockInfo) -> bool { match self.threshold { @@ -99,14 +95,14 @@ impl Proposal { } } - /// returns true iff this proposal is sure to pass (even before expiration if no future - /// sequence of possible votes can cause it to fail) + /// Returns true if this proposal is sure to pass (even before expiration, if no future + /// sequence of possible votes could cause it to fail). pub fn is_passed(&self, block: &BlockInfo) -> bool { self.does_vote_count_reach_threshold(self.votes.yes, block) } - /// As above for the rejected check, used to check if a proposal is - /// already rejected. + /// Returns true if this proposal is sure to be rejected (even before expiration, if + /// no future sequence of possible votes could cause it to fail). pub fn is_rejected(&self, block: &BlockInfo) -> bool { self.does_vote_count_reach_threshold(self.votes.no, block) } From a231a2ede89bb1db29ba04a0db186077ddb96056 Mon Sep 17 00:00:00 2001 From: Callum Anderson <46447937+Callum-A@users.noreply.github.com> Date: Wed, 23 Feb 2022 11:35:01 +0000 Subject: [PATCH 256/352] Update contracts/cw3-flex-multisig/src/contract.rs Co-authored-by: Mauro Lacy --- contracts/cw3-flex-multisig/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index bd6a78dbd..5616cba7d 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -1075,7 +1075,7 @@ mod tests { .execute_contract(Addr::unchecked(VOTER2), flex_addr.clone(), &no_vote, &[]) .unwrap(); - // Powerful voter supports it, so it rejects + // Powerful voter opposes it, so it rejects let res = app .execute_contract(Addr::unchecked(VOTER4), flex_addr, &no_vote, &[]) .unwrap(); From 4cc1159dfda17dbe50c1fa28b27a6489a5bb032d Mon Sep 17 00:00:00 2001 From: Callum Anderson <46447937+Callum-A@users.noreply.github.com> Date: Wed, 23 Feb 2022 11:35:10 +0000 Subject: [PATCH 257/352] Update contracts/cw3-fixed-multisig/src/state.rs Co-authored-by: Mauro Lacy --- contracts/cw3-fixed-multisig/src/state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index 361187dc4..e808da7de 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -102,7 +102,7 @@ impl Proposal { } /// Returns true if this proposal is sure to be rejected (even before expiration, if - /// no future sequence of possible votes could cause it to fail). + /// no future sequence of possible votes could cause it to pass). pub fn is_rejected(&self, block: &BlockInfo) -> bool { self.does_vote_count_reach_threshold(self.votes.no, block) } From 73fcd8a84e51c299cc65a235d5ba1c57d8ea9937 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 22 Feb 2022 22:59:08 +0100 Subject: [PATCH 258/352] Update storage-plus README Add entry / notes about mutli-index type-safe bounds --- packages/storage-plus/README.md | 78 ++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/packages/storage-plus/README.md b/packages/storage-plus/README.md index edb17d8ed..04fa94556 100644 --- a/packages/storage-plus/README.md +++ b/packages/storage-plus/README.md @@ -7,9 +7,8 @@ more powerful and easy to use interfaces. Here are those interfaces. **Status: beta** This has been heavily used in many production-quality contracts and -heavily refined. There is one planned API break (dealing with -auto-deserializing keys in range queries), but the code has demonstrated -itself to be stable and powerful. Please feel free to use in your contracts. +heavily refined. The code has demonstrated itself to be stable and powerful. +Please feel free to use it in your contracts. ## Usage Overview @@ -98,7 +97,7 @@ fn demo() -> StdResult<()> { ## Map -The usage of an [`Map`](./src/item.rs) is a little more complex, but +The usage of a [`Map`](./src/map.rs) is a little more complex, but is still pretty straight-forward. You can imagine it as a storage-backed `BTreeMap`, allowing key-value lookups with typed values. In addition, we support not only simple binary keys (`&[u8]`), but tuples, which are @@ -119,7 +118,7 @@ variants of the object, just one type. Furthermore, we use `const fn` to create the `Bucket`, allowing it to be defined as a global compile-time constant rather than a function that must be constructed each time, which saves gas as well as typing. In addition, the composite indexes -(tuples) is more ergonomic and expressive of intention, and the range +(tuples) are more ergonomic and expressive of intention, and the range interface has been improved. Here is an example with normal (simple) keys: @@ -189,7 +188,7 @@ fn demo() -> StdResult<()> { ### Key types A `Map` key can be anything that implements the `PrimaryKey` trait. There are a series of implementations of -`PrimaryKey` already provided (see `packages/storage-plus/src/keys.rs`): +`PrimaryKey` already provided (see [keys.rs](src/keys.rs)): - `impl<'a> PrimaryKey<'a> for &'a [u8]` - `impl<'a> PrimaryKey<'a> for &'a str` @@ -199,10 +198,11 @@ A `Map` key can be anything that implements the `PrimaryKey` trait. There are a - `impl<'a> PrimaryKey<'a> for &'a Addr` - `impl<'a, T: PrimaryKey<'a> + Prefixer<'a>, U: PrimaryKey<'a>> PrimaryKey<'a> for (T, U)` - `impl<'a, T: PrimaryKey<'a> + Prefixer<'a>, U: PrimaryKey<'a> + Prefixer<'a>, V: PrimaryKey<'a>> PrimaryKey<'a> for (T, U, V)` - - `impl<'a, T: Endian + Clone> PrimaryKey<'a> for IntKey` + - `PrimaryKey` implemented for unsigned integers up to `u64` + - `PrimaryKey` implemented for signed integers up to `i64` That means that byte and string slices, byte vectors, and strings, can be conveniently used as keys. -Moreover, some other types can be used as well, like addresses and address references, pairs and triples, and +Moreover, some other types can be used as well, like addresses and address references, pairs, triples, and integer types. If the key represents an address, we suggest using `&Addr` for keys in storage, instead of `String` or string slices. @@ -211,9 +211,12 @@ legitimate address, and not random text which will fail later. `pub fn addr_validate(&self, &str) -> Addr` in `deps.api` can be used for address validation, and the returned `Addr` can then be conveniently used as key in a `Map` or similar structure. +It's also convenient to use references (i.e. borrowed values) instead of values for keys (i.e. `&Addr` instead of `Addr`) +, as that will typically save some cloning during key reading / writing. + ### Composite Keys -There are times when we want to use multiple items as a key, for example, when +There are times when we want to use multiple items as a key. For example, when storing allowances based on account owner and spender. We could try to manually concatenate them before calling, but that can lead to overlap, and is a bit low-level for us. Also, by explicitly separating the keys, we can easily provide @@ -221,12 +224,12 @@ helpers to do range queries over a prefix, such as "show me all allowances for one owner" (first part of the composite key). Just like you'd expect from your favorite database. -Here how we use it with composite keys. Just define a tuple as a key and use that +Here's how we use it with composite keys. Just define a tuple as a key and use that everywhere you used a byte slice above. ```rust -// Note the tuple for primary key. We support one slice, or a 2 or 3-tuple -// adding longer tuples is quite easy but unlikely to be needed. +// Note the tuple for primary key. We support one slice, or a 2 or 3-tuple. +// Adding longer tuples is possible, but unlikely to be needed. const ALLOWANCE: Map<(&str, &str), u64> = Map::new("allow"); fn demo() -> StdResult<()> { @@ -259,7 +262,7 @@ fn demo() -> StdResult<()> { Under the scenes, we create a `Path` from the `Map` when accessing a key. `PEOPLE.load(&store, b"jack") == PEOPLE.key(b"jack").load()`. `Map.key()` returns a `Path`, which has the same interface as `Item`, -reusing the calculated path to this key. +re-using the calculated path to this key. For simple keys, this is just a bit less typing and a bit less gas if you use the same key for many calls. However, for composite keys, like @@ -296,7 +299,7 @@ fn demo() -> StdResult<()> { let empty = john.may_load(&store)?; assert_eq!(None, empty); - // Same for composite keys, just use both parts in key(). + // Same for composite keys, just use both parts in `key()`. // Notice how much less verbose than the above example. let allow = ALLOWANCE.key(("owner", "spender")); allow.save(&mut store, &1234)?; @@ -314,7 +317,7 @@ fn demo() -> StdResult<()> { In addition to getting one particular item out of a map, we can iterate over the map (or a subset of the map). This let us answer questions like "show me all tokens", -and we provide some nice [`Bound`](#Bound) helpers to easily allow pagination or custom ranges. +and we provide some nice [`Bound`](#Bound) helpers to easily allow pagination, or custom ranges. The general format is to get a `Prefix` by calling `map.prefix(k)`, where `k` is exactly one less item than the normal key (If `map.key()` took `(&[u8], &[u8])`, then `map.prefix()` takes `&[u8]`. @@ -323,7 +326,7 @@ over all items with `range(store, min, max, order)`. It supports `Order::Ascendi `min` is the lower bound and `max` is the higher bound. If the `min` and `max` bounds are `None`, `range` will return all items under the prefix. You can use `.take(n)` to -limit the results to `n` items and start doing pagination. You can also set the `min` bound to +limit the results to `n` items, and start doing pagination. You can also set the `min` bound to eg. `Bound::exclusive(last_value)` to start iterating over all items *after* the last value. Combined with `take`, we easily have pagination support. You can also use `Bound::inclusive(x)` when you want to include any perfect matches. @@ -343,7 +346,7 @@ pub enum Bound<'a, K: PrimaryKey<'a>> { } ``` -To better understand the API, please read the following example: +To better understand the API, please check the following example: ```rust #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] struct Data { @@ -414,15 +417,18 @@ fn demo() -> StdResult<()> { } ``` +*Note*: For properly defining and using type-safe bounds over a `MultiIndex`, see [Type-safe bounds over `MultiIndex`](#Type-safe bounds over MultiIndex), +below. + ## IndexedMap -Let's use one example of `IndexedMap` definition and usage, originally taken from the `cw721-base` contract. +Let's see one example of `IndexedMap` definition and usage, originally taken from the `cw721-base` contract. ### Definition ```rust pub struct TokenIndexes<'a> { - pub owner: MultiIndex<'a, Addr, TokenInfo>, + pub owner: MultiIndex<'a, Addr, TokenInfo, String>, } impl<'a> IndexList for TokenIndexes<'a> { @@ -453,11 +459,10 @@ pub struct TokenIndexes<'a> { These are the index definitions. Here there's only one index, called `owner`. There could be more, as public members of the `TokenIndexes` struct. - We see that the `owner` index is a `MultiIndex`. A multi-index can have repeated values as keys. The primary key is used internally as the last element of the multi-index key, to disambiguate repeated index values. Like the name implies, this is an index over tokens, by owner. Given that an owner can have multiple tokens, -we need a `MultiIndex` to be able to list / iterate over all the tokens a given owner has. +we need a `MultiIndex` to be able to list / iterate over all the tokens he has. The `TokenInfo` data will originally be stored by `token_id` (which is a string value). You can see this in the token creation code: @@ -472,11 +477,15 @@ You can see this in the token creation code: Given that `token_id` is a string value, we specify `String` as the last argument of the `MultiIndex` definition. That way, the deserialization of the primary key will be done to the right type (an owned string). +*Note*: In the particular case of a `MultiIndex`, and with the latest implementation of type-safe bounds, the definition of +this last type parameter is crucial, for properly using type-safe bounds. +See [Type-safe bounds over `MultiIndex`](#Type-safe bounds over MultiIndex), below. + Then, this `TokenInfo` data will be indexed by token `owner` (which is an `Addr`). So that we can list all the tokens an owner has. That's why the `owner` index key is `Addr`. Other important thing here is that the key (and its components, in the case of a composite key) must implement -the `PrimaryKey` trait. You can see that `Addr` do implement `PrimaryKey`: +the `PrimaryKey` trait. You can see that `Addr` do implements `PrimaryKey`: ```rust impl<'a> PrimaryKey<'a> for Addr { @@ -576,17 +585,18 @@ Notice this uses `prefix()`, explained above in the `Map` section. let tokens = res?; ``` Now `tokens` contains `(token_id, TokenInfo)` pairs for the given `owner`. -The pk values are `Vec` in the case of `prefix` + `range`, but will be deserialized to the proper type using -`prefix_de` + `range_de`; provided that the (optional) pk deserialization type (`String`, in this case) -is specified in the `MultiIndex` definition (see #Index keys deserialization, below). +The pk values are `Vec` in the case of `prefix()` + `range_raw()`, but will be deserialized to the proper type using +`prefix()` + `range()`; provided that the pk deserialization type (`String`, in this case) +is correctly specified in the `MultiIndex` definition (see [Index keys deserialization](#Index keys deserialization), +below). -Another example that is similar, but returning only the `token_id`s, using the `keys()` method: +Another example that is similar, but returning only the (raw) `token_id`s, using the `keys_raw()` method: ```rust let pks: Vec<_> = tokens() .idx .owner .prefix(owner_addr) - .keys( + .keys_raw( deps.storage, start, None, @@ -595,13 +605,19 @@ Another example that is similar, but returning only the `token_id`s, using the ` .take(limit) .collect(); ``` -Now `pks` contains `token_id` values (as raw `Vec`s) for the given `owner`. Again, by using `prefix_de` + `range_de`, +Now `pks` contains `token_id` values (as raw `Vec`s) for the given `owner`. By using `prefix()` + `keys`, a deserialized key can be obtained instead, as detailed in the next section. ### Index keys deserialization For `UniqueIndex` and `MultiIndex`, the primary key (`PK`) type needs to be specified, in order to deserialize the primary key to it. This generic type comes with a default of `()`, which means that no deserialization / data -will be provided for the primary key. This is for backwards compatibility with the current `UniqueIndex` / `MultiIndex` -impls. It can also come in handy in cases you don't need the primary key, and are interested only in the deserialized -values. +will be provided for the primary key. This is for backwards compatibility with previous `UniqueIndex` / `MultiIndex` +usages, and will be likely be changed in the future. + +### Type-safe bounds over MultiIndex + +In the particular case of `MultiIndex`, this primary key (`PK`) type also defines the type of the (partial) bounds over +the index key (the part that corresponds to the primary key, that is). +So, to being able to correctly use type-safe bounds over multi-indexes ranges, it is fundamental for this `PK` type +to be correctly defined, so that it matches the primary key type, or its (typically owned) deserialization variant. From 4f120539103b15a6c3c4efbb8c36e129e48fb619 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 23 Feb 2022 08:11:15 +0100 Subject: [PATCH 259/352] Fix syntax / links Remove comment about optional PK --- packages/storage-plus/README.md | 35 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/storage-plus/README.md b/packages/storage-plus/README.md index 04fa94556..17a439f31 100644 --- a/packages/storage-plus/README.md +++ b/packages/storage-plus/README.md @@ -104,7 +104,7 @@ we support not only simple binary keys (`&[u8]`), but tuples, which are combined. This allows us to store allowances as composite keys eg. `(owner, spender)` to look up the balance. -Beyond direct lookups, we have a super power not found in Ethereum - +Beyond direct lookups, we have a super-power not found in Ethereum - iteration. That's right, you can list all items in a `Map`, or only part of them. We can efficiently allow pagination over these items as well, starting at the point the last query ended, with low gas costs. @@ -317,7 +317,7 @@ fn demo() -> StdResult<()> { In addition to getting one particular item out of a map, we can iterate over the map (or a subset of the map). This let us answer questions like "show me all tokens", -and we provide some nice [`Bound`](#Bound) helpers to easily allow pagination, or custom ranges. +and we provide some nice [`Bound`](#bound) helpers to easily allow pagination, or custom ranges. The general format is to get a `Prefix` by calling `map.prefix(k)`, where `k` is exactly one less item than the normal key (If `map.key()` took `(&[u8], &[u8])`, then `map.prefix()` takes `&[u8]`. @@ -417,7 +417,7 @@ fn demo() -> StdResult<()> { } ``` -*Note*: For properly defining and using type-safe bounds over a `MultiIndex`, see [Type-safe bounds over `MultiIndex`](#Type-safe bounds over MultiIndex), +**NB**: For properly defining and using type-safe bounds over a `MultiIndex`, see [Type-safe bounds over `MultiIndex`](#type-safe-bounds-over-multiindex), below. ## IndexedMap @@ -477,9 +477,9 @@ You can see this in the token creation code: Given that `token_id` is a string value, we specify `String` as the last argument of the `MultiIndex` definition. That way, the deserialization of the primary key will be done to the right type (an owned string). -*Note*: In the particular case of a `MultiIndex`, and with the latest implementation of type-safe bounds, the definition of +**NB**: In the particular case of a `MultiIndex`, and with the latest implementation of type-safe bounds, the definition of this last type parameter is crucial, for properly using type-safe bounds. -See [Type-safe bounds over `MultiIndex`](#Type-safe bounds over MultiIndex), below. +See [Type-safe bounds over `MultiIndex`](#type-safe-bounds-over-multiindex), below. Then, this `TokenInfo` data will be indexed by token `owner` (which is an `Addr`). So that we can list all the tokens an owner has. That's why the `owner` index key is `Addr`. @@ -515,7 +515,8 @@ impl<'a> IndexList for TokenIndexes<'a> { ``` This implements the `IndexList` trait for `TokenIndexes`. -Note: this code is more or less boiler-plate, and needed for the internals. Do not try to customize this; + +**NB**: this code is more or less boiler-plate, and needed for the internals. Do not try to customize this; just return a list of all indexes. Implementing this trait serves two purposes (which are really one and the same): it allows the indexes to be queried through `get_indexes`, and, it allows `TokenIndexes` to be treated as an `IndexList`. So that @@ -541,8 +542,7 @@ During index creation, we must supply an index function per index ```rust owner: MultiIndex::new(|d: &TokenInfo| d.owner.clone(), ``` - -, which is the one that will take the value of the original map, and create the index key from it. +which is the one that will take the value of the original map and create the index key from it. Of course, this requires that the elements required for the index key are present in the value. Besides the index function, we must also supply the namespace of the pk, and the one for the new index. @@ -585,9 +585,9 @@ Notice this uses `prefix()`, explained above in the `Map` section. let tokens = res?; ``` Now `tokens` contains `(token_id, TokenInfo)` pairs for the given `owner`. -The pk values are `Vec` in the case of `prefix()` + `range_raw()`, but will be deserialized to the proper type using -`prefix()` + `range()`; provided that the pk deserialization type (`String`, in this case) -is correctly specified in the `MultiIndex` definition (see [Index keys deserialization](#Index keys deserialization), +The pk values are `Vec` in the case of `range_raw()`, but will be deserialized to the proper type using +`range()`; provided that the pk deserialization type (`String`, in this case) is correctly specified +in the `MultiIndex` definition (see [Index keys deserialization](#index-keys-deserialization), below). Another example that is similar, but returning only the (raw) `token_id`s, using the `keys_raw()` method: @@ -605,15 +605,18 @@ Another example that is similar, but returning only the (raw) `token_id`s, using .take(limit) .collect(); ``` -Now `pks` contains `token_id` values (as raw `Vec`s) for the given `owner`. By using `prefix()` + `keys`, -a deserialized key can be obtained instead, as detailed in the next section. +Now `pks` contains `token_id` values (as raw `Vec`s) for the given `owner`. By using `keys` instead, +a deserialized key can be obtained, as detailed in the next section. ### Index keys deserialization For `UniqueIndex` and `MultiIndex`, the primary key (`PK`) type needs to be specified, in order to deserialize -the primary key to it. This generic type comes with a default of `()`, which means that no deserialization / data -will be provided for the primary key. This is for backwards compatibility with previous `UniqueIndex` / `MultiIndex` -usages, and will be likely be changed in the future. +the primary key to it. +This `PK` type specification is also important for `MultiIndex` type-safe bounds, as the primary key +is part of the multi-index key. See next section, [Type-safe bounds over MultiIndex](#type-safe-bounds-over-multiindex). + +**NB**: This specification is still a manual (and therefore error-prone) process / setup, that will if possible +be automated in the future (https://github.com/CosmWasm/cw-plus/issues/531). ### Type-safe bounds over MultiIndex From e4050d87e7866ec3ea8d17d5e3d62345c51d689b Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 23 Feb 2022 08:12:56 +0100 Subject: [PATCH 260/352] Remove PK default from MultiIndex --- packages/storage-plus/src/indexes/multi.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/indexes/multi.rs b/packages/storage-plus/src/indexes/multi.rs index 7cd7b4ebd..f3a4bd70a 100644 --- a/packages/storage-plus/src/indexes/multi.rs +++ b/packages/storage-plus/src/indexes/multi.rs @@ -23,8 +23,11 @@ use std::marker::PhantomData; /// The stored pk_len is used to recover the pk from the index namespace, and perform /// the secondary load of the associated value from the main map. /// -/// The (optional) PK type defines the type of Primary Key deserialization. -pub struct MultiIndex<'a, IK, T, PK = ()> { +/// The PK type defines the type of Primary Key, both for deserialization, and +/// more important, type-safe bound key type. +/// This type must match the encompassing `IndexedMap` primary key type, +/// or its owned variant. +pub struct MultiIndex<'a, IK, T, PK> { index: fn(&T) -> IK, idx_namespace: &'a [u8], // note, we collapse the ik - combining everything under the namespace - and concatenating the pk From 8bae5061c42ba5d145ed37a4bcc0a83de896953b Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 23 Feb 2022 08:20:47 +0100 Subject: [PATCH 261/352] Adapt / extend IndexedMap bounds tests over multi-index --- packages/storage-plus/src/indexed_map.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index ee68c7549..9507dec8c 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -1391,11 +1391,12 @@ mod test { ); } - mod inclusive_bound { + mod bounds { use super::*; struct Indexes<'a> { - secondary: MultiIndex<'a, u64, u64>, + // The last type param must match the `IndexedMap` primary key type, below + secondary: MultiIndex<'a, u64, u64, &'a str>, } impl<'a> IndexList for Indexes<'a> { @@ -1420,7 +1421,9 @@ mod test { map.save(&mut store, "one", &1).unwrap(); map.save(&mut store, "two", &2).unwrap(); + map.save(&mut store, "three", &3).unwrap(); + // Inclusive prefix-bound let items: Vec<_> = map .idx .secondary @@ -1437,6 +1440,22 @@ mod test { let items: Vec<_> = items.into_iter().map(|(_, v)| v).collect(); assert_eq!(items, vec![1]); + + // Exclusive bound (used for pagination) + // Range over the index specifying a primary key (multi-index key includes the pk) + let items: Vec<_> = map + .idx + .secondary + .range( + &store, + Some(Bound::exclusive((2u64, "two"))), + None, + Order::Ascending, + ) + .collect::>() + .unwrap(); + + assert_eq!(items, vec![("three".to_string(), 3)]); } } } From 0aaf3bd623494ba3f2949c11532e160ddef49b6e Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 23 Feb 2022 08:26:03 +0100 Subject: [PATCH 262/352] Add repeated value example in multi-index --- packages/storage-plus/src/indexed_map.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 9507dec8c..ef5d06cc3 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -1421,6 +1421,7 @@ mod test { map.save(&mut store, "one", &1).unwrap(); map.save(&mut store, "two", &2).unwrap(); + map.save(&mut store, "two2", &2).unwrap(); map.save(&mut store, "three", &3).unwrap(); // Inclusive prefix-bound @@ -1455,7 +1456,7 @@ mod test { .collect::>() .unwrap(); - assert_eq!(items, vec![("three".to_string(), 3)]); + assert_eq!(items, vec![("two2".to_string(), 2), ("three".to_string(), 3)]); } } } From 01e643f376dfa3934f2929dc99d2956a04a69677 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 23 Feb 2022 08:48:32 +0100 Subject: [PATCH 263/352] Add unique index bounds test for reference / comparison --- packages/storage-plus/src/indexed_map.rs | 59 +++++++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index ef5d06cc3..1771b0df2 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -1391,7 +1391,59 @@ mod test { ); } - mod bounds { + mod bounds_unique_index { + use super::*; + + struct Indexes<'a> { + secondary: UniqueIndex<'a, u64, u64>, + } + + impl<'a> IndexList for Indexes<'a> { + fn get_indexes(&'_ self) -> Box> + '_> { + let v: Vec<&dyn Index> = vec![&self.secondary]; + Box::new(v.into_iter()) + } + } + + #[test] + #[cfg(feature = "iterator")] + fn composite_key_query() { + let indexes = Indexes { + secondary: UniqueIndex::new(|secondary| *secondary, "test_map__secondary"), + }; + let map = IndexedMap::<&str, u64, Indexes>::new("test_map", indexes); + let mut store = MockStorage::new(); + + map.save(&mut store, "one", &1).unwrap(); + map.save(&mut store, "two", &2).unwrap(); + map.save(&mut store, "three", &3).unwrap(); + + // Inclusive bound + let items: Vec<_> = map + .idx + .secondary + .range_raw(&store, None, Some(Bound::inclusive(1u64)), Order::Ascending) + .collect::>() + .unwrap(); + + // Strip the index from values (for simpler comparison) + let items: Vec<_> = items.into_iter().map(|(_, v)| v).collect(); + + assert_eq!(items, vec![1]); + + // Exclusive bound + let items: Vec<_> = map + .idx + .secondary + .range(&store, Some(Bound::exclusive(2u64)), None, Order::Ascending) + .collect::>() + .unwrap(); + + assert_eq!(items, vec![((), 3)]); + } + } + + mod bounds_multi_index { use super::*; struct Indexes<'a> { @@ -1456,7 +1508,10 @@ mod test { .collect::>() .unwrap(); - assert_eq!(items, vec![("two2".to_string(), 2), ("three".to_string(), 3)]); + assert_eq!( + items, + vec![("two2".to_string(), 2), ("three".to_string(), 3)] + ); } } } From 135db188b31c750b3620342df9178633c7922afd Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 23 Feb 2022 09:04:14 +0100 Subject: [PATCH 264/352] Fix syntax / details --- packages/storage-plus/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/storage-plus/README.md b/packages/storage-plus/README.md index 17a439f31..fb1c03b87 100644 --- a/packages/storage-plus/README.md +++ b/packages/storage-plus/README.md @@ -188,7 +188,7 @@ fn demo() -> StdResult<()> { ### Key types A `Map` key can be anything that implements the `PrimaryKey` trait. There are a series of implementations of -`PrimaryKey` already provided (see [keys.rs](src/keys.rs)): +`PrimaryKey` already provided (see [keys.rs](./src/keys.rs)): - `impl<'a> PrimaryKey<'a> for &'a [u8]` - `impl<'a> PrimaryKey<'a> for &'a str` @@ -211,8 +211,8 @@ legitimate address, and not random text which will fail later. `pub fn addr_validate(&self, &str) -> Addr` in `deps.api` can be used for address validation, and the returned `Addr` can then be conveniently used as key in a `Map` or similar structure. -It's also convenient to use references (i.e. borrowed values) instead of values for keys (i.e. `&Addr` instead of `Addr`) -, as that will typically save some cloning during key reading / writing. +It's also convenient to use references (i.e. borrowed values) instead of values for keys (i.e. `&Addr` instead of `Addr`), +as that will typically save some cloning during key reading / writing. ### Composite Keys @@ -485,7 +485,7 @@ Then, this `TokenInfo` data will be indexed by token `owner` (which is an `Addr` an owner has. That's why the `owner` index key is `Addr`. Other important thing here is that the key (and its components, in the case of a composite key) must implement -the `PrimaryKey` trait. You can see that `Addr` do implements `PrimaryKey`: +the `PrimaryKey` trait. You can see that `Addr` does implement `PrimaryKey`: ```rust impl<'a> PrimaryKey<'a> for Addr { @@ -615,12 +615,12 @@ the primary key to it. This `PK` type specification is also important for `MultiIndex` type-safe bounds, as the primary key is part of the multi-index key. See next section, [Type-safe bounds over MultiIndex](#type-safe-bounds-over-multiindex). -**NB**: This specification is still a manual (and therefore error-prone) process / setup, that will if possible +**NB**: This specification is still a manual (and therefore error-prone) process / setup, that will (if possible) be automated in the future (https://github.com/CosmWasm/cw-plus/issues/531). ### Type-safe bounds over MultiIndex -In the particular case of `MultiIndex`, this primary key (`PK`) type also defines the type of the (partial) bounds over +In the particular case of `MultiIndex`, the primary key (`PK`) type parameter also defines the type of the (partial) bounds over the index key (the part that corresponds to the primary key, that is). -So, to being able to correctly use type-safe bounds over multi-indexes ranges, it is fundamental for this `PK` type +So, to correctly use type-safe bounds over multi-indexes ranges, it is fundamental for this `PK` type to be correctly defined, so that it matches the primary key type, or its (typically owned) deserialization variant. From 22c0c213546f0b3e8aa59c8f5c482a58c0b89817 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 24 Feb 2022 21:53:12 +0100 Subject: [PATCH 265/352] Remove useless commas --- packages/storage-plus/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/README.md b/packages/storage-plus/README.md index fb1c03b87..ac07718fd 100644 --- a/packages/storage-plus/README.md +++ b/packages/storage-plus/README.md @@ -317,7 +317,7 @@ fn demo() -> StdResult<()> { In addition to getting one particular item out of a map, we can iterate over the map (or a subset of the map). This let us answer questions like "show me all tokens", -and we provide some nice [`Bound`](#bound) helpers to easily allow pagination, or custom ranges. +and we provide some nice [`Bound`](#bound) helpers to easily allow pagination or custom ranges. The general format is to get a `Prefix` by calling `map.prefix(k)`, where `k` is exactly one less item than the normal key (If `map.key()` took `(&[u8], &[u8])`, then `map.prefix()` takes `&[u8]`. @@ -326,7 +326,7 @@ over all items with `range(store, min, max, order)`. It supports `Order::Ascendi `min` is the lower bound and `max` is the higher bound. If the `min` and `max` bounds are `None`, `range` will return all items under the prefix. You can use `.take(n)` to -limit the results to `n` items, and start doing pagination. You can also set the `min` bound to +limit the results to `n` items and start doing pagination. You can also set the `min` bound to eg. `Bound::exclusive(last_value)` to start iterating over all items *after* the last value. Combined with `take`, we easily have pagination support. You can also use `Bound::inclusive(x)` when you want to include any perfect matches. From 88d6bffa542ffe7872f664f5d693b21a0890e406 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 7 Mar 2022 17:04:01 +0100 Subject: [PATCH 266/352] Upgrade cosmwasm to 1.0.0-beta6 --- Cargo.lock | 27 ++++++++++++++++--------- contracts/cw1-subkeys/Cargo.toml | 4 ++-- contracts/cw1-whitelist-ng/Cargo.toml | 4 ++-- contracts/cw1-whitelist/Cargo.toml | 4 ++-- contracts/cw1155-base/Cargo.toml | 4 ++-- contracts/cw20-base/Cargo.toml | 4 ++-- contracts/cw20-ics20/Cargo.toml | 4 ++-- contracts/cw3-fixed-multisig/Cargo.toml | 4 ++-- contracts/cw3-flex-multisig/Cargo.toml | 4 ++-- contracts/cw4-group/Cargo.toml | 4 ++-- contracts/cw4-stake/Cargo.toml | 4 ++-- packages/controllers/Cargo.toml | 2 +- packages/cw1/Cargo.toml | 4 ++-- packages/cw1155/Cargo.toml | 4 ++-- packages/cw2/Cargo.toml | 2 +- packages/cw20/Cargo.toml | 4 ++-- packages/cw3/Cargo.toml | 4 ++-- packages/cw4/Cargo.toml | 4 ++-- packages/multi-test/Cargo.toml | 4 ++-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 2 +- 21 files changed, 53 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8c4ce5e5..14813c3bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -155,9 +155,9 @@ checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" [[package]] name = "cosmwasm-crypto" -version = "1.0.0-beta5" +version = "1.0.0-beta6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8904127a5b9e325ef5d6b2b3f997dcd74943cd35097139b1a4d15b1b6bccae66" +checksum = "2dddc1443004c6340e55ca66d98e9d2f1a44aadf4ce2bed2c4f29baa8a15e7b7" dependencies = [ "digest", "ed25519-zebra", @@ -168,18 +168,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.0.0-beta5" +version = "1.0.0-beta6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a14364ac4d9d085867929d0cf3e94b1d2100121ce02c33c72961406830002613" +checksum = "fe4f0f10f165b8bcc558a13cddb498140960544519aa0581532c766dd80b5598" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.0.0-beta5" +version = "1.0.0-beta6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2941b87c42620d348e96ed05876bfda0dc1d5454a646d780d32f114c04921d" +checksum = "497432aa9a8e154e3789845f64049d088eb797ba5a7f78da312153f46c822388" dependencies = [ "schemars", "serde_json", @@ -187,13 +187,14 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.0.0-beta5" +version = "1.0.0-beta6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2ece12e5bbde434b93937d7b2107e6291f11d69ffa72398c50e8bab41d451d3" +checksum = "2f0f3145097b692b2d95fa5d2c7c6fdd60f193ccc709857e7e1987a608725300" dependencies = [ "base64", "cosmwasm-crypto", "cosmwasm-derive", + "forward_ref", "schemars", "serde", "serde-json-wasm", @@ -203,9 +204,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.0.0-beta5" +version = "1.0.0-beta6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e4338d8e9934effa4594f139ce4e5f4b426796b70e2d53bb7e8605e9adf68c" +checksum = "2945b2c28f64a09e1831f8f830641dc86b39b374c211215e88f2252f474dcb6e" dependencies = [ "cosmwasm-std", "serde", @@ -744,6 +745,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "forward_ref" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" + [[package]] name = "generic-array" version = "0.14.5" diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index db313da0a..8ebebea6d 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -23,7 +23,7 @@ cw-utils = { path = "../../packages/utils", version = "0.12.1" } cw1 = { path = "../../packages/cw1", version = "0.12.1" } cw2 = { path = "../../packages/cw2", version = "0.12.1" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.1", features = ["library"] } -cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = "1.0.23" semver = "1" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.1", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index 89e20e1e9..04732dc59 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -25,7 +25,7 @@ multitest = ["cw-multi-test", "anyhow"] cw-utils = { path = "../../packages/utils", version = "0.12.1" } cw1 = { path = "../../packages/cw1", version = "0.12.1" } cw2 = { path = "../../packages/cw2", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -36,6 +36,6 @@ anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index ac7e9ed28..05995e64b 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -22,7 +22,7 @@ test-utils = [] cw-utils = { path = "../../packages/utils", version = "0.12.1" } cw1 = { path = "../../packages/cw1", version = "0.12.1" } cw2 = { path = "../../packages/cw2", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } +cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,6 +31,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] anyhow = "1" assert_matches = "1" -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index e6197e527..834ac65b2 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -22,10 +22,10 @@ cw-utils = { path = "../../packages/utils", version = "0.12.1" } cw2 = { path = "../../packages/cw2", version = "0.12.1" } cw1155 = { path = "../../packages/cw1155", version = "0.12.1" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index 03acef104..061e093be 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -22,10 +22,10 @@ cw-utils = { path = "../../packages/utils", version = "0.12.1" } cw2 = { path = "../../packages/cw2", version = "0.12.1" } cw20 = { path = "../../packages/cw20", version = "0.12.1" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 2b10d4857..d36fa5d2a 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -21,7 +21,7 @@ library = [] cw-utils = { path = "../../packages/utils", version = "0.12.1" } cw2 = { path = "../../packages/cw2", version = "0.12.1" } cw20 = { path = "../../packages/cw20", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5", features = ["stargate"] } +cosmwasm-std = { version = "1.0.0-beta6", features = ["stargate"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } cw-controllers = { path = "../../packages/controllers", version = "0.12.1" } schemars = "0.8.1" @@ -30,4 +30,4 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index b1388a00b..089861193 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -22,13 +22,13 @@ cw-utils = { path = "../../packages/utils", version = "0.12.1" } cw2 = { path = "../../packages/cw2", version = "0.12.1" } cw3 = { path = "../../packages/cw3", version = "0.12.1" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } cw20 = { path = "../../packages/cw20", version = "0.12.1" } cw20-base = { path = "../cw20-base", version = "0.12.1", features = ["library"] } cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index e4f032420..e397f673a 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -24,12 +24,12 @@ cw3 = { path = "../../packages/cw3", version = "0.12.1" } cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.12.1", features = ["library"] } cw4 = { path = "../../packages/cw4", version = "0.12.1" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } cw4-group = { path = "../cw4-group", version = "0.12.1" } cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index b2038f155..842cede30 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -31,10 +31,10 @@ cw2 = { path = "../../packages/cw2", version = "0.12.1" } cw4 = { path = "../../packages/cw4", version = "0.12.1" } cw-controllers = { path = "../../packages/controllers", version = "0.12.1" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index a3086f48c..7ed93addc 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -32,10 +32,10 @@ cw4 = { path = "../../packages/cw4", version = "0.12.1" } cw20 = { path = "../../packages/cw20", version = "0.12.1" } cw-controllers = { path = "../../packages/controllers", version = "0.12.1" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index 17ee89281..4739bb0e9 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -12,7 +12,7 @@ documentation = "https://docs.cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } cw-utils = { path = "../utils", version = "0.12.1" } cw-storage-plus = { path = "../storage-plus", version = "0.12.1" } schemars = "0.8.1" diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index 8b3017c2d..6cac3d9fd 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -10,9 +10,9 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index e81f36c92..8ae9a6204 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 675d2ecfe..b23fc717d 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0-beta5", default-features = false } +cosmwasm-std = { version = "1.0.0-beta6", default-features = false } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index c24708e85..3d027f622 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index 98dcc64af..a643a0f76 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index 77c20b649..f61dd94f8 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-storage-plus = { path = "../storage-plus", version = "0.12.1" } -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta5" } +cosmwasm-schema = { version = "1.0.0-beta6" } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index f39042c1d..3da22ef5a 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -20,8 +20,8 @@ backtrace = ["anyhow/backtrace"] [dependencies] cw-utils = { path = "../../packages/utils", version = "0.12.1" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1"} -cosmwasm-std = { version = "1.0.0-beta5", features = ["staking"] } -cosmwasm-storage = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } +cosmwasm-storage = { version = "1.0.0-beta6" } itertools = "0.10.1" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 1e22dd983..1d8d3f0cc 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -18,7 +18,7 @@ iterator = ["cosmwasm-std/iterator"] bench = false [dependencies] -cosmwasm-std = { version = "1.0.0-beta5", default-features = false } +cosmwasm-std = { version = "1.0.0-beta6", default-features = false } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index f2ab10026..82ad9e35a 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -12,7 +12,7 @@ documentation = "https://docs.cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0-beta5" } +cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } From 45a2776b46ca604b03fd5139b64cca6fa8c7d9c3 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Mar 2022 11:06:01 +0100 Subject: [PATCH 267/352] Adapt code to ContractResult -> SubMsgResult change --- contracts/cw20-ics20/src/ibc.rs | 16 ++++++++-------- .../src/test_helpers/contracts/echo.rs | 6 +++--- packages/multi-test/src/wasm.rs | 10 +++++----- packages/utils/src/parse_reply.rs | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index f666db322..add61ac5f 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -2,10 +2,10 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{ - attr, entry_point, from_binary, to_binary, BankMsg, Binary, ContractResult, CosmosMsg, Deps, - DepsMut, Env, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, - IbcChannelOpenMsg, IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, - IbcPacketTimeoutMsg, IbcReceiveResponse, Reply, Response, SubMsg, Uint128, WasmMsg, + attr, entry_point, from_binary, to_binary, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, + IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, + IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, + IbcReceiveResponse, Reply, Response, SubMsg, SubMsgResult, Uint128, WasmMsg, }; use crate::amount::Amount; @@ -87,8 +87,8 @@ const ACK_FAILURE_ID: u64 = 0xfa17; pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> Result { match reply.id { RECEIVE_ID => match reply.result { - ContractResult::Ok(_) => Ok(Response::new()), - ContractResult::Err(err) => { + SubMsgResult::Ok(_) => Ok(Response::new()), + SubMsgResult::Err(err) => { // Important design note: with ibcv2 and wasmd 0.22 we can implement this all much easier. // No reply needed... the receive function and submessage should return error on failure and all // state gets reverted with a proper app-level message auto-generated @@ -113,8 +113,8 @@ pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> Result match reply.result { - ContractResult::Ok(_) => Ok(Response::new()), - ContractResult::Err(err) => Ok(Response::new().set_data(ack_fail(err))), + SubMsgResult::Ok(_) => Ok(Response::new()), + SubMsgResult::Err(err) => Ok(Response::new().set_data(ack_fail(err))), }, _ => Err(ContractError::UnknownReplyId { id: reply.id }), } diff --git a/packages/multi-test/src/test_helpers/contracts/echo.rs b/packages/multi-test/src/test_helpers/contracts/echo.rs index 71737d530..c1d51b3a5 100644 --- a/packages/multi-test/src/test_helpers/contracts/echo.rs +++ b/packages/multi-test/src/test_helpers/contracts/echo.rs @@ -4,8 +4,8 @@ //! Additionally it bypass all events and attributes send to it use cosmwasm_std::{ - to_binary, Attribute, Binary, ContractResult, Deps, DepsMut, Empty, Env, Event, MessageInfo, - Reply, Response, StdError, SubMsg, SubMsgExecutionResponse, + to_binary, Attribute, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Reply, Response, + StdError, SubMsg, SubMsgExecutionResponse, SubMsgResult, }; use serde::{de::DeserializeOwned, Deserialize, Serialize}; @@ -98,7 +98,7 @@ where if let Reply { id, result: - ContractResult::Ok(SubMsgExecutionResponse { + SubMsgResult::Ok(SubMsgExecutionResponse { data: Some(data), .. }), } = msg diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index ce793c3af..513535230 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -4,9 +4,9 @@ use std::ops::Deref; use cosmwasm_std::{ to_binary, Addr, Api, Attribute, BankMsg, Binary, BlockInfo, Coin, ContractInfo, - ContractInfoResponse, ContractResult, CustomQuery, Deps, DepsMut, Env, Event, MessageInfo, - Order, Querier, QuerierWrapper, Reply, ReplyOn, Response, StdResult, Storage, SubMsg, - SubMsgExecutionResponse, TransactionInfo, WasmMsg, WasmQuery, + ContractInfoResponse, CustomQuery, Deps, DepsMut, Env, Event, MessageInfo, Order, Querier, + QuerierWrapper, Reply, ReplyOn, Response, StdResult, Storage, SubMsg, SubMsgExecutionResponse, + SubMsgResult, TransactionInfo, WasmMsg, WasmQuery, }; use cosmwasm_storage::{prefixed, prefixed_read, PrefixedStorage, ReadonlyPrefixedStorage}; use prost::Message; @@ -436,7 +436,7 @@ where if matches!(reply_on, ReplyOn::Always | ReplyOn::Success) { let reply = Reply { id, - result: ContractResult::Ok(SubMsgExecutionResponse { + result: SubMsgResult::Ok(SubMsgExecutionResponse { events: r.events.clone(), data: r.data, }), @@ -457,7 +457,7 @@ where if matches!(reply_on, ReplyOn::Always | ReplyOn::Error) { let reply = Reply { id, - result: ContractResult::Err(e.to_string()), + result: SubMsgResult::Err(e.to_string()), }; self._reply(api, router, storage, block, contract, reply) } else { diff --git a/packages/utils/src/parse_reply.rs b/packages/utils/src/parse_reply.rs index 37e1a27ca..3b61f7474 100644 --- a/packages/utils/src/parse_reply.rs +++ b/packages/utils/src/parse_reply.rs @@ -168,7 +168,7 @@ pub enum ParseReplyError { mod test { use super::*; use crate::parse_reply::ParseReplyError::{BrokenUtf8, ParseFailure}; - use cosmwasm_std::{ContractResult, SubMsgExecutionResponse}; + use cosmwasm_std::{SubMsgExecutionResponse, SubMsgResult}; use prost::Message; use std::str::from_utf8; @@ -466,7 +466,7 @@ mod test { // Build reply message let msg = Reply { id: 1, - result: ContractResult::Ok(SubMsgExecutionResponse { + result: SubMsgResult::Ok(SubMsgExecutionResponse { events: vec![], data: Some(encoded_instantiate_reply.into()), }), @@ -514,7 +514,7 @@ mod test { // Build reply message let msg = Reply { id: 1, - result: ContractResult::Ok(SubMsgExecutionResponse { + result: SubMsgResult::Ok(SubMsgExecutionResponse { events: vec![], data: Some(encoded_execute_reply.into()), }), From 907cea7604423511406b16462e261b3ce1e6e97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kuras?= Date: Wed, 9 Mar 2022 12:41:14 +0100 Subject: [PATCH 268/352] Cargo.lock update --- Cargo.lock | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14813c3bf..87edbf431 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "anyhow" -version = "1.0.53" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" +checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" dependencies = [ "backtrace", ] @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.72" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cfg-if" @@ -774,9 +774,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" +checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" dependencies = [ "cfg-if", "libc", @@ -881,9 +881,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.117" +version = "0.2.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" +checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" [[package]] name = "log" @@ -1046,14 +1046,13 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", "rand_core 0.6.3", - "rand_hc", ] [[package]] @@ -1081,16 +1080,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.4", -] - -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core 0.6.3", + "getrandom 0.2.5", ] [[package]] @@ -1120,9 +1110,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ "regex-syntax", ] @@ -1201,9 +1191,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0486718e92ec9a68fbed73bb5ef687d71103b142595b406835649bebd33f72c7" +checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d" [[package]] name = "serde" From bfffaec066f3887bdfff41db9cec70224af96f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kuras?= Date: Wed, 9 Mar 2022 12:41:46 +0100 Subject: [PATCH 269/352] Set version: 0.13.0 --- Cargo.lock | 40 ++++++++++++------------- contracts/cw1-subkeys/Cargo.toml | 14 ++++----- contracts/cw1-whitelist-ng/Cargo.toml | 14 ++++----- contracts/cw1-whitelist/Cargo.toml | 12 ++++---- contracts/cw1155-base/Cargo.toml | 10 +++---- contracts/cw20-base/Cargo.toml | 10 +++---- contracts/cw20-ics20/Cargo.toml | 12 ++++---- contracts/cw3-fixed-multisig/Cargo.toml | 16 +++++----- contracts/cw3-flex-multisig/Cargo.toml | 18 +++++------ contracts/cw4-group/Cargo.toml | 12 ++++---- contracts/cw4-stake/Cargo.toml | 14 ++++----- packages/controllers/Cargo.toml | 6 ++-- packages/cw1/Cargo.toml | 2 +- packages/cw1155/Cargo.toml | 4 +-- packages/cw2/Cargo.toml | 4 +-- packages/cw20/Cargo.toml | 4 +-- packages/cw3/Cargo.toml | 4 +-- packages/cw4/Cargo.toml | 4 +-- packages/multi-test/Cargo.toml | 6 ++-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 4 +-- 21 files changed, 106 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 87edbf431..64a8f025b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -366,7 +366,7 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -378,7 +378,7 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.12.1" +version = "0.13.0" dependencies = [ "anyhow", "cosmwasm-std", @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-std", "criterion", @@ -406,7 +406,7 @@ dependencies = [ [[package]] name = "cw-utils" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -418,7 +418,7 @@ dependencies = [ [[package]] name = "cw1" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -428,7 +428,7 @@ dependencies = [ [[package]] name = "cw1-subkeys" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -445,7 +445,7 @@ dependencies = [ [[package]] name = "cw1-whitelist" -version = "0.12.1" +version = "0.13.0" dependencies = [ "anyhow", "assert_matches", @@ -464,7 +464,7 @@ dependencies = [ [[package]] name = "cw1-whitelist-ng" -version = "0.12.1" +version = "0.13.0" dependencies = [ "anyhow", "assert_matches", @@ -483,7 +483,7 @@ dependencies = [ [[package]] name = "cw1155" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -494,7 +494,7 @@ dependencies = [ [[package]] name = "cw1155-base" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -509,7 +509,7 @@ dependencies = [ [[package]] name = "cw2" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -519,7 +519,7 @@ dependencies = [ [[package]] name = "cw20" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -530,7 +530,7 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -545,7 +545,7 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -562,7 +562,7 @@ dependencies = [ [[package]] name = "cw3" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -573,7 +573,7 @@ dependencies = [ [[package]] name = "cw3-fixed-multisig" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -591,7 +591,7 @@ dependencies = [ [[package]] name = "cw3-flex-multisig" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -610,7 +610,7 @@ dependencies = [ [[package]] name = "cw4" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -621,7 +621,7 @@ dependencies = [ [[package]] name = "cw4-group" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -637,7 +637,7 @@ dependencies = [ [[package]] name = "cw4-stake" -version = "0.12.1" +version = "0.13.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 8ebebea6d..666e7af0a 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-subkeys" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Implement subkeys for authorizing native tokens as a cw1 proxy contract" @@ -19,12 +19,12 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw1 = { path = "../../packages/cw1", version = "0.12.1" } -cw2 = { path = "../../packages/cw2", version = "0.12.1" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.1", features = ["library"] } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw1 = { path = "../../packages/cw1", version = "0.13.0" } +cw2 = { path = "../../packages/cw2", version = "0.13.0" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.0", features = ["library"] } cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.23" @@ -32,4 +32,4 @@ semver = "1" [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta6" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.12.1", features = ["library", "test-utils"] } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.0", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index 04732dc59..fe81fc847 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist-ng" -version = "0.12.1" +version = "0.13.0" authors = ["Bartłomiej Kuras "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -22,20 +22,20 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw1 = { path = "../../packages/cw1", version = "0.12.1" } -cw2 = { path = "../../packages/cw2", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw1 = { path = "../../packages/cw1", version = "0.13.0" } +cw2 = { path = "../../packages/cw2", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1", optional = true } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.0", optional = true } anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta6" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.0" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index 05995e64b..94ee651dc 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw1 = { path = "../../packages/cw1", version = "0.12.1" } -cw2 = { path = "../../packages/cw2", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw1 = { path = "../../packages/cw1", version = "0.13.0" } +cw2 = { path = "../../packages/cw2", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -32,5 +32,5 @@ thiserror = { version = "1.0.23" } anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta6" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.0" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 834ac65b2..36650e506 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155-base" -version = "0.12.1" +version = "0.13.0" authors = ["Huang Yi "] edition = "2018" description = "Basic implementation of a CosmWasm-1155 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw2 = { path = "../../packages/cw2", version = "0.12.1" } -cw1155 = { path = "../../packages/cw1155", version = "0.12.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw2 = { path = "../../packages/cw2", version = "0.13.0" } +cw1155 = { path = "../../packages/cw1155", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index 061e093be..ff894a876 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-base" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation of a CosmWasm-20 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw2 = { path = "../../packages/cw2", version = "0.12.1" } -cw20 = { path = "../../packages/cw20", version = "0.12.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw2 = { path = "../../packages/cw2", version = "0.13.0" } +cw20 = { path = "../../packages/cw20", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index d36fa5d2a..187dbf89d 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw2 = { path = "../../packages/cw2", version = "0.12.1" } -cw20 = { path = "../../packages/cw20", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw2 = { path = "../../packages/cw2", version = "0.13.0" } +cw20 = { path = "../../packages/cw20", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6", features = ["stargate"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } -cw-controllers = { path = "../../packages/controllers", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.0" } schemars = "0.8.1" semver = "1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index 089861193..06b2b40eb 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-fixed-multisig" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with an fixed group multisig" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw2 = { path = "../../packages/cw2", version = "0.12.1" } -cw3 = { path = "../../packages/cw3", version = "0.12.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw2 = { path = "../../packages/cw2", version = "0.13.0" } +cw3 = { path = "../../packages/cw3", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -29,6 +29,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta6" } -cw20 = { path = "../../packages/cw20", version = "0.12.1" } -cw20-base = { path = "../cw20-base", version = "0.12.1", features = ["library"] } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } +cw20 = { path = "../../packages/cw20", version = "0.13.0" } +cw20-base = { path = "../cw20-base", version = "0.13.0", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.0" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index e397f673a..ea7d9eb21 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-flex-multisig" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with multiple voting patterns and dynamic groups" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw2 = { path = "../../packages/cw2", version = "0.12.1" } -cw3 = { path = "../../packages/cw3", version = "0.12.1" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.12.1", features = ["library"] } -cw4 = { path = "../../packages/cw4", version = "0.12.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw2 = { path = "../../packages/cw2", version = "0.13.0" } +cw3 = { path = "../../packages/cw3", version = "0.13.0" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.13.0", features = ["library"] } +cw4 = { path = "../../packages/cw4", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta6" } -cw4-group = { path = "../cw4-group", version = "0.12.1" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.12.1" } +cw4-group = { path = "../cw4-group", version = "0.13.0" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.0" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index 842cede30..7e41d420a 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-group" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Simple cw4 implementation of group membership controlled by admin " @@ -26,11 +26,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw2 = { path = "../../packages/cw2", version = "0.12.1" } -cw4 = { path = "../../packages/cw4", version = "0.12.1" } -cw-controllers = { path = "../../packages/controllers", version = "0.12.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw2 = { path = "../../packages/cw2", version = "0.13.0" } +cw4 = { path = "../../packages/cw4", version = "0.13.0" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index 7ed93addc..70c422e85 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-stake" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "CW4 implementation of group based on staked tokens" @@ -26,12 +26,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw2 = { path = "../../packages/cw2", version = "0.12.1" } -cw4 = { path = "../../packages/cw4", version = "0.12.1" } -cw20 = { path = "../../packages/cw20", version = "0.12.1" } -cw-controllers = { path = "../../packages/controllers", version = "0.12.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw2 = { path = "../../packages/cw2", version = "0.13.0" } +cw4 = { path = "../../packages/cw4", version = "0.13.0" } +cw20 = { path = "../../packages/cw20", version = "0.13.0" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index 4739bb0e9..28a99ae27 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-controllers" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Common controllers we can reuse in many contracts" @@ -13,8 +13,8 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta6" } -cw-utils = { path = "../utils", version = "0.12.1" } -cw-storage-plus = { path = "../storage-plus", version = "0.12.1" } +cw-utils = { path = "../utils", version = "0.13.0" } +cw-storage-plus = { path = "../storage-plus", version = "0.13.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index 6cac3d9fd..bf0d428d9 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-1 interface" diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 8ae9a6204..96ab68f95 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155" -version = "0.12.1" +version = "0.13.0" authors = ["Huang Yi "] edition = "2018" description = "Definition and types for the CosmWasm-1155 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index b23fc717d..501b2eba6 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw2" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-2 interface" @@ -11,6 +11,6 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta6", default-features = false } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index 3d027f622..383a789cd 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-20 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index a643a0f76..6720ae812 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-3 Interface: On-Chain MultiSig/Voting contracts" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index f61dd94f8..6ad539d43 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-4 Interface: Groups Members" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-storage-plus = { path = "../storage-plus", version = "0.12.1" } +cw-storage-plus = { path = "../storage-plus", version = "0.13.0" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index 3da22ef5a..ed91c3c7d 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-multi-test" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Test helpers for multi-contract interactions" @@ -18,8 +18,8 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.12.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1"} +cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0"} cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } cosmwasm-storage = { version = "1.0.0-beta6" } itertools = "0.10.1" diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 1d8d3f0cc..7d49d877e 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-storage-plus" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Enhanced/experimental storage engines" diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index 82ad9e35a..da0e411f5 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-utils" -version = "0.12.1" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Common helpers for other cw specs" @@ -18,5 +18,5 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } [dev-dependencies] -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.12.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } prost = "0.9" From 320ea83b409c5cd0993a06b4146d6e124e5e666c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kuras?= Date: Wed, 9 Mar 2022 12:47:57 +0100 Subject: [PATCH 270/352] Changelog update for 0.13.0 --- CHANGELOG.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 731c7c808..b6969264f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,26 @@ # Changelog -## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) +## [v0.13.0](https://github.com/CosmWasm/cw-plus/tree/v0.13.0) (2022-03-09) [Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.1...HEAD) +**Breaking changes:** + +- Fix `MultiIndex` last type param default / docs [\#669](https://github.com/CosmWasm/cw-plus/issues/669) + +**Closed issues:** + +- Querying over composite key [\#664](https://github.com/CosmWasm/cw-plus/issues/664) +- the method `may_load` exists for struct `cw_storage_plus::Map<'static, (std::string::String, Uint256), Uint256>`, but its trait bounds were not satisfied the following trait bounds were not satisfied: `(std::string::String, Uint256): PrimaryKey` [\#663](https://github.com/CosmWasm/cw-plus/issues/663) +- Make `Bound` helpers return `Option` [\#644](https://github.com/CosmWasm/cw-plus/issues/644) + +**Merged pull requests:** + +- Update cosmwasm to 1.0.0-beta6 [\#672](https://github.com/CosmWasm/cw-plus/pull/672) ([webmaster128](https://github.com/webmaster128)) +- Update storage plus docs / Remove `MultiIndex` PK default [\#671](https://github.com/CosmWasm/cw-plus/pull/671) ([maurolacy](https://github.com/maurolacy)) +- fix: Remove old TODO comment in cw3-flex readme [\#661](https://github.com/CosmWasm/cw-plus/pull/661) ([apollo-sturdy](https://github.com/apollo-sturdy)) +- Properly handle generic queries in multi-test [\#660](https://github.com/CosmWasm/cw-plus/pull/660) ([ethanfrey](https://github.com/ethanfrey)) + ## [v0.12.1](https://github.com/CosmWasm/cw-plus/tree/v0.12.1) (2022-02-14) [Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.0...v0.12.1) From ce4aeda0e5516a4dd1e4741a4b11db61e30bec6a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 9 Mar 2022 13:39:29 +0100 Subject: [PATCH 271/352] Fix v0.13.0 changelog entry --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6969264f..ff503d3f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ # Changelog +## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.0...HEAD) + ## [v0.13.0](https://github.com/CosmWasm/cw-plus/tree/v0.13.0) (2022-03-09) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.1...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.12.1...0.13.0) **Breaking changes:** From 44f65e674c780c2b61a1ab529db69a7e8d8f4da5 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 9 Mar 2022 15:17:12 +0100 Subject: [PATCH 272/352] Add "add upcoming entry" option to update_changelog --- scripts/update_changelog.sh | 38 +++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/scripts/update_changelog.sh b/scripts/update_changelog.sh index 6b2900615..36fe6cbc8 100755 --- a/scripts/update_changelog.sh +++ b/scripts/update_changelog.sh @@ -1,19 +1,28 @@ #!/bin/bash - +set -o errexit -o pipefail ORIGINAL_OPTS=$* -OPTS=$(getopt -l "help,since-tag:,full,token:" -o "hft" -- "$@") || exit 1 +OPTS=$(getopt -l "help,since-tag:,upcoming-tag:,full,token:" -o "hu:ft" -- "$@") || exit 1 + +function print_usage() { + echo -e "Usage: $0 [-h|--help] [-f|--full] [--since-tag ] [-u|--upcoming-tag] [-t|--token ] +-h, --help Display help +-f, --full Process changes since the beginning (by default: since latest git version tag) +--since-tag Process changes since git version tag (by default: since latest git version tag) +-u, --upcoming-tag Add a title in CHANGELOG for the new changes +--token Pass changelog github token " +} + +function remove_opt() { + ORIGINAL_OPTS=$(echo "$ORIGINAL_OPTS" | sed "s/\\B$1\\b//") +} eval set -- "$OPTS" while true do case $1 in -h|--help) - echo -e "Usage: $0 [-h|--help] [-f|--full] [--since-tag ] [-t|--token ] --h, --help Display help --f, --full Process changes since the beginning (by default: since latest git version tag) ---since-tag Process changes since git version tag (by default: since latest git version tag) ---token Pass changelog github token " + print_usage exit 0 ;; --since-tag) @@ -22,7 +31,13 @@ case $1 in ;; -f|--full) TAG="" - ORIGINAL_OPTS=$(echo "$ORIGINAL_OPTS" | sed "s/\\B$1\\b//") + remove_opt $1 + ;; + -u|--upcoming-tag) + remove_opt $1 + shift + UPCOMING_TAG="$1" + remove_opt $1 ;; --) shift @@ -50,4 +65,11 @@ sed -i -n "/^## \\[${TAG}[^]]*\\]/,\$p" CHANGELOG.md github_changelog_generator -u CosmWasm -p cw-plus --base CHANGELOG.md $ORIGINAL_OPTS || cp /tmp/CHANGELOG.md.$$ CHANGELOG.md +if [ -n "$UPCOMING_TAG" ] +then + # Add "upcoming" version tag + TODAY=$(date "+%Y-%m-%d") + sed -i "s+\[Full Changelog\](https://github.com/CosmWasm/cw-plus/compare/\(.*\)\.\.\.HEAD)+[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/$UPCOMING_TAG...HEAD)\n\n## [$UPCOMING_TAG](https://github.com/CosmWasm/cw-plus/tree/$UPCOMING_TAG) ($TODAY)\n\n[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/\1...$UPCOMING_TAG)+" CHANGELOG.md +fi + rm -f /tmp/CHANGELOG.md.$$ From 592e3154242cdef1870b1d201a294689a40a77c1 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 9 Mar 2022 15:19:06 +0100 Subject: [PATCH 273/352] Add --help for set_version --- scripts/set_version.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/set_version.sh b/scripts/set_version.sh index 26987c1ff..019b8125d 100755 --- a/scripts/set_version.sh +++ b/scripts/set_version.sh @@ -1,14 +1,14 @@ #!/bin/bash set -o errexit -o nounset -o pipefail -command -v shellcheck > /dev/null && shellcheck "$0" +command -v shellcheck >/dev/null && shellcheck "$0" function print_usage() { - echo "Usage: $0 NEW_VERSION" - echo "" - echo "e.g. $0 0.8.0" + echo "Usage: $0 [-h|--help] " + echo "e.g.: $0 0.8.0" } -if [ "$#" -ne 1 ]; then +if [ "$#" -ne 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] +then print_usage exit 1 fi From 160fb06697f91162bbdeea5861357a297296facd Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 9 Mar 2022 15:21:21 +0100 Subject: [PATCH 274/352] Add --help to publish.sh --- scripts/publish.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index 8c4bee118..afd4c696b 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -1,6 +1,17 @@ #!/bin/bash set -o errexit -o nounset -o pipefail -command -v shellcheck > /dev/null && shellcheck "$0" +command -v shellcheck >/dev/null && shellcheck "$0" + +function print_usage() { + echo "Usage: $0 [-h|--help]" + echo "Publishes crates to crates.io." +} + +if [ "$1" = "-h" ] || [ "$1" = "--help" ] +then + print_usage + exit 1 +fi # this should really more to cosmwasm... STORAGE_PACKAGES="storage-plus" From 99d06a65a461da76bac2c626315f81dd36e8078e Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 9 Mar 2022 20:13:11 +0100 Subject: [PATCH 275/352] Clarify the stability of cw-storage-plus, no longer Experimental --- packages/storage-plus/Cargo.toml | 2 +- packages/storage-plus/README.md | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 7d49d877e..6032e7384 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -3,7 +3,7 @@ name = "cw-storage-plus" version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" -description = "Enhanced/experimental storage engines" +description = "Enhanced storage engines" license = "Apache-2.0" repository = "https://github.com/CosmWasm/cw-plus" homepage = "https://cosmwasm.com" diff --git a/packages/storage-plus/README.md b/packages/storage-plus/README.md index ac07718fd..2b1e53c0e 100644 --- a/packages/storage-plus/README.md +++ b/packages/storage-plus/README.md @@ -1,14 +1,25 @@ -# CW-Storage-Plus: Enhanced/experimental storage engines for CosmWasm +# CW-Storage-Plus: Enhanced storage engines for CosmWasm -The ideas in here are based on the `cosmwasm-storage` crate. However, -after much usage, we decided a complete rewrite could allow us to add -more powerful and easy to use interfaces. Here are those interfaces. +After building `cosmwasm-storage`, we realized many of the design decisions were +limiting us and producing a lot of needless boilerplate. The decision was made to leave +those APIs stable for anyone wanting a very basic abstraction on the KV-store and to +build a much more powerful and complex ORM layer that can provide powerful accessors +using complex key types, which are transparently turned into bytes. + +This led to a number of breaking API changes in this package of the course of several +releases as we updated this with lots of experience, user feedback, and deep dives to harness +the full power of generics. **Status: beta** -This has been heavily used in many production-quality contracts and -heavily refined. The code has demonstrated itself to be stable and powerful. -Please feel free to use it in your contracts. +As of `cw-storage-plus` `v0.12` the API should be quite stable. +There are no major API breaking issues pending, and all API changes will be documented +in [`MIGRATING.md`](../../MIGRATING.md). + +This has been heavily used in many production-quality contracts. +The code has demonstrated itself to be stable and powerful. +It has not been audited, and Confio assumes no liability, butwe consider it mature enough +to be the standard storage layer for your contracts. ## Usage Overview From c7acbb573bc911b2673ebfc066847bd05c686fed Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 10 Mar 2022 13:08:44 +0100 Subject: [PATCH 276/352] Update packages/storage-plus/README.md Co-authored-by: Jakub Bogucki --- packages/storage-plus/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/README.md b/packages/storage-plus/README.md index 2b1e53c0e..56c5b0f16 100644 --- a/packages/storage-plus/README.md +++ b/packages/storage-plus/README.md @@ -18,7 +18,7 @@ in [`MIGRATING.md`](../../MIGRATING.md). This has been heavily used in many production-quality contracts. The code has demonstrated itself to be stable and powerful. -It has not been audited, and Confio assumes no liability, butwe consider it mature enough +It has not been audited, and Confio assumes no liability, but we consider it mature enough to be the standard storage layer for your contracts. ## Usage Overview From bd110774cc182105e8ec6a8f83f04677059a1cc3 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 10 Mar 2022 13:08:50 +0100 Subject: [PATCH 277/352] Update packages/storage-plus/README.md Co-authored-by: Mauro Lacy --- packages/storage-plus/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/README.md b/packages/storage-plus/README.md index 56c5b0f16..3e2691df1 100644 --- a/packages/storage-plus/README.md +++ b/packages/storage-plus/README.md @@ -19,7 +19,7 @@ in [`MIGRATING.md`](../../MIGRATING.md). This has been heavily used in many production-quality contracts. The code has demonstrated itself to be stable and powerful. It has not been audited, and Confio assumes no liability, but we consider it mature enough -to be the standard storage layer for your contracts. +to be the **standard storage layer** for your contracts. ## Usage Overview From af19599fa38760431ffbbcfb43e8399d842415c9 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 13:15:46 +0100 Subject: [PATCH 278/352] Remove extra "v" field, act is if always set --- contracts/cw20-ics20/src/ibc.rs | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index add61ac5f..d46121f65 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -11,8 +11,8 @@ use cosmwasm_std::{ use crate::amount::Amount; use crate::error::{ContractError, Never}; use crate::state::{ - increase_channel_balance, reduce_channel_balance, undo_reduce_channel_balance, ChannelInfo, - ReplyArgs, ALLOW_LIST, CHANNEL_INFO, REPLY_ARGS, + reduce_channel_balance, undo_reduce_channel_balance, ChannelInfo, ReplyArgs, ALLOW_LIST, + CHANNEL_INFO, REPLY_ARGS, }; use cw20::Cw20ExecuteMsg; @@ -32,12 +32,8 @@ pub struct Ics20Packet { pub receiver: String, /// the sender address pub sender: String, - /// used only by us to control ack handling - pub v: Option, } -const V2: u32 = 2; - impl Ics20Packet { pub fn new>(amount: Uint128, denom: T, sender: &str, receiver: &str) -> Self { Ics20Packet { @@ -45,7 +41,6 @@ impl Ics20Packet { amount, sender: sender.to_string(), receiver: receiver.to_string(), - v: Some(V2), } } @@ -317,15 +312,9 @@ pub fn ibc_packet_timeout( } // update the balance stored on this (channel, denom) index -fn on_packet_success(deps: DepsMut, packet: IbcPacket) -> Result { +fn on_packet_success(_deps: DepsMut, packet: IbcPacket) -> Result { let msg: Ics20Packet = from_binary(&packet.data)?; - // if this was for an older (pre-v2) packet we send continue with old behavior - // (this is needed for transitioning on a system with pending packet) - if msg.v.is_none() { - increase_channel_balance(deps.storage, &packet.src.channel_id, &msg.denom, msg.amount)?; - } - // similar event messages like ibctransfer module let attributes = vec![ attr("action", "acknowledge"), @@ -347,10 +336,8 @@ fn on_packet_failure( ) -> Result { let msg: Ics20Packet = from_binary(&packet.data)?; - // undo the balance update (but not for pre-v2/None packets which didn't add before sending) - if msg.v.is_some() { - reduce_channel_balance(deps.storage, &packet.src.channel_id, &msg.denom, msg.amount)?; - } + // undo the balance update on failure (as we pre-emptively added it on send) + reduce_channel_balance(deps.storage, &packet.src.channel_id, &msg.denom, msg.amount)?; let to_send = Amount::from_parts(msg.denom.clone(), msg.amount); let gas_limit = check_gas_limit(deps.as_ref(), &to_send)?; @@ -426,7 +413,7 @@ mod test { "wasm1fucynrfkrt684pm8jrt8la5h2csvs5cnldcgqc", ); // Example message generated from the SDK - let expected = r#"{"amount":"12345","denom":"ucosm","receiver":"wasm1fucynrfkrt684pm8jrt8la5h2csvs5cnldcgqc","sender":"cosmos1zedxv25ah8fksmg2lzrndrpkvsjqgk4zt5ff7n","v":2}"#; + let expected = r#"{"amount":"12345","denom":"ucosm","receiver":"wasm1fucynrfkrt684pm8jrt8la5h2csvs5cnldcgqc","sender":"cosmos1zedxv25ah8fksmg2lzrndrpkvsjqgk4zt5ff7n"}"#; let encdoded = String::from_utf8(to_vec(&packet).unwrap()).unwrap(); assert_eq!(expected, encdoded.as_str()); @@ -474,7 +461,6 @@ mod test { amount: amount.into(), sender: "remote-sender".to_string(), receiver: receiver.to_string(), - v: Some(V2), }; print!("Packet denom: {}", &data.denom); IbcPacket::new( @@ -535,7 +521,6 @@ mod test { amount: Uint128::new(987654321), sender: "local-sender".to_string(), receiver: "remote-rcpt".to_string(), - v: Some(V2), }; let timeout = mock_env().block.time.plus_seconds(DEFAULT_TIMEOUT); assert_eq!( From 2aa334ab20d080135b09c0e4837d35b2e1ed4e01 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 13:34:07 +0100 Subject: [PATCH 279/352] Add new migration path for old contracts to the new logic --- contracts/cw20-ics20/src/contract.rs | 9 ++++-- contracts/cw20-ics20/src/migrations.rs | 40 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 706a16073..e04f4eb6e 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -13,7 +13,7 @@ use cw_storage_plus::Bound; use crate::amount::Amount; use crate::error::ContractError; use crate::ibc::Ics20Packet; -use crate::migrations::v1; +use crate::migrations::{v1, v2}; use crate::msg::{ AllowMsg, AllowedInfo, AllowedResponse, ChannelResponse, ConfigResponse, ExecuteMsg, InitMsg, ListAllowedResponse, ListChannelsResponse, MigrateMsg, PortResponse, QueryMsg, TransferMsg, @@ -199,9 +199,10 @@ pub fn execute_allow( const MIGRATE_MIN_VERSION: &str = "0.11.1"; const MIGRATE_VERSION_2: &str = "0.12.0-alpha1"; +const MIGRATE_VERSION_3: &str = "0.13.1"; #[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(mut deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { +pub fn migrate(mut deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result { let version: Version = CONTRACT_VERSION.parse().map_err(from_semver)?; let stored = get_contract_version(deps.storage)?; let storage_version: Version = stored.version.parse().map_err(from_semver)?; @@ -235,6 +236,10 @@ pub fn migrate(mut deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Resultv3 converstion if we are v2 style + if storage_version <= MIGRATE_VERSION_3.parse().map_err(from_semver)? { + v2::update_balances(deps.branch(), &env)?; + } // otherwise no migration (yet) - add them here // we don't need to save anything if migrating from the same version diff --git a/contracts/cw20-ics20/src/migrations.rs b/contracts/cw20-ics20/src/migrations.rs index e874569a0..4c79b6ffb 100644 --- a/contracts/cw20-ics20/src/migrations.rs +++ b/contracts/cw20-ics20/src/migrations.rs @@ -14,3 +14,43 @@ pub mod v1 { pub const CONFIG: Item = Item::new("ics20_config"); } + +// v2 format is anything older than 0.13.1 when we only updated the internal balances on success ack +pub mod v2 { + use crate::state::{CHANNEL_INFO, CHANNEL_STATE}; + use crate::ContractError; + use cosmwasm_std::{Coin, DepsMut, Env, Order, StdResult}; + + pub fn update_balances(deps: DepsMut, env: &Env) -> Result<(), ContractError> { + let channels = CHANNEL_INFO + .keys(deps.storage, None, None, Order::Ascending) + .collect::>>()?; + match channels.len() { + 0 => Ok(()), + 1 => { + let channel = &channels[0]; + let addr = &env.contract.address; + let states = CHANNEL_STATE + .prefix(channel) + .range(deps.storage, None, None, Order::Ascending) + .collect::>>()?; + for (denom, mut state) in states.into_iter() { + // this checks if we have received some coins that are "in flight" and not yet accounted in the state + let Coin { amount, .. } = deps.querier.query_balance(addr, &denom)?; + let diff = state.outstanding - amount; + // if they are in flight, we add them to the internal state now, as if we added them when sent (not when acked) + // to match the current logic + if !diff.is_zero() { + state.outstanding += diff; + state.total_sent += diff; + CHANNEL_STATE.save(deps.storage, (channel, &denom), &state)?; + } + } + Ok(()) + } + _ => Err(ContractError::CannotMigrate { + previous_contract: "multiple channels open".into(), + }), + } + } +} From 1b43accd2970aa0aac08d71c7d0df0316a45454e Mon Sep 17 00:00:00 2001 From: Callum Anderson Date: Thu, 24 Mar 2022 15:15:44 +0000 Subject: [PATCH 280/352] Address feedback --- contracts/cw3-fixed-multisig/src/contract.rs | 40 +++++- contracts/cw3-fixed-multisig/src/state.rs | 137 +++++++++++-------- 2 files changed, 118 insertions(+), 59 deletions(-) diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index f55609bfe..629544bda 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -788,7 +788,7 @@ mod tests { proposal_id, vote: Vote::No, }; - // Voter1 vote no + // Voter1 vote no, weight 1 let info = mock_info(VOTER1, &[]); let res = execute(deps.as_mut(), mock_env(), info, no_vote.clone()).unwrap(); @@ -802,16 +802,50 @@ mod tests { .add_attribute("status", "Open") ); + // Voter 4 votes no, weight 4, total weight for no so far 5, need 14 to reject let info = mock_info(VOTER4, &[]); - let res = execute(deps.as_mut(), mock_env(), info, no_vote).unwrap(); + let res = execute(deps.as_mut(), mock_env(), info, no_vote.clone()).unwrap(); - // Verify it is now rejected due to reaching threshold + // Verify it is still open as we actually need no votes > 16 - 3 assert_eq!( res, Response::new() .add_attribute("action", "vote") .add_attribute("sender", VOTER4) .add_attribute("proposal_id", proposal_id.to_string()) + .add_attribute("status", "Open") + ); + + // Voter 3 votes no, weight 3, total weight for no far 8, need 14 + let info = mock_info(VOTER3, &[]); + let _res = execute(deps.as_mut(), mock_env(), info, no_vote.clone()).unwrap(); + + // Voter 5 votes no, weight 5, total weight for no far 13, need 14 + let info = mock_info(VOTER5, &[]); + let res = execute(deps.as_mut(), mock_env(), info, no_vote.clone()).unwrap(); + + // Verify it is still open as we actually need no votes > 16 - 3 + assert_eq!( + res, + Response::new() + .add_attribute("action", "vote") + .add_attribute("sender", VOTER5) + .add_attribute("proposal_id", proposal_id.to_string()) + .add_attribute("status", "Open") + ); + + // Voter 2 votes no, weight 2, total weight for no so far 15, need 14. + // Can now reject + let info = mock_info(VOTER2, &[]); + let res = execute(deps.as_mut(), mock_env(), info, no_vote).unwrap(); + + // Verify it is rejected as, 15 no votes > 16 - 3 + assert_eq!( + res, + Response::new() + .add_attribute("action", "vote") + .add_attribute("sender", VOTER2) + .add_attribute("proposal_id", proposal_id.to_string()) .add_attribute("status", "Rejected") ); } diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index 361187dc4..e1ea12ef8 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -57,23 +57,17 @@ impl Proposal { self.status = self.current_status(block); } - /// Helper function to check if a certain vote count has reached threshold. - /// Only called from is_rejected and is_passed for no and yes votes - /// Handles the different threshold types accordingly. - /// This function returns true if and only if vote_count is greater than the threshold which - /// is calculated. - /// In the case where we use yes votes, this function will return true if the proposal will pass. - /// In the case where we use no votes, this function will return true if the - /// proposal will be rejected regardless of other votes. - fn does_vote_count_reach_threshold(&self, vote_count: u64, block: &BlockInfo) -> bool { + /// Returns true if this proposal is sure to pass (even before expiration, if no future + /// sequence of possible votes could cause it to fail). + pub fn is_passed(&self, block: &BlockInfo) -> bool { match self.threshold { Threshold::AbsoluteCount { weight: weight_needed, - } => vote_count >= weight_needed, + } => self.votes.yes >= weight_needed, Threshold::AbsolutePercentage { percentage: percentage_needed, } => { - vote_count + self.votes.yes >= votes_needed(self.total_weight - self.votes.abstain, percentage_needed) } Threshold::ThresholdQuorum { threshold, quorum } => { @@ -84,27 +78,53 @@ impl Proposal { if self.expires.is_expired(block) { // If expired, we compare vote_count against the total number of votes (minus abstain). let opinions = self.votes.total() - self.votes.abstain; - vote_count >= votes_needed(opinions, threshold) + self.votes.yes >= votes_needed(opinions, threshold) } else { // If not expired, we must assume all non-votes will be cast against // vote_count let possible_opinions = self.total_weight - self.votes.abstain; - vote_count >= votes_needed(possible_opinions, threshold) + self.votes.yes >= votes_needed(possible_opinions, threshold) } } } } - /// Returns true if this proposal is sure to pass (even before expiration, if no future - /// sequence of possible votes could cause it to fail). - pub fn is_passed(&self, block: &BlockInfo) -> bool { - self.does_vote_count_reach_threshold(self.votes.yes, block) - } - /// Returns true if this proposal is sure to be rejected (even before expiration, if /// no future sequence of possible votes could cause it to fail). pub fn is_rejected(&self, block: &BlockInfo) -> bool { - self.does_vote_count_reach_threshold(self.votes.no, block) + match self.threshold { + Threshold::AbsoluteCount { + weight: weight_needed, + } => { + let weight = self.total_weight - weight_needed; + self.votes.no > weight + } + Threshold::AbsolutePercentage { + percentage: percentage_needed, + } => { + self.votes.no + >= votes_needed( + self.total_weight - self.votes.abstain, + Decimal::one() - percentage_needed, + ) + } + Threshold::ThresholdQuorum { threshold, quorum } => { + // we always require the quorum + if self.votes.total() < votes_needed(self.total_weight, quorum) { + return false; + } + if self.expires.is_expired(block) { + // If expired, we compare vote_count against the total number of votes (minus abstain). + let opinions = self.votes.total() - self.votes.abstain; + self.votes.no >= votes_needed(opinions, Decimal::one() - threshold) + } else { + // If not expired, we must assume all non-votes will be cast against + // vote_count + let possible_opinions = self.total_weight - self.votes.abstain; + self.votes.no >= votes_needed(possible_opinions, Decimal::one() - threshold) + } + } + } } } @@ -276,11 +296,11 @@ mod test { let mut votes = Votes::yes(0); votes.add_vote(Vote::Veto, 4); votes.add_vote(Vote::No, 7); - // same expired or not, total_weight or whatever + // In order to reject the proposal we need no votes > 30 - 10, currently it is not rejected assert!(!check_is_rejected(fixed.clone(), votes.clone(), 30, false)); assert!(!check_is_rejected(fixed.clone(), votes.clone(), 30, true)); - // a few more no votes and we have rejected the prop - votes.add_vote(Vote::No, 3); + // 7 + 14 = 21 > 20, we can now reject + votes.add_vote(Vote::No, 14); assert!(check_is_rejected(fixed.clone(), votes.clone(), 30, false)); assert!(check_is_rejected(fixed, votes, 30, true)); } @@ -308,7 +328,7 @@ mod test { #[test] fn proposal_rejected_absolute_percentage() { let percent = Threshold::AbsolutePercentage { - percentage: Decimal::percent(50), + percentage: Decimal::percent(60), }; // 4 YES, 7 NO, 2 ABSTAIN @@ -317,24 +337,25 @@ mod test { votes.add_vote(Vote::Abstain, 2); // 15 total voting power - // 7 / (15 - 2) > 50% - // Expiry does not matter + // we need no votes > 0.4 * 15, no votes > 6 assert!(check_is_rejected(percent.clone(), votes.clone(), 15, false)); assert!(check_is_rejected(percent.clone(), votes.clone(), 15, true)); // 17 total voting power - // 7 / (17 - 2) < 50% + // we need no votes > 0.4 * 17, no votes > 6.8 + // still rejected + assert!(check_is_rejected(percent.clone(), votes.clone(), 17, false)); + assert!(check_is_rejected(percent.clone(), votes.clone(), 17, true)); + + // Not rejected if total weight is 20 + // as no votes > 0.4 * 18, no votes > 8 assert!(!check_is_rejected( percent.clone(), votes.clone(), - 17, + 20, false )); - assert!(!check_is_rejected(percent.clone(), votes.clone(), 17, true)); - - // Rejected if total was lower - assert!(check_is_rejected(percent.clone(), votes.clone(), 14, false)); - assert!(check_is_rejected(percent, votes.clone(), 14, true)); + assert!(!check_is_rejected(percent, votes.clone(), 20, true)); } #[test] @@ -407,7 +428,7 @@ mod test { #[test] fn proposal_rejected_quorum() { let quorum = Threshold::ThresholdQuorum { - threshold: Decimal::percent(50), + threshold: Decimal::percent(60), quorum: Decimal::percent(40), }; // all non-yes votes are counted for quorum @@ -427,13 +448,16 @@ mod test { // fails any way you look at it let failing = Votes { yes: 5, - no: 6, + no: 5, abstain: 2, - veto: 2, + veto: 3, }; // first, expired (voting period over) - // over quorum (40% of 30 = 12), over threshold (7/11 > 50%) + // over quorum (40% of 30 = 12, 13 votes casted) + // 13 - 2 abstains = 11 + // we need no votes > 0.4 * 11, no votes > 4.4 + // We can reject this assert!(check_is_rejected( quorum.clone(), rejecting.clone(), @@ -441,16 +465,19 @@ mod test { true )); // Under quorum means it cannot be rejected + // (40% of 50 = 20), 13 votes casted assert!(!check_is_rejected( quorum.clone(), rejecting.clone(), - 33, + 50, true )); // over quorum, threshold passes if we ignore abstain - // 17 total votes w/ abstain => 40% quorum of 40 total - // 6 no / (6 no + 4 yes + 2 votes) => 50% threshold + // 17 total votes > 40% quorum + // 6 no > 0.4 * (6 no + 4 yes + 2 votes) + // 6 > 4.8 + // we can reject assert!(check_is_rejected( quorum.clone(), rejected_ignoring_abstain.clone(), @@ -458,24 +485,16 @@ mod test { true )); - // over quorum, but under threshold fails also + // over quorum + // total opinions due to abstains: 13 + // no votes > 0.4 * 13, no votes > 5 to reject, we have 5 exactly so cannot reject assert!(!check_is_rejected(quorum.clone(), failing, 20, true)); - // Voting is still open so assume rest of votes are yes - // threshold not reached - assert!(!check_is_rejected( - quorum.clone(), - rejecting.clone(), - 30, - false - )); - assert!(!check_is_rejected( - quorum.clone(), - rejected_ignoring_abstain.clone(), - 40, - false - )); - // if we have threshold * total_weight as no votes this must reject + // voting period on going + // over quorum (40% of 14 = 5, 13 votes casted) + // 13 - 2 abstains = 11 + // we need no votes > 0.4 * 11, no votes > 4.4 + // We can reject this even when it hasn't expired assert!(check_is_rejected( quorum.clone(), rejecting.clone(), @@ -483,12 +502,18 @@ mod test { false )); // all votes have been cast, some abstain + // voting period on going + // over quorum (40% of 17 = 7, 17 casted_ + // 17 - 5 = 12 total opinions + // we need no votes > 0.4 * 12, no votes > 4.8 + // We can reject this even when it hasn't expired assert!(check_is_rejected( quorum.clone(), rejected_ignoring_abstain, 17, false )); + // 3 votes uncast, if they all vote yes, we have 7 no, 7 yes+veto, 2 abstain (out of 16) assert!(check_is_rejected(quorum, rejecting, 16, false)); } From 3b326ee4dfd0ef55a0e8322a63c5193080666039 Mon Sep 17 00:00:00 2001 From: Callum Anderson Date: Thu, 24 Mar 2022 15:23:36 +0000 Subject: [PATCH 281/352] Correct small error --- contracts/cw3-fixed-multisig/src/state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index fbb2cb990..3d558c8d2 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -116,12 +116,12 @@ impl Proposal { if self.expires.is_expired(block) { // If expired, we compare vote_count against the total number of votes (minus abstain). let opinions = self.votes.total() - self.votes.abstain; - self.votes.no >= votes_needed(opinions, Decimal::one() - threshold) + self.votes.no > votes_needed(opinions, Decimal::one() - threshold) } else { // If not expired, we must assume all non-votes will be cast against // vote_count let possible_opinions = self.total_weight - self.votes.abstain; - self.votes.no >= votes_needed(possible_opinions, Decimal::one() - threshold) + self.votes.no > votes_needed(possible_opinions, Decimal::one() - threshold) } } } From 514a203d5a28136fb32074715c530c0172bd1859 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 17:44:44 +0100 Subject: [PATCH 282/352] Test migration --- contracts/cw20-ics20/src/contract.rs | 35 +++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index e04f4eb6e..3c8b25aa9 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -365,9 +365,10 @@ mod test { use super::*; use crate::test_helpers::*; - use cosmwasm_std::testing::{mock_env, mock_info}; + use cosmwasm_std::testing::{mock_env, mock_info, MOCK_CONTRACT_ADDR}; use cosmwasm_std::{coin, coins, CosmosMsg, IbcMsg, StdError, Uint128}; + use crate::state::ChannelState; use cw_utils::PaymentError; #[test] @@ -532,4 +533,36 @@ mod test { let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); assert_eq!(err, ContractError::NotOnAllowList); } + + #[test] + fn v3_migration_works() { + // basic state with one channel + let send_channel = "channel-15"; + let cw20_addr = "my-token"; + let native = "ucosm"; + let mut deps = setup(&[send_channel], &[(cw20_addr, 123456)]); + + // mock that we sent some tokens in both native and cw20 (TODO: cw20) + // balances set high + deps.querier + .update_balance(MOCK_CONTRACT_ADDR, coins(50000, native)); + + // channel state a bit lower (some in-flight acks) + let state = ChannelState { + // 14000 not accounted for (in-flight) + outstanding: Uint128::new(36000), + total_sent: Uint128::new(100000), + }; + CHANNEL_STATE + .save(deps.as_mut().storage, (send_channel, native), &state) + .unwrap(); + + // run migration + migrate(deps.as_mut(), mock_env(), MigrateMsg {}).unwrap(); + + // check new channel state + let chan = query_channel(deps.as_ref(), send_channel.into()).unwrap(); + assert_eq!(chan.balances, vec![Amount::native(50000, native)]); + assert_eq!(chan.total_sent, vec![Amount::native(114000, native)]); + } } From f0c32d32febdb3b50ed0de13dbf88806e87dae30 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 17:45:25 +0100 Subject: [PATCH 283/352] Fix subtration in diff --- contracts/cw20-ics20/src/migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw20-ics20/src/migrations.rs b/contracts/cw20-ics20/src/migrations.rs index 4c79b6ffb..c48e7f71a 100644 --- a/contracts/cw20-ics20/src/migrations.rs +++ b/contracts/cw20-ics20/src/migrations.rs @@ -37,7 +37,7 @@ pub mod v2 { for (denom, mut state) in states.into_iter() { // this checks if we have received some coins that are "in flight" and not yet accounted in the state let Coin { amount, .. } = deps.querier.query_balance(addr, &denom)?; - let diff = state.outstanding - amount; + let diff = amount - state.outstanding; // if they are in flight, we add them to the internal state now, as if we added them when sent (not when acked) // to match the current logic if !diff.is_zero() { From 7689360a721eb6e762ced7d77076333872378e48 Mon Sep 17 00:00:00 2001 From: Callum Anderson Date: Thu, 24 Mar 2022 17:04:08 +0000 Subject: [PATCH 284/352] Typo again --- contracts/cw3-fixed-multisig/src/state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index 3d558c8d2..039fbe17f 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -103,7 +103,7 @@ impl Proposal { percentage: percentage_needed, } => { self.votes.no - >= votes_needed( + > votes_needed( self.total_weight - self.votes.abstain, Decimal::one() - percentage_needed, ) From 9ad5fef463ad7ff4ffd187e1b23ec2c03e0758ef Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 18:09:40 +0100 Subject: [PATCH 285/352] Add (untested) support for migrating cw20 --- contracts/cw20-ics20/src/migrations.rs | 61 ++++++++++++++++++++------ 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/contracts/cw20-ics20/src/migrations.rs b/contracts/cw20-ics20/src/migrations.rs index c48e7f71a..536b4da96 100644 --- a/contracts/cw20-ics20/src/migrations.rs +++ b/contracts/cw20-ics20/src/migrations.rs @@ -17,11 +17,13 @@ pub mod v1 { // v2 format is anything older than 0.13.1 when we only updated the internal balances on success ack pub mod v2 { - use crate::state::{CHANNEL_INFO, CHANNEL_STATE}; + use crate::amount::Amount; + use crate::state::{ChannelState, CHANNEL_INFO, CHANNEL_STATE}; use crate::ContractError; - use cosmwasm_std::{Coin, DepsMut, Env, Order, StdResult}; + use cosmwasm_std::{to_binary, Addr, DepsMut, Env, Order, StdResult, WasmQuery}; + use cw20::{BalanceResponse, Cw20QueryMsg}; - pub fn update_balances(deps: DepsMut, env: &Env) -> Result<(), ContractError> { + pub fn update_balances(mut deps: DepsMut, env: &Env) -> Result<(), ContractError> { let channels = CHANNEL_INFO .keys(deps.storage, None, None, Order::Ascending) .collect::>>()?; @@ -34,17 +36,8 @@ pub mod v2 { .prefix(channel) .range(deps.storage, None, None, Order::Ascending) .collect::>>()?; - for (denom, mut state) in states.into_iter() { - // this checks if we have received some coins that are "in flight" and not yet accounted in the state - let Coin { amount, .. } = deps.querier.query_balance(addr, &denom)?; - let diff = amount - state.outstanding; - // if they are in flight, we add them to the internal state now, as if we added them when sent (not when acked) - // to match the current logic - if !diff.is_zero() { - state.outstanding += diff; - state.total_sent += diff; - CHANNEL_STATE.save(deps.storage, (channel, &denom), &state)?; - } + for (denom, state) in states.into_iter() { + update_denom(deps.branch(), addr, channel, denom, state)?; } Ok(()) } @@ -53,4 +46,44 @@ pub mod v2 { }), } } + + fn update_denom( + deps: DepsMut, + contract: &Addr, + channel: &str, + denom: String, + mut state: ChannelState, + ) -> StdResult<()> { + // handle this for both native and cw20 + let balance = match Amount::from_parts(denom.clone(), state.outstanding) { + Amount::Native(coin) => deps.querier.query_balance(contract, coin.denom)?.amount, + Amount::Cw20(coin) => { + // FIXME: we should be able to do this with the following line, but QuerierWrapper doesn't play + // with the Querier generics + // Cw20Contract(contract.clone()).balance(&deps.querier, contract)? + let msg = Cw20QueryMsg::Balance { + address: contract.into(), + }; + let query = WasmQuery::Smart { + contract_addr: coin.address, + msg: to_binary(&msg)?, + } + .into(); + let res: BalanceResponse = deps.querier.query(&query)?; + res.balance + } + }; + + // this checks if we have received some coins that are "in flight" and not yet accounted in the state + let diff = balance - state.outstanding; + // if they are in flight, we add them to the internal state now, as if we added them when sent (not when acked) + // to match the current logic + if !diff.is_zero() { + state.outstanding += diff; + state.total_sent += diff; + CHANNEL_STATE.save(deps.storage, (channel, &denom), &state)?; + } + + Ok(()) + } } From 068d33fcc0d1461c73ea7573e8c81aed4d355470 Mon Sep 17 00:00:00 2001 From: Callum Anderson Date: Thu, 24 Mar 2022 17:29:13 +0000 Subject: [PATCH 286/352] Address feedback --- contracts/cw3-fixed-multisig/src/state.rs | 42 +++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index 039fbe17f..eedf1c46e 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -81,7 +81,6 @@ impl Proposal { self.votes.yes >= votes_needed(opinions, threshold) } else { // If not expired, we must assume all non-votes will be cast against - // vote_count let possible_opinions = self.total_weight - self.votes.abstain; self.votes.yes >= votes_needed(possible_opinions, threshold) } @@ -108,18 +107,16 @@ impl Proposal { Decimal::one() - percentage_needed, ) } - Threshold::ThresholdQuorum { threshold, quorum } => { - // we always require the quorum - if self.votes.total() < votes_needed(self.total_weight, quorum) { - return false; - } + Threshold::ThresholdQuorum { + threshold, + quorum: _, + } => { if self.expires.is_expired(block) { // If expired, we compare vote_count against the total number of votes (minus abstain). let opinions = self.votes.total() - self.votes.abstain; self.votes.no > votes_needed(opinions, Decimal::one() - threshold) } else { - // If not expired, we must assume all non-votes will be cast against - // vote_count + // If not expired, we must assume all non-votes will be cast for let possible_opinions = self.total_weight - self.votes.abstain; self.votes.no > votes_needed(possible_opinions, Decimal::one() - threshold) } @@ -464,12 +461,37 @@ mod test { 30, true )); - // Under quorum means it cannot be rejected - // (40% of 50 = 20), 13 votes casted + + // Under quorum and cannot reject as it is not expired assert!(!check_is_rejected( quorum.clone(), rejecting.clone(), 50, + false + )); + // Can reject when expired + assert!(check_is_rejected( + quorum.clone(), + rejecting.clone(), + 50, + true + )); + + // Check edgecase where quorum is not met but we can reject + // 35% vote no + let quorum_edgecase = Threshold::ThresholdQuorum { + threshold: Decimal::percent(67), + quorum: Decimal::percent(40), + }; + assert!(check_is_rejected( + quorum_edgecase, + Votes { + yes: 15, + no: 35, + abstain: 0, + veto: 10 + }, + 100, true )); From cd6b88c5e9bf123e6263728012951eba9da54649 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 19:15:32 +0100 Subject: [PATCH 287/352] Cleanup --- contracts/cw20-ics20/src/migrations.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/contracts/cw20-ics20/src/migrations.rs b/contracts/cw20-ics20/src/migrations.rs index 536b4da96..8c67b6b49 100644 --- a/contracts/cw20-ics20/src/migrations.rs +++ b/contracts/cw20-ics20/src/migrations.rs @@ -60,16 +60,14 @@ pub mod v2 { Amount::Cw20(coin) => { // FIXME: we should be able to do this with the following line, but QuerierWrapper doesn't play // with the Querier generics - // Cw20Contract(contract.clone()).balance(&deps.querier, contract)? - let msg = Cw20QueryMsg::Balance { - address: contract.into(), - }; + // `Cw20Contract(contract.clone()).balance(&deps.querier, contract)?` let query = WasmQuery::Smart { contract_addr: coin.address, - msg: to_binary(&msg)?, - } - .into(); - let res: BalanceResponse = deps.querier.query(&query)?; + msg: to_binary(&Cw20QueryMsg::Balance { + address: contract.into(), + })?, + }; + let res: BalanceResponse = deps.querier.query(&query.into())?; res.balance } }; From 92e01a4b9cff139bb1733d938a4dde398b18d673 Mon Sep 17 00:00:00 2001 From: Callum Anderson Date: Thu, 24 Mar 2022 18:18:33 +0000 Subject: [PATCH 288/352] Update comment. Circle CI --- contracts/cw3-fixed-multisig/src/state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index eedf1c46e..11d49daf1 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -469,7 +469,7 @@ mod test { 50, false )); - // Can reject when expired + // Can reject when expired. assert!(check_is_rejected( quorum.clone(), rejecting.clone(), From 0899b23b88b1257410c73bbf04f68619b1e842f6 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 19:35:39 +0100 Subject: [PATCH 289/352] Add default_gas_limit to InitMsg and Config --- contracts/cw20-ics20/src/contract.rs | 3 +++ contracts/cw20-ics20/src/msg.rs | 4 ++++ contracts/cw20-ics20/src/state.rs | 1 + contracts/cw20-ics20/src/test_helpers.rs | 1 + 4 files changed, 9 insertions(+) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 3c8b25aa9..60b64ff83 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -38,6 +38,7 @@ pub fn instantiate( set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; let cfg = Config { default_timeout: msg.default_timeout, + default_gas_limit: msg.default_gas_limit, }; CONFIG.save(deps.storage, &cfg)?; @@ -233,6 +234,7 @@ pub fn migrate(mut deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result StdResult { let admin = ADMIN.get(deps)?.unwrap_or_else(|| Addr::unchecked("")); let res = ConfigResponse { default_timeout: cfg.default_timeout, + default_gas_limit: cfg.default_gas_limit, gov_contract: admin.into(), }; Ok(res) diff --git a/contracts/cw20-ics20/src/msg.rs b/contracts/cw20-ics20/src/msg.rs index c5330dd97..778878ada 100644 --- a/contracts/cw20-ics20/src/msg.rs +++ b/contracts/cw20-ics20/src/msg.rs @@ -14,6 +14,9 @@ pub struct InitMsg { pub gov_contract: String, /// initial allowlist - all cw20 tokens we will send must be previously allowed by governance pub allowlist: Vec, + /// If set, contracts off the allowlist will run with this gas limit. + /// If unset, will refuse to accept any contract off the allow list. + pub default_gas_limit: Option, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] @@ -98,6 +101,7 @@ pub struct PortResponse { #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct ConfigResponse { pub default_timeout: u64, + pub default_gas_limit: Option, pub gov_contract: String, } diff --git a/contracts/cw20-ics20/src/state.rs b/contracts/cw20-ics20/src/state.rs index 20277035a..57cbe0a0a 100644 --- a/contracts/cw20-ics20/src/state.rs +++ b/contracts/cw20-ics20/src/state.rs @@ -32,6 +32,7 @@ pub struct ChannelState { #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { pub default_timeout: u64, + pub default_gas_limit: Option, } #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] diff --git a/contracts/cw20-ics20/src/test_helpers.rs b/contracts/cw20-ics20/src/test_helpers.rs index 27106d66f..6f16a7e1a 100644 --- a/contracts/cw20-ics20/src/test_helpers.rs +++ b/contracts/cw20-ics20/src/test_helpers.rs @@ -70,6 +70,7 @@ pub fn setup( // instantiate an empty contract let instantiate_msg = InitMsg { + default_gas_limit: None, default_timeout: DEFAULT_TIMEOUT, gov_contract: "gov".to_string(), allowlist, From 8f82207b845be733963aeffccae17b428a4d9341 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 19:41:10 +0100 Subject: [PATCH 290/352] Add migration entry to set the default_gas_limit --- contracts/cw20-ics20/src/contract.rs | 24 ++++++++++++++++++++++-- contracts/cw20-ics20/src/msg.rs | 4 +++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 60b64ff83..77e0efb8a 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -203,7 +203,7 @@ const MIGRATE_VERSION_2: &str = "0.12.0-alpha1"; const MIGRATE_VERSION_3: &str = "0.13.1"; #[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(mut deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result { +pub fn migrate(mut deps: DepsMut, env: Env, msg: MigrateMsg) -> Result { let version: Version = CONTRACT_VERSION.parse().map_err(from_semver)?; let stored = get_contract_version(deps.storage)?; let storage_version: Version = stored.version.parse().map_err(from_semver)?; @@ -244,6 +244,15 @@ pub fn migrate(mut deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result StdResult<_> { + old.default_gas_limit = msg.default_gas_limit; + Ok(old) + })?; + } + // we don't need to save anything if migrating from the same version if storage_version < version { set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; @@ -561,11 +570,22 @@ mod test { .unwrap(); // run migration - migrate(deps.as_mut(), mock_env(), MigrateMsg {}).unwrap(); + migrate( + deps.as_mut(), + mock_env(), + MigrateMsg { + default_gas_limit: Some(123456), + }, + ) + .unwrap(); // check new channel state let chan = query_channel(deps.as_ref(), send_channel.into()).unwrap(); assert_eq!(chan.balances, vec![Amount::native(50000, native)]); assert_eq!(chan.total_sent, vec![Amount::native(114000, native)]); + + // check config updates + let config = query_config(deps.as_ref()).unwrap(); + assert_eq!(config.default_gas_limit, Some(123456)); } } diff --git a/contracts/cw20-ics20/src/msg.rs b/contracts/cw20-ics20/src/msg.rs index 778878ada..6cb68ccbe 100644 --- a/contracts/cw20-ics20/src/msg.rs +++ b/contracts/cw20-ics20/src/msg.rs @@ -26,7 +26,9 @@ pub struct AllowMsg { } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)] -pub struct MigrateMsg {} +pub struct MigrateMsg { + pub default_gas_limit: Option, +} #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] From 41678f490e0d9a9b02c8f6dd5dc0ef2d4bd706df Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 19:47:09 +0100 Subject: [PATCH 291/352] Handle contracts off allow list if default_gas_limit set --- contracts/cw20-ics20/src/contract.rs | 14 +++++++++----- contracts/cw20-ics20/src/ibc.rs | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 77e0efb8a..a9fef4abb 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -108,19 +108,23 @@ pub fn execute_transfer( if !CHANNEL_INFO.has(deps.storage, &msg.channel) { return Err(ContractError::NoSuchChannel { id: msg.channel }); } + let config = CONFIG.load(deps.storage)?; - // if cw20 token, ensure it is whitelisted + // if cw20 token, validate and ensure it is whitelisted, or we set default gas limit if let Amount::Cw20(coin) = &amount { let addr = deps.api.addr_validate(&coin.address)?; - ALLOW_LIST - .may_load(deps.storage, &addr)? - .ok_or(ContractError::NotOnAllowList)?; + // if limit is set, then we always allow cw20 + if config.default_gas_limit.is_none() { + ALLOW_LIST + .may_load(deps.storage, &addr)? + .ok_or(ContractError::NotOnAllowList)?; + } }; // delta from user is in seconds let timeout_delta = match msg.timeout { Some(t) => t, - None => CONFIG.load(deps.storage)?.default_timeout, + None => config.default_timeout, }; // timeout is in nanoseconds let timeout = env.block.time.plus_seconds(timeout_delta); diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index d46121f65..3174584dc 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -12,7 +12,7 @@ use crate::amount::Amount; use crate::error::{ContractError, Never}; use crate::state::{ reduce_channel_balance, undo_reduce_channel_balance, ChannelInfo, ReplyArgs, ALLOW_LIST, - CHANNEL_INFO, REPLY_ARGS, + CHANNEL_INFO, CONFIG, REPLY_ARGS, }; use cw20::Cw20ExecuteMsg; @@ -273,10 +273,14 @@ fn check_gas_limit(deps: Deps, amount: &Amount) -> Result, ContractE Amount::Cw20(coin) => { // if cw20 token, use the registered gas limit, or error if not whitelisted let addr = deps.api.addr_validate(&coin.address)?; - Ok(ALLOW_LIST - .may_load(deps.storage, &addr)? - .ok_or(ContractError::NotOnAllowList)? - .gas_limit) + let allowed = ALLOW_LIST.may_load(deps.storage, &addr)?; + match allowed { + Some(allow) => Ok(allow.gas_limit), + None => match CONFIG.load(deps.storage)?.default_gas_limit { + Some(base) => Ok(Some(base)), + None => Err(ContractError::NotOnAllowList), + }, + } } _ => Ok(None), } From 1ab59a4b0c9bd6b5c7553bd8a771ffddd696094a Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 19:57:42 +0100 Subject: [PATCH 292/352] Test the default_gas_limit works properly --- contracts/cw20-ics20/src/contract.rs | 21 ++++++++++++--- contracts/cw20-ics20/src/ibc.rs | 39 ++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index a9fef4abb..894199dea 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -528,9 +528,9 @@ mod test { } #[test] - fn execute_cw20_fails_if_not_whitelisted() { + fn execute_cw20_fails_if_not_whitelisted_unless_default_gas_limit() { let send_channel = "channel-15"; - let mut deps = setup(&["channel-3", send_channel], &[]); + let mut deps = setup(&[send_channel], &[]); let cw20_addr = "my-token"; let transfer = TransferMsg { @@ -544,10 +544,23 @@ mod test { msg: to_binary(&transfer).unwrap(), }); - // works with proper funds + // rejected as not on allow list let info = mock_info(cw20_addr, &[]); - let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); + let err = execute(deps.as_mut(), mock_env(), info.clone(), msg.clone()).unwrap_err(); assert_eq!(err, ContractError::NotOnAllowList); + + // add a default gas limit + migrate( + deps.as_mut(), + mock_env(), + MigrateMsg { + default_gas_limit: Some(123456), + }, + ) + .unwrap(); + + // try again + execute(deps.as_mut(), mock_env(), info, msg).unwrap(); } #[test] diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index 3174584dc..80433da32 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -390,8 +390,8 @@ mod test { use super::*; use crate::test_helpers::*; - use crate::contract::{execute, query_channel}; - use crate::msg::{ExecuteMsg, TransferMsg}; + use crate::contract::{execute, migrate, query_channel}; + use crate::msg::{ExecuteMsg, MigrateMsg, TransferMsg}; use cosmwasm_std::testing::{mock_env, mock_info}; use cosmwasm_std::{coins, to_vec, IbcEndpoint, IbcMsg, IbcTimeout, Timestamp}; use cw20::Cw20ReceiveMsg; @@ -625,4 +625,39 @@ mod test { assert_eq!(state.balances, vec![Amount::native(111111111, denom)]); assert_eq!(state.total_sent, vec![Amount::native(987654321, denom)]); } + + #[test] + fn check_gas_limit_handles_all_cases() { + let send_channel = "channel-9"; + let allowed = "foobar"; + let allowed_gas = 777666; + let mut deps = setup(&[send_channel], &[(allowed, allowed_gas)]); + + // allow list will get proper gas + let limit = check_gas_limit(deps.as_ref(), &Amount::cw20(500, allowed)).unwrap(); + assert_eq!(limit, Some(allowed_gas)); + + // non-allow list will error + let random = "tokenz"; + check_gas_limit(deps.as_ref(), &Amount::cw20(500, random)).unwrap_err(); + + // add default_gas_limit + let def_limit = 54321; + migrate( + deps.as_mut(), + mock_env(), + MigrateMsg { + default_gas_limit: Some(def_limit), + }, + ) + .unwrap(); + + // allow list still gets proper gas + let limit = check_gas_limit(deps.as_ref(), &Amount::cw20(500, allowed)).unwrap(); + assert_eq!(limit, Some(allowed_gas)); + + // non-allow list will now get default + let limit = check_gas_limit(deps.as_ref(), &Amount::cw20(500, random)).unwrap(); + assert_eq!(limit, Some(def_limit)); + } } From bf6be13fbd92bdac62023e4889fa9c357e6be530 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 24 Mar 2022 20:03:58 +0100 Subject: [PATCH 293/352] Set version: 0.13.1 --- Cargo.lock | 40 ++++++++++++------------- contracts/cw1-subkeys/Cargo.toml | 14 ++++----- contracts/cw1-whitelist-ng/Cargo.toml | 14 ++++----- contracts/cw1-whitelist/Cargo.toml | 12 ++++---- contracts/cw1155-base/Cargo.toml | 10 +++---- contracts/cw20-base/Cargo.toml | 10 +++---- contracts/cw20-ics20/Cargo.toml | 12 ++++---- contracts/cw3-fixed-multisig/Cargo.toml | 16 +++++----- contracts/cw3-flex-multisig/Cargo.toml | 18 +++++------ contracts/cw4-group/Cargo.toml | 12 ++++---- contracts/cw4-stake/Cargo.toml | 14 ++++----- packages/controllers/Cargo.toml | 6 ++-- packages/cw1/Cargo.toml | 2 +- packages/cw1155/Cargo.toml | 4 +-- packages/cw2/Cargo.toml | 4 +-- packages/cw20/Cargo.toml | 4 +-- packages/cw3/Cargo.toml | 4 +-- packages/cw4/Cargo.toml | 4 +-- packages/multi-test/Cargo.toml | 6 ++-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 4 +-- 21 files changed, 106 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 64a8f025b..ed172e095 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -366,7 +366,7 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -378,7 +378,7 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.13.0" +version = "0.13.1" dependencies = [ "anyhow", "cosmwasm-std", @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-std", "criterion", @@ -406,7 +406,7 @@ dependencies = [ [[package]] name = "cw-utils" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -418,7 +418,7 @@ dependencies = [ [[package]] name = "cw1" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -428,7 +428,7 @@ dependencies = [ [[package]] name = "cw1-subkeys" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -445,7 +445,7 @@ dependencies = [ [[package]] name = "cw1-whitelist" -version = "0.13.0" +version = "0.13.1" dependencies = [ "anyhow", "assert_matches", @@ -464,7 +464,7 @@ dependencies = [ [[package]] name = "cw1-whitelist-ng" -version = "0.13.0" +version = "0.13.1" dependencies = [ "anyhow", "assert_matches", @@ -483,7 +483,7 @@ dependencies = [ [[package]] name = "cw1155" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -494,7 +494,7 @@ dependencies = [ [[package]] name = "cw1155-base" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -509,7 +509,7 @@ dependencies = [ [[package]] name = "cw2" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -519,7 +519,7 @@ dependencies = [ [[package]] name = "cw20" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -530,7 +530,7 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -545,7 +545,7 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -562,7 +562,7 @@ dependencies = [ [[package]] name = "cw3" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -573,7 +573,7 @@ dependencies = [ [[package]] name = "cw3-fixed-multisig" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -591,7 +591,7 @@ dependencies = [ [[package]] name = "cw3-flex-multisig" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -610,7 +610,7 @@ dependencies = [ [[package]] name = "cw4" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -621,7 +621,7 @@ dependencies = [ [[package]] name = "cw4-group" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -637,7 +637,7 @@ dependencies = [ [[package]] name = "cw4-stake" -version = "0.13.0" +version = "0.13.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 666e7af0a..8913fc731 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-subkeys" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Implement subkeys for authorizing native tokens as a cw1 proxy contract" @@ -19,12 +19,12 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw1 = { path = "../../packages/cw1", version = "0.13.0" } -cw2 = { path = "../../packages/cw2", version = "0.13.0" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.0", features = ["library"] } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw1 = { path = "../../packages/cw1", version = "0.13.1" } +cw2 = { path = "../../packages/cw2", version = "0.13.1" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.1", features = ["library"] } cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.23" @@ -32,4 +32,4 @@ semver = "1" [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta6" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.0", features = ["library", "test-utils"] } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.1", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index fe81fc847..90445d219 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist-ng" -version = "0.13.0" +version = "0.13.1" authors = ["Bartłomiej Kuras "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -22,20 +22,20 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw1 = { path = "../../packages/cw1", version = "0.13.0" } -cw2 = { path = "../../packages/cw2", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw1 = { path = "../../packages/cw1", version = "0.13.1" } +cw2 = { path = "../../packages/cw2", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.0", optional = true } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.1", optional = true } anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta6" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.0" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.1" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index 94ee651dc..47da30eb3 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw1 = { path = "../../packages/cw1", version = "0.13.0" } -cw2 = { path = "../../packages/cw2", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw1 = { path = "../../packages/cw1", version = "0.13.1" } +cw2 = { path = "../../packages/cw2", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -32,5 +32,5 @@ thiserror = { version = "1.0.23" } anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0-beta6" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.0" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.1" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 36650e506..edd5f7399 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155-base" -version = "0.13.0" +version = "0.13.1" authors = ["Huang Yi "] edition = "2018" description = "Basic implementation of a CosmWasm-1155 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw2 = { path = "../../packages/cw2", version = "0.13.0" } -cw1155 = { path = "../../packages/cw1155", version = "0.13.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw2 = { path = "../../packages/cw2", version = "0.13.1" } +cw1155 = { path = "../../packages/cw1155", version = "0.13.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index ff894a876..cb05c9620 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-base" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation of a CosmWasm-20 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw2 = { path = "../../packages/cw2", version = "0.13.0" } -cw20 = { path = "../../packages/cw20", version = "0.13.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw2 = { path = "../../packages/cw2", version = "0.13.1" } +cw20 = { path = "../../packages/cw20", version = "0.13.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 187dbf89d..68c76cb95 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw2 = { path = "../../packages/cw2", version = "0.13.0" } -cw20 = { path = "../../packages/cw20", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw2 = { path = "../../packages/cw2", version = "0.13.1" } +cw20 = { path = "../../packages/cw20", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6", features = ["stargate"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.1" } schemars = "0.8.1" semver = "1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index 06b2b40eb..a06f37679 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-fixed-multisig" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with an fixed group multisig" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw2 = { path = "../../packages/cw2", version = "0.13.0" } -cw3 = { path = "../../packages/cw3", version = "0.13.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw2 = { path = "../../packages/cw2", version = "0.13.1" } +cw3 = { path = "../../packages/cw3", version = "0.13.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -29,6 +29,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta6" } -cw20 = { path = "../../packages/cw20", version = "0.13.0" } -cw20-base = { path = "../cw20-base", version = "0.13.0", features = ["library"] } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.0" } +cw20 = { path = "../../packages/cw20", version = "0.13.1" } +cw20-base = { path = "../cw20-base", version = "0.13.1", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.1" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index ea7d9eb21..673434d5c 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-flex-multisig" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with multiple voting patterns and dynamic groups" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw2 = { path = "../../packages/cw2", version = "0.13.0" } -cw3 = { path = "../../packages/cw3", version = "0.13.0" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.13.0", features = ["library"] } -cw4 = { path = "../../packages/cw4", version = "0.13.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw2 = { path = "../../packages/cw2", version = "0.13.1" } +cw3 = { path = "../../packages/cw3", version = "0.13.1" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.13.1", features = ["library"] } +cw4 = { path = "../../packages/cw4", version = "0.13.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta6" } -cw4-group = { path = "../cw4-group", version = "0.13.0" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.0" } +cw4-group = { path = "../cw4-group", version = "0.13.1" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.1" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index 7e41d420a..610921433 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-group" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Simple cw4 implementation of group membership controlled by admin " @@ -26,11 +26,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw2 = { path = "../../packages/cw2", version = "0.13.0" } -cw4 = { path = "../../packages/cw4", version = "0.13.0" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw2 = { path = "../../packages/cw2", version = "0.13.1" } +cw4 = { path = "../../packages/cw4", version = "0.13.1" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index 70c422e85..f5e97cd78 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-stake" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "CW4 implementation of group based on staked tokens" @@ -26,12 +26,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw2 = { path = "../../packages/cw2", version = "0.13.0" } -cw4 = { path = "../../packages/cw4", version = "0.13.0" } -cw20 = { path = "../../packages/cw20", version = "0.13.0" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw2 = { path = "../../packages/cw2", version = "0.13.1" } +cw4 = { path = "../../packages/cw4", version = "0.13.1" } +cw20 = { path = "../../packages/cw20", version = "0.13.1" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index 28a99ae27..56b12b5f5 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-controllers" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Common controllers we can reuse in many contracts" @@ -13,8 +13,8 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta6" } -cw-utils = { path = "../utils", version = "0.13.0" } -cw-storage-plus = { path = "../storage-plus", version = "0.13.0" } +cw-utils = { path = "../utils", version = "0.13.1" } +cw-storage-plus = { path = "../storage-plus", version = "0.13.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index bf0d428d9..ecfe3482d 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-1 interface" diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 96ab68f95..c5980ff07 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155" -version = "0.13.0" +version = "0.13.1" authors = ["Huang Yi "] edition = "2018" description = "Definition and types for the CosmWasm-1155 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 501b2eba6..136105e22 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw2" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-2 interface" @@ -11,6 +11,6 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0-beta6", default-features = false } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index 383a789cd..d04bd3e6d 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-20 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index 6720ae812..45c5e4106 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-3 Interface: On-Chain MultiSig/Voting contracts" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } +cw-utils = { path = "../../packages/utils", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index 6ad539d43..e5fe7c8f2 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-4 Interface: Groups Members" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-storage-plus = { path = "../storage-plus", version = "0.13.0" } +cw-storage-plus = { path = "../storage-plus", version = "0.13.1" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index ed91c3c7d..739f233ee 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-multi-test" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Test helpers for multi-contract interactions" @@ -18,8 +18,8 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.0" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0"} +cw-utils = { path = "../../packages/utils", version = "0.13.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1"} cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } cosmwasm-storage = { version = "1.0.0-beta6" } itertools = "0.10.1" diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 6032e7384..2b35f106b 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-storage-plus" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Enhanced storage engines" diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index da0e411f5..8c8a29bac 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-utils" -version = "0.13.0" +version = "0.13.1" authors = ["Ethan Frey "] edition = "2018" description = "Common helpers for other cw specs" @@ -18,5 +18,5 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } [dev-dependencies] -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.0" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } prost = "0.9" From 0876dcc9ae8453e8fc23fca818c5ce289dcb15e1 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 25 Mar 2022 08:32:38 +0100 Subject: [PATCH 294/352] Update CHANGELOG --- CHANGELOG.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff503d3f1..c392dbdb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,29 @@ ## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.0...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.1...HEAD) + +## [v0.13.1](https://github.com/CosmWasm/cw-plus/tree/v0.13.1) (2022-03-25) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.0...v0.13.1) + +**Closed issues:** + +- cw20-base: duplicate accounts get overwritten in Init [\#683](https://github.com/CosmWasm/cw-plus/issues/683) +- Implementation of hooks.rs \(not\) as `HashMap` [\#682](https://github.com/CosmWasm/cw-plus/issues/682) +- Release `cw-plus` v0.13.0 [\#673](https://github.com/CosmWasm/cw-plus/issues/673) +- ICS20, invalid packet data [\#662](https://github.com/CosmWasm/cw-plus/issues/662) +- Duplicate accounts in cw20 initial balances causes unrecoverable inconsistent state [\#626](https://github.com/CosmWasm/cw-plus/issues/626) + +**Merged pull requests:** + +- Add default gas limit to cw20-ics20 [\#685](https://github.com/CosmWasm/cw-plus/pull/685) ([ethanfrey](https://github.com/ethanfrey)) +- Fix cw20 ics20 packets [\#684](https://github.com/CosmWasm/cw-plus/pull/684) ([ethanfrey](https://github.com/ethanfrey)) +- Clarify the stability of cw-storage-plus, no longer Experimental [\#676](https://github.com/CosmWasm/cw-plus/pull/676) ([ethanfrey](https://github.com/ethanfrey)) +- Update changelog add upcoming [\#675](https://github.com/CosmWasm/cw-plus/pull/675) ([maurolacy](https://github.com/maurolacy)) +- Reject proposals early [\#668](https://github.com/CosmWasm/cw-plus/pull/668) ([Callum-A](https://github.com/Callum-A)) +- cw20-base: validate addresses are unique in initial balances [\#659](https://github.com/CosmWasm/cw-plus/pull/659) ([harryscholes](https://github.com/harryscholes)) +- New SECURITY.md refering to wasmd [\#624](https://github.com/CosmWasm/cw-plus/pull/624) ([ethanfrey](https://github.com/ethanfrey)) ## [v0.13.0](https://github.com/CosmWasm/cw-plus/tree/v0.13.0) (2022-03-09) From 34ee531b1646e6f1e525d6b40414893b099e12dd Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 25 Mar 2022 08:33:39 +0100 Subject: [PATCH 295/352] Changelog edit for clarity --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c392dbdb5..e2d514dad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,6 @@ - cw20-base: duplicate accounts get overwritten in Init [\#683](https://github.com/CosmWasm/cw-plus/issues/683) - Implementation of hooks.rs \(not\) as `HashMap` [\#682](https://github.com/CosmWasm/cw-plus/issues/682) -- Release `cw-plus` v0.13.0 [\#673](https://github.com/CosmWasm/cw-plus/issues/673) - ICS20, invalid packet data [\#662](https://github.com/CosmWasm/cw-plus/issues/662) - Duplicate accounts in cw20 initial balances causes unrecoverable inconsistent state [\#626](https://github.com/CosmWasm/cw-plus/issues/626) @@ -36,6 +35,7 @@ **Closed issues:** +- Release `cw-plus` v0.13.0 [\#673](https://github.com/CosmWasm/cw-plus/issues/673) - Querying over composite key [\#664](https://github.com/CosmWasm/cw-plus/issues/664) - the method `may_load` exists for struct `cw_storage_plus::Map<'static, (std::string::String, Uint256), Uint256>`, but its trait bounds were not satisfied the following trait bounds were not satisfied: `(std::string::String, Uint256): PrimaryKey` [\#663](https://github.com/CosmWasm/cw-plus/issues/663) - Make `Bound` helpers return `Option` [\#644](https://github.com/CosmWasm/cw-plus/issues/644) From d00b7334a5bfa438bb625f1c052189534c0cc23f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 25 Mar 2022 08:39:14 +0100 Subject: [PATCH 296/352] Update check_contract to latest beta6 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b10f55721..777aff31b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -597,7 +597,7 @@ jobs: - run: name: Install check_contract # Uses --debug for compilation speed - command: cargo install --debug --version 1.0.0-beta4 --features iterator --example check_contract -- cosmwasm-vm + command: cargo install --debug --version 1.0.0-beta6 --features iterator --example check_contract -- cosmwasm-vm - save_cache: paths: - /usr/local/cargo/registry From 51404fe71d63a8738a6b9405fc0d72240f43a838 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 25 Mar 2022 09:16:30 +0100 Subject: [PATCH 297/352] Fix publish.sh help / args --- scripts/publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index afd4c696b..783c3b3b0 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -7,7 +7,7 @@ function print_usage() { echo "Publishes crates to crates.io." } -if [ "$1" = "-h" ] || [ "$1" = "--help" ] +if [ $# = 1 ] && ( [ "$1" = "-h" ] || [ "$1" = "--help" ] ) then print_usage exit 1 From 7a84bb5326d977345364f76293b47b4ad25a8657 Mon Sep 17 00:00:00 2001 From: MeNoln Date: Sat, 26 Mar 2022 17:24:53 +0300 Subject: [PATCH 298/352] fix type in desc --- contracts/cw20-base/src/msg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw20-base/src/msg.rs b/contracts/cw20-base/src/msg.rs index b234ffd1b..8c45fc2fa 100644 --- a/contracts/cw20-base/src/msg.rs +++ b/contracts/cw20-base/src/msg.rs @@ -106,7 +106,7 @@ pub enum QueryMsg { /// Return type: MarketingInfoResponse MarketingInfo {}, /// Only with "marketing" extension - /// Downloads the mbeded logo data (if stored on chain). Errors if no logo data ftored for this + /// Downloads the embedded logo data (if stored on chain). Errors if no logo data is stored for this /// contract. /// Return type: DownloadLogoResponse. DownloadLogo {}, From 40b5b1587f6952d1320cf3d1c27e2f2b0c287f5a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 27 Mar 2022 08:55:24 +0200 Subject: [PATCH 299/352] Make KeyDeserialize trait public --- packages/storage-plus/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 0d6e464c9..7035d9a25 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -18,6 +18,7 @@ mod snapshot; #[cfg(feature = "iterator")] pub use bound::{Bound, Bounder, PrefixBound, RawBound}; +pub use de::KeyDeserialize; pub use endian::Endian; #[cfg(feature = "iterator")] pub use indexed_map::{IndexList, IndexedMap}; From bffc70fda438ca23371d2a9590f77141d76bd333 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 27 Mar 2022 11:38:20 +0200 Subject: [PATCH 300/352] Fix required trait bounds on raw Map iterators --- packages/storage-plus/src/map.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 398521f3a..82da70a37 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -196,7 +196,7 @@ where impl<'a, K, T> Map<'a, K, T> where T: Serialize + DeserializeOwned, - K: PrimaryKey<'a> + KeyDeserialize + Bounder<'a>, + K: PrimaryKey<'a> + Bounder<'a>, { pub fn range_raw<'c>( &self, @@ -223,7 +223,14 @@ where { self.no_prefix_raw().keys_raw(store, min, max, order) } +} +#[cfg(feature = "iterator")] +impl<'a, K, T> Map<'a, K, T> +where + T: Serialize + DeserializeOwned, + K: PrimaryKey<'a> + KeyDeserialize + Bounder<'a>, +{ pub fn range<'c>( &self, store: &'c dyn Storage, From b07ce13d394000b79dc4a46a7ae15c16777b2f00 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Sun, 27 Mar 2022 11:45:27 +0200 Subject: [PATCH 301/352] Remove optional Bounder trait bound --- packages/storage-plus/src/map.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 82da70a37..eee46f5c1 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -3,7 +3,7 @@ use serde::Serialize; use std::marker::PhantomData; #[cfg(feature = "iterator")] -use crate::bound::{Bound, Bounder, PrefixBound}; +use crate::bound::{Bound, PrefixBound}; #[cfg(feature = "iterator")] use crate::de::KeyDeserialize; use crate::helpers::query_raw; @@ -196,7 +196,7 @@ where impl<'a, K, T> Map<'a, K, T> where T: Serialize + DeserializeOwned, - K: PrimaryKey<'a> + Bounder<'a>, + K: PrimaryKey<'a>, { pub fn range_raw<'c>( &self, @@ -229,7 +229,7 @@ where impl<'a, K, T> Map<'a, K, T> where T: Serialize + DeserializeOwned, - K: PrimaryKey<'a> + KeyDeserialize + Bounder<'a>, + K: PrimaryKey<'a> + KeyDeserialize, { pub fn range<'c>( &self, @@ -270,6 +270,9 @@ mod test { #[cfg(feature = "iterator")] use cosmwasm_std::{Order, StdResult}; + #[cfg(feature = "iterator")] + use crate::bound::Bounder; + use crate::int_key::CwIntKey; #[cfg(feature = "iterator")] use crate::IntKeyOld; From c54018fb12d1d64f0e882b5340554b7402fefd12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20K=C3=BCl=C3=A7e?= Date: Tue, 29 Mar 2022 16:38:41 +0300 Subject: [PATCH 302/352] storage-plus: Implement u128 key --- packages/storage-plus/src/keys.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index e4240abb1..2af4941ba 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -11,6 +11,7 @@ pub enum Key<'a> { Val16([u8; 2]), Val32([u8; 4]), Val64([u8; 8]), + Val128([u8; 16]), } impl<'a> AsRef<[u8]> for Key<'a> { @@ -21,6 +22,7 @@ impl<'a> AsRef<[u8]> for Key<'a> { Key::Val16(v) => v, Key::Val32(v) => v, Key::Val64(v) => v, + Key::Val128(v) => v } } } @@ -286,7 +288,7 @@ macro_rules! integer_key { } } -integer_key!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64); +integer_key!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64, i128, Val128, u128, Val128); macro_rules! integer_prefix { (for $($t:ty, $v:tt),+) => { @@ -298,7 +300,7 @@ macro_rules! integer_prefix { } } -integer_prefix!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64); +integer_prefix!(for i8, Val8, u8, Val8, i16, Val16, u16, Val16, i32, Val32, u32, Val32, i64, Val64, u64, Val64, i128, Val128, u128, Val128); #[cfg(test)] mod test { @@ -356,6 +358,19 @@ mod test { assert_eq!(4242i64.to_cw_bytes(), path[0].as_ref()); } + #[test] + fn naked_128key_works() { + let k: u128 = 4242u128; + let path = k.key(); + assert_eq!(1, path.len()); + assert_eq!(4242u128.to_cw_bytes(), path[0].as_ref()); + + let k: i128 = 4242i128; + let path = k.key(); + assert_eq!(1, path.len()); + assert_eq!(4242i128.to_cw_bytes(), path[0].as_ref()); + } + #[test] fn str_key_works() { type K<'a> = &'a str; From f0731c060b58bd6437b9870e098c00caa5a49970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20K=C3=BCl=C3=A7e?= Date: Tue, 29 Mar 2022 16:58:48 +0300 Subject: [PATCH 303/352] cargo fmt --- packages/storage-plus/src/keys.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index 2af4941ba..9e55bfd5b 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -22,7 +22,7 @@ impl<'a> AsRef<[u8]> for Key<'a> { Key::Val16(v) => v, Key::Val32(v) => v, Key::Val64(v) => v, - Key::Val128(v) => v + Key::Val128(v) => v, } } } From 7dc1691633be3f782ff8102f515bc42a44b9bfe2 Mon Sep 17 00:00:00 2001 From: Giancarlos Salas Date: Thu, 31 Mar 2022 23:16:03 -0500 Subject: [PATCH 304/352] Fix missing assert --- contracts/cw20-ics20/src/ibc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index 80433da32..f5f2dc213 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -557,7 +557,7 @@ mod test { res.messages[0] ); let ack: Ics20Ack = from_binary(&res.acknowledgement).unwrap(); - matches!(ack, Ics20Ack::Result(_)); + assert!(matches!(ack, Ics20Ack::Result(_))); // TODO: we need to call the reply block @@ -616,7 +616,7 @@ mod test { res.messages[0] ); let ack: Ics20Ack = from_binary(&res.acknowledgement).unwrap(); - matches!(ack, Ics20Ack::Result(_)); + assert!(matches!(ack, Ics20Ack::Result(_))); // only need to call reply block on error case From af28db23f092f573eef0f1ee03bba8dfab13f5ad Mon Sep 17 00:00:00 2001 From: Saif Uddin Mahmud Date: Wed, 6 Apr 2022 10:06:24 +0800 Subject: [PATCH 305/352] Remove dead links --- README.md | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/README.md b/README.md index 062c7fd10..caa5076bf 100644 --- a/README.md +++ b/README.md @@ -127,22 +127,6 @@ CW20 Fungible Tokens: * [`cw20-base`](./contracts/cw20-base) a straightforward, but complete implementation of the cw20 spec along with all extensions. Can be deployed as-is, or imported by other contracts. -* [`cw20-atomic-swap`](./contracts/cw20-atomic-swap) an implementation of atomic swaps for -both native and cw20 tokens. -* [`cw20-bonding`](./contracts/cw20-bonding) a smart contract implementing arbitrary bonding curves, -which can use native and cw20 tokens as reserve tokens. -* [`cw20-staking`](./contracts/cw20-staking) provides staking derivatives, -staking native tokens on your behalf and minting cw20 tokens that can -be used to claim them. It uses `cw20-base` for all the cw20 logic and -only implements the interactions with the staking module and accounting -for prices. -* [`cw20-escrow`](./contracts/cw20-escrow) is a basic escrow contract -(arbiter can release or refund tokens) that is compatible with all native -and cw20 tokens. This is a good example to show how to interact with -cw20 tokens. - -* [`cw20-merkle-airdrop`](./contracts/cw20-merkle-airdrop) is a contract - for efficient cw20 token airdrop distribution. ## Compiling From d5a9937480279c98d44852d85aa9af5c8d7fc50f Mon Sep 17 00:00:00 2001 From: Alex Lynham Date: Sat, 9 Apr 2022 12:09:57 +0100 Subject: [PATCH 306/352] multi-test: upgrade to cw-std beta8 and fix next_address --- Cargo.lock | 29 +++++++++++++++-------------- packages/multi-test/Cargo.toml | 4 ++-- packages/multi-test/src/wasm.rs | 3 ++- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed172e095..772b14a40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -155,22 +155,22 @@ checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" [[package]] name = "cosmwasm-crypto" -version = "1.0.0-beta6" +version = "1.0.0-beta8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dddc1443004c6340e55ca66d98e9d2f1a44aadf4ce2bed2c4f29baa8a15e7b7" +checksum = "37e70111e9701c3ec43bfbff0e523cd4cb115876b4d3433813436dd0934ee962" dependencies = [ "digest", "ed25519-zebra", "k256", - "rand_core 0.5.1", + "rand_core 0.6.3", "thiserror", ] [[package]] name = "cosmwasm-derive" -version = "1.0.0-beta6" +version = "1.0.0-beta8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4f0f10f165b8bcc558a13cddb498140960544519aa0581532c766dd80b5598" +checksum = "58bc2ad5d86be5f6068833f63e20786768db6890019c095dd7775232184fb7b3" dependencies = [ "syn", ] @@ -187,9 +187,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.0.0-beta6" +version = "1.0.0-beta8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0f3145097b692b2d95fa5d2c7c6fdd60f193ccc709857e7e1987a608725300" +checksum = "915ca82bd944f116f3a9717481f3fa657e4a73f28c4887288761ebb24e6fbe10" dependencies = [ "base64", "cosmwasm-crypto", @@ -204,9 +204,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.0.0-beta6" +version = "1.0.0-beta8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2945b2c28f64a09e1831f8f830641dc86b39b374c211215e88f2252f474dcb6e" +checksum = "1c4be9fd8c9d3ae7d0c32a925ecbc20707007ce0cba1f7538c0d78b7a2d3729b" dependencies = [ "cosmwasm-std", "serde", @@ -701,16 +701,17 @@ dependencies = [ [[package]] name = "ed25519-zebra" -version = "2.2.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a128b76af6dd4b427e34a6fd43dc78dbfe73672ec41ff615a2414c1a0ad0409" +checksum = "403ef3e961ab98f0ba902771d29f842058578bb1ce7e3c59dad5a6a93e784c69" dependencies = [ "curve25519-dalek", "hex", - "rand_core 0.5.1", + "rand_core 0.6.3", "serde", "sha2", "thiserror", + "zeroize", ] [[package]] @@ -1358,9 +1359,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "uint" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" +checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0" dependencies = [ "byteorder", "crunchy", diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index 739f233ee..ec2664ad2 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -20,8 +20,8 @@ backtrace = ["anyhow/backtrace"] [dependencies] cw-utils = { path = "../../packages/utils", version = "0.13.1" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1"} -cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } -cosmwasm-storage = { version = "1.0.0-beta6" } +cosmwasm-std = { version = "1.0.0-beta8", features = ["staking"] } +cosmwasm-storage = { version = "1.0.0-beta8" } itertools = "0.10.1" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index 513535230..f8cfacf98 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -779,7 +779,8 @@ where .range_raw(storage, None, None, Order::Ascending) .count(); // we make this longer so it is not rejected by tests - Addr::unchecked(format!("Contract #{}", count)) + // it is lowercase to be compatible with beta8 + Addr::unchecked(format!("contract{}", count)) } fn contract_namespace(&self, contract: &Addr) -> Vec { From 6fe6ca1bd55564c7d21803a00a76b2a6ab89bf28 Mon Sep 17 00:00:00 2001 From: Alex Lynham Date: Sat, 9 Apr 2022 13:58:29 +0100 Subject: [PATCH 307/352] Update all cw-std beta6 -> beta8 and all 0.13.1 -> 0.13.2 --- .circleci/config.yml | 2 +- Cargo.lock | 44 ++++++++++++------------- contracts/cw1-subkeys/Cargo.toml | 18 +++++----- contracts/cw1-whitelist-ng/Cargo.toml | 18 +++++----- contracts/cw1-whitelist/Cargo.toml | 16 ++++----- contracts/cw1155-base/Cargo.toml | 14 ++++---- contracts/cw20-base/Cargo.toml | 14 ++++---- contracts/cw20-ics20/Cargo.toml | 16 ++++----- contracts/cw3-fixed-multisig/Cargo.toml | 20 +++++------ contracts/cw3-flex-multisig/Cargo.toml | 22 ++++++------- contracts/cw4-group/Cargo.toml | 16 ++++----- contracts/cw4-stake/Cargo.toml | 18 +++++----- packages/controllers/Cargo.toml | 8 ++--- packages/cw1/Cargo.toml | 6 ++-- packages/cw1155/Cargo.toml | 8 ++--- packages/cw2/Cargo.toml | 6 ++-- packages/cw20/Cargo.toml | 8 ++--- packages/cw3/Cargo.toml | 8 ++--- packages/cw4/Cargo.toml | 8 ++--- packages/multi-test/Cargo.toml | 6 ++-- packages/storage-plus/Cargo.toml | 4 +-- packages/utils/Cargo.toml | 6 ++-- 22 files changed, 143 insertions(+), 143 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 777aff31b..3f195444e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -597,7 +597,7 @@ jobs: - run: name: Install check_contract # Uses --debug for compilation speed - command: cargo install --debug --version 1.0.0-beta6 --features iterator --example check_contract -- cosmwasm-vm + command: cargo install --debug --version 1.0.0-beta8 --features iterator --example check_contract -- cosmwasm-vm - save_cache: paths: - /usr/local/cargo/registry diff --git a/Cargo.lock b/Cargo.lock index 772b14a40..b4efb6445 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -177,9 +177,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema" -version = "1.0.0-beta6" +version = "1.0.0-beta8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497432aa9a8e154e3789845f64049d088eb797ba5a7f78da312153f46c822388" +checksum = "0d75f6a05667d8613b24171ef2c77a8bf6fb9c14f9e3aaa39aa10e0c6416ed67" dependencies = [ "schemars", "serde_json", @@ -366,7 +366,7 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -378,7 +378,7 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.13.1" +version = "0.13.2" dependencies = [ "anyhow", "cosmwasm-std", @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-std", "criterion", @@ -406,7 +406,7 @@ dependencies = [ [[package]] name = "cw-utils" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -418,7 +418,7 @@ dependencies = [ [[package]] name = "cw1" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -428,7 +428,7 @@ dependencies = [ [[package]] name = "cw1-subkeys" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -445,7 +445,7 @@ dependencies = [ [[package]] name = "cw1-whitelist" -version = "0.13.1" +version = "0.13.2" dependencies = [ "anyhow", "assert_matches", @@ -464,7 +464,7 @@ dependencies = [ [[package]] name = "cw1-whitelist-ng" -version = "0.13.1" +version = "0.13.2" dependencies = [ "anyhow", "assert_matches", @@ -483,7 +483,7 @@ dependencies = [ [[package]] name = "cw1155" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -494,7 +494,7 @@ dependencies = [ [[package]] name = "cw1155-base" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -509,7 +509,7 @@ dependencies = [ [[package]] name = "cw2" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -519,7 +519,7 @@ dependencies = [ [[package]] name = "cw20" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -530,7 +530,7 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -545,7 +545,7 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -562,7 +562,7 @@ dependencies = [ [[package]] name = "cw3" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -573,7 +573,7 @@ dependencies = [ [[package]] name = "cw3-fixed-multisig" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -591,7 +591,7 @@ dependencies = [ [[package]] name = "cw3-flex-multisig" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -610,7 +610,7 @@ dependencies = [ [[package]] name = "cw4" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -621,7 +621,7 @@ dependencies = [ [[package]] name = "cw4-group" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -637,7 +637,7 @@ dependencies = [ [[package]] name = "cw4-stake" -version = "0.13.1" +version = "0.13.2" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 8913fc731..1e10ab7ea 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-subkeys" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Implement subkeys for authorizing native tokens as a cw1 proxy contract" @@ -19,17 +19,17 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw1 = { path = "../../packages/cw1", version = "0.13.1" } -cw2 = { path = "../../packages/cw2", version = "0.13.1" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.1", features = ["library"] } -cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw1 = { path = "../../packages/cw1", version = "0.13.2" } +cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.2", features = ["library"] } +cosmwasm-std = { version = "1.0.0-beta8", features = ["staking"] } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.23" semver = "1" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.1", features = ["library", "test-utils"] } +cosmwasm-schema = { version = "1.0.0-beta8" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.2", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index 90445d219..55eee448a 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist-ng" -version = "0.13.1" +version = "0.13.2" authors = ["Bartłomiej Kuras "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -22,20 +22,20 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw1 = { path = "../../packages/cw1", version = "0.13.1" } -cw2 = { path = "../../packages/cw2", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw1 = { path = "../../packages/cw1", version = "0.13.2" } +cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8", features = ["staking"] } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.1", optional = true } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2", optional = true } anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" -cosmwasm-schema = { version = "1.0.0-beta6" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.1" } +cosmwasm-schema = { version = "1.0.0-beta8" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index 47da30eb3..f9b549856 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw1 = { path = "../../packages/cw1", version = "0.13.1" } -cw2 = { path = "../../packages/cw2", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw1 = { path = "../../packages/cw1", version = "0.13.2" } +cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8", features = ["staking"] } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -31,6 +31,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] anyhow = "1" assert_matches = "1" -cosmwasm-schema = { version = "1.0.0-beta6" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.1" } +cosmwasm-schema = { version = "1.0.0-beta8" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index edd5f7399..b003fad9c 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155-base" -version = "0.13.1" +version = "0.13.2" authors = ["Huang Yi "] edition = "2018" description = "Basic implementation of a CosmWasm-1155 compliant token" @@ -18,14 +18,14 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw2 = { path = "../../packages/cw2", version = "0.13.1" } -cw1155 = { path = "../../packages/cw1155", version = "0.13.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cw1155 = { path = "../../packages/cw1155", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } +cosmwasm-schema = { version = "1.0.0-beta8" } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index cb05c9620..b82698eb4 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-base" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation of a CosmWasm-20 compliant token" @@ -18,14 +18,14 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw2 = { path = "../../packages/cw2", version = "0.13.1" } -cw20 = { path = "../../packages/cw20", version = "0.13.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cw20 = { path = "../../packages/cw20", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } +cosmwasm-schema = { version = "1.0.0-beta8" } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 68c76cb95..74c101605 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain" @@ -18,16 +18,16 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw2 = { path = "../../packages/cw2", version = "0.13.1" } -cw20 = { path = "../../packages/cw20", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6", features = ["stargate"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.1" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cw20 = { path = "../../packages/cw20", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8", features = ["stargate"] } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.2" } schemars = "0.8.1" semver = "1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } +cosmwasm-schema = { version = "1.0.0-beta8" } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index a06f37679..fab4ea012 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-fixed-multisig" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with an fixed group multisig" @@ -18,17 +18,17 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw2 = { path = "../../packages/cw2", version = "0.13.1" } -cw3 = { path = "../../packages/cw3", version = "0.13.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cw3 = { path = "../../packages/cw3", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } -cw20 = { path = "../../packages/cw20", version = "0.13.1" } -cw20-base = { path = "../cw20-base", version = "0.13.1", features = ["library"] } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.1" } +cosmwasm-schema = { version = "1.0.0-beta8" } +cw20 = { path = "../../packages/cw20", version = "0.13.2" } +cw20-base = { path = "../cw20-base", version = "0.13.2", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 673434d5c..16039cb72 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-flex-multisig" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with multiple voting patterns and dynamic groups" @@ -18,18 +18,18 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw2 = { path = "../../packages/cw2", version = "0.13.1" } -cw3 = { path = "../../packages/cw3", version = "0.13.1" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.13.1", features = ["library"] } -cw4 = { path = "../../packages/cw4", version = "0.13.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cw3 = { path = "../../packages/cw3", version = "0.13.2" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.13.2", features = ["library"] } +cw4 = { path = "../../packages/cw4", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } -cw4-group = { path = "../cw4-group", version = "0.13.1" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.1" } +cosmwasm-schema = { version = "1.0.0-beta8" } +cw4-group = { path = "../cw4-group", version = "0.13.2" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index 610921433..a1b7e07ef 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-group" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Simple cw4 implementation of group membership controlled by admin " @@ -26,15 +26,15 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw2 = { path = "../../packages/cw2", version = "0.13.1" } -cw4 = { path = "../../packages/cw4", version = "0.13.1" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cw4 = { path = "../../packages/cw4", version = "0.13.2" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } +cosmwasm-schema = { version = "1.0.0-beta8" } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index f5e97cd78..c0dfb9286 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-stake" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "CW4 implementation of group based on staked tokens" @@ -26,16 +26,16 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw2 = { path = "../../packages/cw2", version = "0.13.1" } -cw4 = { path = "../../packages/cw4", version = "0.13.1" } -cw20 = { path = "../../packages/cw20", version = "0.13.1" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cw4 = { path = "../../packages/cw4", version = "0.13.2" } +cw20 = { path = "../../packages/cw20", version = "0.13.2" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } +cosmwasm-schema = { version = "1.0.0-beta8" } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index 56b12b5f5..ed8607745 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-controllers" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Common controllers we can reuse in many contracts" @@ -12,9 +12,9 @@ documentation = "https://docs.cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0-beta6" } -cw-utils = { path = "../utils", version = "0.13.1" } -cw-storage-plus = { path = "../storage-plus", version = "0.13.1" } +cosmwasm-std = { version = "1.0.0-beta8" } +cw-utils = { path = "../utils", version = "0.13.2" } +cw-storage-plus = { path = "../storage-plus", version = "0.13.2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index ecfe3482d..f3584ce5b 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-1 interface" @@ -10,9 +10,9 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0-beta6" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } +cosmwasm-schema = { version = "1.0.0-beta8" } diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index c5980ff07..2ce6796aa 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155" -version = "0.13.1" +version = "0.13.2" authors = ["Huang Yi "] edition = "2018" description = "Definition and types for the CosmWasm-1155 interface" @@ -10,10 +10,10 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } +cosmwasm-schema = { version = "1.0.0-beta8" } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 136105e22..5b0ea1997 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw2" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-2 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0-beta6", default-features = false } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } +cosmwasm-std = { version = "1.0.0-beta8", default-features = false } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index d04bd3e6d..353ab8d9b 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-20 interface" @@ -10,10 +10,10 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } +cosmwasm-schema = { version = "1.0.0-beta8" } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index 45c5e4106..6a9d45b41 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-3 Interface: On-Chain MultiSig/Voting contracts" @@ -10,10 +10,10 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6" } +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } +cosmwasm-schema = { version = "1.0.0-beta8" } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index e5fe7c8f2..9d9c972bb 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-4 Interface: Groups Members" @@ -10,10 +10,10 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-storage-plus = { path = "../storage-plus", version = "0.13.1" } -cosmwasm-std = { version = "1.0.0-beta6" } +cw-storage-plus = { path = "../storage-plus", version = "0.13.2" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta6" } +cosmwasm-schema = { version = "1.0.0-beta8" } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index ec2664ad2..82505a7ba 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-multi-test" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Test helpers for multi-contract interactions" @@ -18,8 +18,8 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.1" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1"} +cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2"} cosmwasm-std = { version = "1.0.0-beta8", features = ["staking"] } cosmwasm-storage = { version = "1.0.0-beta8" } itertools = "0.10.1" diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 2b35f106b..6656060d1 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-storage-plus" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Enhanced storage engines" @@ -18,7 +18,7 @@ iterator = ["cosmwasm-std/iterator"] bench = false [dependencies] -cosmwasm-std = { version = "1.0.0-beta6", default-features = false } +cosmwasm-std = { version = "1.0.0-beta8", default-features = false } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index 8c8a29bac..26e25d475 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-utils" -version = "0.13.1" +version = "0.13.2" authors = ["Ethan Frey "] edition = "2018" description = "Common helpers for other cw specs" @@ -12,11 +12,11 @@ documentation = "https://docs.cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0-beta6" } +cosmwasm-std = { version = "1.0.0-beta8" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } [dev-dependencies] -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.1" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } prost = "0.9" From bc2aa29f3e7c55d2086cbec53ff4fd40e7197e7e Mon Sep 17 00:00:00 2001 From: Alex Lynham Date: Sat, 9 Apr 2022 14:03:56 +0100 Subject: [PATCH 308/352] Update code comment as suggested by @webmaster128 --- packages/multi-test/src/wasm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index f8cfacf98..8182bc3c4 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -779,7 +779,7 @@ where .range_raw(storage, None, None, Order::Ascending) .count(); // we make this longer so it is not rejected by tests - // it is lowercase to be compatible with beta8 + // it is lowercase to be compatible with the MockApi implementation of cosmwasm-std >= 1.0.0-beta8 Addr::unchecked(format!("contract{}", count)) } From 37c0a5acd5b10c6e44d191a33edbaed6e5083f0c Mon Sep 17 00:00:00 2001 From: Alex Lynham Date: Sat, 9 Apr 2022 14:05:42 +0100 Subject: [PATCH 309/352] Update current version for v3 in ics20 --- contracts/cw20-ics20/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 894199dea..bcb71733c 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -204,7 +204,7 @@ pub fn execute_allow( const MIGRATE_MIN_VERSION: &str = "0.11.1"; const MIGRATE_VERSION_2: &str = "0.12.0-alpha1"; -const MIGRATE_VERSION_3: &str = "0.13.1"; +const MIGRATE_VERSION_3: &str = "0.13.2"; #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(mut deps: DepsMut, env: Env, msg: MigrateMsg) -> Result { From f36ed40df1d21e3e0a914efdd6535cbeab78981c Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 11 Apr 2022 21:27:51 -0400 Subject: [PATCH 310/352] Add has to indexed map --- packages/storage-plus/src/indexed_map.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 1771b0df2..062d7ce96 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -130,6 +130,12 @@ where self.primary.may_load(store, key) } + /// has returns true or false if any data is at this key, without parsing or interpreting the + /// contents. + pub fn has(&self, store: &dyn Storage, k: K) -> bool { + self.primary.key(k).has(store) + } + // use no_prefix to scan -> range fn no_prefix_raw(&self) -> Prefix, T, K> { Prefix::new(self.pk_namespace, &[]) @@ -519,6 +525,24 @@ mod test { assert_eq!(None, aged); } + #[test] + fn existence() { + let mut store = MockStorage::new(); + let map = build_map(); + + // save data + let (pks, datas) = save_data(&mut store, &map); + let pk = pks[0]; + let data = &datas[0]; + + // load it properly + let loaded = map.load(&store, pk).unwrap(); + assert_eq!(*data, loaded); + + assert!(map.has(&store, pks[1])); + assert!(!map.has(&store, "6")); + } + #[test] fn range_raw_simple_key_by_multi_index() { let mut store = MockStorage::new(); From ddd2351b1cae086d4f9cc4d43e85260c4e44dc1f Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 13 Apr 2022 08:30:19 +0200 Subject: [PATCH 311/352] Update link to new shared CosmWasm SECURITY.md --- SECURITY.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 1b10ff8e5..830ec1711 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,5 +1,9 @@ # Security Policy +This repository is maintained by Confio as part of the CosmWasm stack. +Please see https://github.com/CosmWasm/advisories/blob/main/SECURITY.md +for our security policy. + ## Supported Versions cw-plus is still pre v1.0. A best effort has been made that the contracts here are secure, and we have moved the more @@ -10,9 +14,3 @@ with significant token value, and please inform us if it detects any issues so w Until v1.0 APIs are subject to change. The contracts APIs are pretty much stable, most work is currently in `storage-plus` and `multi-test`. - -## Reporting a Vulnerability - -We have a [unified security policy](https://github.com/CosmWasm/wasmd/blob/master/SECURITY.md) -for all CosmWasm-related repositories maintained by Confio. -You can [read it here](https://github.com/CosmWasm/wasmd/blob/master/SECURITY.md) From 1b09774fdc6436d6766d2350bdb4fd0617e52d07 Mon Sep 17 00:00:00 2001 From: "shane.stars" Date: Thu, 14 Apr 2022 09:26:32 -0400 Subject: [PATCH 312/352] Update packages/storage-plus/src/indexed_map.rs Co-authored-by: Jakub Bogucki --- packages/storage-plus/src/indexed_map.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index 062d7ce96..a70bb412b 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -130,8 +130,7 @@ where self.primary.may_load(store, key) } - /// has returns true or false if any data is at this key, without parsing or interpreting the - /// contents. + /// Returns true if storage contains this key, without parsing or interpreting the contents. pub fn has(&self, store: &dyn Storage, k: K) -> bool { self.primary.key(k).has(store) } From b40bdcaa8138e7063dd2773c94db6c7422d60e82 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Thu, 14 Apr 2022 09:31:48 -0400 Subject: [PATCH 313/352] Simplified test --- packages/storage-plus/src/indexed_map.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/storage-plus/src/indexed_map.rs b/packages/storage-plus/src/indexed_map.rs index a70bb412b..55d572958 100644 --- a/packages/storage-plus/src/indexed_map.rs +++ b/packages/storage-plus/src/indexed_map.rs @@ -528,17 +528,9 @@ mod test { fn existence() { let mut store = MockStorage::new(); let map = build_map(); + let (pks, _) = save_data(&mut store, &map); - // save data - let (pks, datas) = save_data(&mut store, &map); - let pk = pks[0]; - let data = &datas[0]; - - // load it properly - let loaded = map.load(&store, pk).unwrap(); - assert_eq!(*data, loaded); - - assert!(map.has(&store, pks[1])); + assert!(map.has(&store, pks[0])); assert!(!map.has(&store, "6")); } From 3f5a3cd9475d45d11a424e5593b32195bb6825b3 Mon Sep 17 00:00:00 2001 From: Artie Kushner <34076599+rtviii@users.noreply.github.com> Date: Wed, 27 Apr 2022 18:31:21 -0700 Subject: [PATCH 314/352] Update item.rs --- packages/storage-plus/src/item.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/src/item.rs b/packages/storage-plus/src/item.rs index 312a87fef..78ec3b73e 100644 --- a/packages/storage-plus/src/item.rs +++ b/packages/storage-plus/src/item.rs @@ -10,7 +10,7 @@ use crate::helpers::{may_deserialize, must_deserialize}; /// Item stores one typed item at the given key. /// This is an analog of Singleton. -/// It functions just as Path but doesn't ue a Vec and thus has a const fn constructor. +/// It functions the same way Path does but doesn't use a Vec and thus has a const fn constructor. pub struct Item<'a, T> { // this is full key - no need to length-prefix it, we only store one item storage_key: &'a [u8], From 057786e329a033df1ac0e3e38acd24d51ce48d28 Mon Sep 17 00:00:00 2001 From: Artie Kushner <34076599+rtviii@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:48:22 -0700 Subject: [PATCH 315/352] Update packages/storage-plus/src/item.rs Co-authored-by: Jakub Bogucki --- packages/storage-plus/src/item.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storage-plus/src/item.rs b/packages/storage-plus/src/item.rs index 78ec3b73e..865fd534e 100644 --- a/packages/storage-plus/src/item.rs +++ b/packages/storage-plus/src/item.rs @@ -10,7 +10,7 @@ use crate::helpers::{may_deserialize, must_deserialize}; /// Item stores one typed item at the given key. /// This is an analog of Singleton. -/// It functions the same way Path does but doesn't use a Vec and thus has a const fn constructor. +/// It functions the same way as Path does but doesn't use a Vec and thus has a const fn constructor. pub struct Item<'a, T> { // this is full key - no need to length-prefix it, we only store one item storage_key: &'a [u8], From 1729df0f3ac7078a823b8e35e92863abe1495055 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 3 May 2022 13:03:59 +0200 Subject: [PATCH 316/352] Add tarpaulin code coverage to CI --- .circleci/config.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3f195444e..87179718b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,6 +34,15 @@ workflows: # Long living branches - main # 👇Add your branch here if benchmarking matters to your work + coverage: + jobs: + - coverage: + filters: + branches: + only: + # Long living branches + - main + # 👇Add your branch here if code coverage matters to your work deploy: jobs: - build_and_upload_contracts: @@ -695,6 +704,15 @@ jobs: - target key: cargocache-v2-benchmarking-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} + # This job follows the instructions from https://github.com/xd009642/tarpaulin#circleci + coverage: + machine: true + steps: + - checkout + - run: + name: Coverage with tarpaulin docker image + command: docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin + # This job roughly follows the instructions from https://circleci.com/blog/publishing-to-github-releases-via-circleci/ build_and_upload_contracts: docker: From ed1803c5126dc592307fc1be5dabea5fabd2cd87 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 3 May 2022 13:10:12 +0200 Subject: [PATCH 317/352] Add dev branch to code coverage --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 87179718b..fc78e0fd1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -43,6 +43,7 @@ workflows: # Long living branches - main # 👇Add your branch here if code coverage matters to your work + - 172-code-coverage deploy: jobs: - build_and_upload_contracts: From 764faa5a0fa4c1c5200d5258ac1fa4ecc2c97d28 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 3 May 2022 13:27:18 +0200 Subject: [PATCH 318/352] Switch to a supported image in machine job --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fc78e0fd1..0772c066a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -707,7 +707,8 @@ jobs: # This job follows the instructions from https://github.com/xd009642/tarpaulin#circleci coverage: - machine: true + machine: + image: ubuntu-2004:202201-02 steps: - checkout - run: From 459afb62b316bdea450061d1c23952f9ec54f799 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 3 May 2022 16:03:37 +0200 Subject: [PATCH 319/352] Add codecov orb for coverage results --- .circleci/config.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0772c066a..53e9b69ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,8 @@ -version: 2 +version: 2.1 + +orbs: + codecov: codecov/codecov@3.2.2 + workflows: version: 2 test: @@ -34,6 +38,7 @@ workflows: # Long living branches - main # 👇Add your branch here if benchmarking matters to your work + coverage: jobs: - coverage: @@ -705,15 +710,20 @@ jobs: - target key: cargocache-v2-benchmarking-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} - # This job follows the instructions from https://github.com/xd009642/tarpaulin#circleci coverage: + # https://circleci.com/developer/images?imageType=machine machine: image: ubuntu-2004:202201-02 steps: - checkout - run: - name: Coverage with tarpaulin docker image - command: docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin + name: Run tests with coverage + command: | + mkdir -p cov + docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin \ + sh -c "cargo tarpaulin --skip-clean --frozen --out Xml --output-dir cov" + - codecov/upload: + file: cov/cobertura.html # This job roughly follows the instructions from https://circleci.com/blog/publishing-to-github-releases-via-circleci/ build_and_upload_contracts: From 306a683e5550b968371ccae0f58ff10c23e7d69f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 3 May 2022 17:57:37 +0200 Subject: [PATCH 320/352] Add codecov setup file --- codecov.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..acfcbf4ca --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +comment: false + +coverage: + status: + project: + default: + threshold: 0.05% + patch: + default: + threshold: 0.05% + +ignore: + +flags: From 966eab9526f1195a3edcfeb218772df2d375dc47 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 3 May 2022 18:07:43 +0200 Subject: [PATCH 321/352] Fix cobertura file extension --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 53e9b69ed..69d611fce 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -723,7 +723,7 @@ jobs: docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin \ sh -c "cargo tarpaulin --skip-clean --frozen --out Xml --output-dir cov" - codecov/upload: - file: cov/cobertura.html + file: cov/cobertura.xml # This job roughly follows the instructions from https://circleci.com/blog/publishing-to-github-releases-via-circleci/ build_and_upload_contracts: From ef69301e30cfff941e01f3ebe5ee162a8dbbc87b Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 3 May 2022 21:20:28 +0200 Subject: [PATCH 322/352] Fix: validated codecov.yml --- codecov.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/codecov.yml b/codecov.yml index acfcbf4ca..a33250820 100644 --- a/codecov.yml +++ b/codecov.yml @@ -10,5 +10,3 @@ coverage: threshold: 0.05% ignore: - -flags: From d740cb1e5a33cc8fa40d7363a27527db21a1dec2 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Tue, 3 May 2022 21:45:06 +0200 Subject: [PATCH 323/352] Add cove coverage badge to README --- README.md | 59 +++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index caa5076bf..cd56c7cae 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,34 @@ # CosmWasm Plus -[![CircleCI](https://circleci.com/gh/CosmWasm/cw-plus/tree/master.svg?style=shield)](https://circleci.com/gh/CosmWasm/cw-plus/tree/master) - -| Specification | Crates.io | Docs | -| ---------------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------| -| cw1 | [![cw1 on crates.io](https://img.shields.io/crates/v/cw1.svg)](https://crates.io/crates/cw1) | [![Docs](https://docs.rs/cw1/badge.svg)](https://docs.rs/cw1) | -| cw2 | [![cw2 on crates.io](https://img.shields.io/crates/v/cw2.svg)](https://crates.io/crates/cw2) | [![Docs](https://docs.rs/cw2/badge.svg)](https://docs.rs/cw2) | -| cw3 | [![cw3 on crates.io](https://img.shields.io/crates/v/cw3.svg)](https://crates.io/crates/cw3) | [![Docs](https://docs.rs/cw3/badge.svg)](https://docs.rs/cw3) | -| cw4 | [![cw4 on crates.io](https://img.shields.io/crates/v/cw4.svg)](https://crates.io/crates/cw4) | [![Docs](https://docs.rs/cw4/badge.svg)](https://docs.rs/cw4) | -| cw20 | [![cw20 on crates.io](https://img.shields.io/crates/v/cw20.svg)](https://crates.io/crates/cw20) | [![Docs](https://docs.rs/cw20/badge.svg)](https://docs.rs/cw20) | -| cw1155 | [![cw1155 on crates.io](https://img.shields.io/crates/v/cw1155.svg)](https://crates.io/crates/cw1155) | [![Docs](https://docs.rs/cw1155/badge.svg)](https://docs.rs/cw1155) | - -| Utilities | Crates.io | Docs | -| ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------| -| cw-controllers | [![cw-controllers on crates.io](https://img.shields.io/crates/v/cw-controllers.svg)](https://crates.io/crates/cw-controllers) | [![Docs](https://docs.rs/cw-controllers/badge.svg)](https://docs.rs/cw-controllers) | -| cw-multi-test | [![cw-multi-test on crates.io](https://img.shields.io/crates/v/cw-multi-test.svg)](https://crates.io/crates/cw-multi-test) | [![Docs](https://docs.rs/cw-multi-test/badge.svg)](https://docs.rs/cw-multi-test) | -| cw-storage-plus | [![cw-storage-plus on crates.io](https://img.shields.io/crates/v/cw-storage-plus.svg)](https://crates.io/crates/cw-storage-plus) | [![Docs](https://docs.rs/cw-storage-plus/badge.svg)](https://docs.rs/cw-storage-plus) | -| cw-utils | [![cw-utils on crates.io](https://img.shields.io/crates/v/cw-utils.svg)](https://crates.io/crates/cw-utils) | [![Docs](https://docs.rs/cw-utils/badge.svg)](https://docs.rs/cw-utils) | - -| Contracts | Download | Docs | -| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------| -| cw1-subkeys | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw1_subkeys.wasm) | [![Docs](https://docs.rs/cw1-subkeys/badge.svg)](https://docs.rs/cw1-subkeys) | -| cw1-whitelist | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw1_whitelist.wasm) | [![Docs](https://docs.rs/cw1-whitelist/badge.svg)](https://docs.rs/cw1-whitelist) | -| cw3-fixed-multisig | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw3_fixed_multisig.wasm) | [![Docs](https://docs.rs/cw3-fixed-multisig/badge.svg)](https://docs.rs/cw3-fixed-multisig) | -| cw3-flex-multisig | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw3_flex_multisig.wasm) | [![Docs](https://docs.rs/cw3-flex-multisig/badge.svg)](https://docs.rs/cw3-flex-multisig) | -| cw4-group | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw4_group.wasm) | [![Docs](https://docs.rs/cw4-group/badge.svg)](https://docs.rs/cw4-group) | -| cw4-stake | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw4_stake.wasm) | [![Docs](https://docs.rs/cw4-stake/badge.svg)](https://docs.rs/cw4-stake) | -| cw20-base | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_base.wasm) | [![Docs](https://docs.rs/cw20-base/badge.svg)](https://docs.rs/cw20-base) | -| cw20-ics20 | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_ics20.wasm) | [![Docs](https://docs.rs/cw20-ics20/badge.svg)](https://docs.rs/cw20-ics20) | -| cw1155-base | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw1155_base.wasm) | [![Docs](https://docs.rs/cw1155-base/badge.svg)](https://docs.rs/cw1155-base) | - +[![CircleCI](https://circleci.com/gh/CosmWasm/cw-plus/tree/main.svg?style=shield)](https://circleci.com/gh/CosmWasm/cw-plus/tree/main) + +| Specification | Crates.io | Docs | Coverage | +|---------------|-------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------| +| cw1 | [![cw1 on crates.io](https://img.shields.io/crates/v/cw1.svg)](https://crates.io/crates/cw1) | [![Docs](https://docs.rs/cw1/badge.svg)](https://docs.rs/cw1) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw2 | [![cw2 on crates.io](https://img.shields.io/crates/v/cw2.svg)](https://crates.io/crates/cw2) | [![Docs](https://docs.rs/cw2/badge.svg)](https://docs.rs/cw2) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw3 | [![cw3 on crates.io](https://img.shields.io/crates/v/cw3.svg)](https://crates.io/crates/cw3) | [![Docs](https://docs.rs/cw3/badge.svg)](https://docs.rs/cw3) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw4 | [![cw4 on crates.io](https://img.shields.io/crates/v/cw4.svg)](https://crates.io/crates/cw4) | [![Docs](https://docs.rs/cw4/badge.svg)](https://docs.rs/cw4) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw20 | [![cw20 on crates.io](https://img.shields.io/crates/v/cw20.svg)](https://crates.io/crates/cw20) | [![Docs](https://docs.rs/cw20/badge.svg)](https://docs.rs/cw20) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw1155 | [![cw1155 on crates.io](https://img.shields.io/crates/v/cw1155.svg)](https://crates.io/crates/cw1155) | [![Docs](https://docs.rs/cw1155/badge.svg)](https://docs.rs/cw1155) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | + +| Utilities | Crates.io | Docs | Coverage | +|-----------------|----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------| +| cw-controllers | [![cw-controllers on crates.io](https://img.shields.io/crates/v/cw-controllers.svg)](https://crates.io/crates/cw-controllers) | [![Docs](https://docs.rs/cw-controllers/badge.svg)](https://docs.rs/cw-controllers) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw-multi-test | [![cw-multi-test on crates.io](https://img.shields.io/crates/v/cw-multi-test.svg)](https://crates.io/crates/cw-multi-test) | [![Docs](https://docs.rs/cw-multi-test/badge.svg)](https://docs.rs/cw-multi-test) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | | +| cw-storage-plus | [![cw-storage-plus on crates.io](https://img.shields.io/crates/v/cw-storage-plus.svg)](https://crates.io/crates/cw-storage-plus) | [![Docs](https://docs.rs/cw-storage-plus/badge.svg)](https://docs.rs/cw-storage-plus) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw-utils | [![cw-utils on crates.io](https://img.shields.io/crates/v/cw-utils.svg)](https://crates.io/crates/cw-utils) | [![Docs](https://docs.rs/cw-utils/badge.svg)](https://docs.rs/cw-utils) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | + +| Contracts | Download | Docs | Coverage | +|--------------------|----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------| +| cw1-subkeys | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw1_subkeys.wasm) | [![Docs](https://docs.rs/cw1-subkeys/badge.svg)](https://docs.rs/cw1-subkeys) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw1-whitelist | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw1_whitelist.wasm) | [![Docs](https://docs.rs/cw1-whitelist/badge.svg)](https://docs.rs/cw1-whitelist) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw3-fixed-multisig | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw3_fixed_multisig.wasm) | [![Docs](https://docs.rs/cw3-fixed-multisig/badge.svg)](https://docs.rs/cw3-fixed-multisig) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw3-flex-multisig | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw3_flex_multisig.wasm) | [![Docs](https://docs.rs/cw3-flex-multisig/badge.svg)](https://docs.rs/cw3-flex-multisig) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw4-group | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw4_group.wasm) | [![Docs](https://docs.rs/cw4-group/badge.svg)](https://docs.rs/cw4-group) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw4-stake | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw4_stake.wasm) | [![Docs](https://docs.rs/cw4-stake/badge.svg)](https://docs.rs/cw4-stake) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw20-base | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_base.wasm) | [![Docs](https://docs.rs/cw20-base/badge.svg)](https://docs.rs/cw20-base) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw20-ics20 | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw20_ics20.wasm) | [![Docs](https://docs.rs/cw20-ics20/badge.svg)](https://docs.rs/cw20-ics20) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | +| cw1155-base | [Release v0.10.3](https://github.com/CosmWasm/cw-plus/releases/download/v0.10.3/cw1155_base.wasm) | [![Docs](https://docs.rs/cw1155-base/badge.svg)](https://docs.rs/cw1155-base) | [![codecov](https://codecov.io/gh/CosmWasm/cw-plus/branch/main/graph/badge.svg?token=IYY72ZVS3X)](https://codecov.io/gh/CosmWasm/cw-plus) | Note: `cw721` and `cw721-base` have moved to the new [`cw-nfts` repo](https://github.com/CosmWasm/cw-nfts) and can be followed there. From 58348b80553d8af7a68cce5b9dc15176833373ba Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 5 May 2022 08:26:09 +0200 Subject: [PATCH 324/352] Run coverage on all branches Run coverage as part of tests --- .circleci/config.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 69d611fce..f62325e34 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,17 +38,7 @@ workflows: # Long living branches - main # 👇Add your branch here if benchmarking matters to your work - - coverage: - jobs: - - coverage: - filters: - branches: - only: - # Long living branches - - main - # 👇Add your branch here if code coverage matters to your work - - 172-code-coverage + - coverage deploy: jobs: - build_and_upload_contracts: From b923f8ada766187956081af2de6dd2f6403d3853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kuras?= Date: Mon, 16 May 2022 13:58:56 +0200 Subject: [PATCH 325/352] Repo reclippization --- Cargo.lock | 264 ++++++++++-------- packages/multi-test/src/executor.rs | 7 +- .../src/test_helpers/contracts/echo.rs | 22 +- packages/multi-test/src/wasm.rs | 4 +- packages/storage-plus/src/prefix.rs | 3 +- packages/utils/src/parse_reply.rs | 6 +- 6 files changed, 171 insertions(+), 135 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4efb6445..df3eb49ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "anyhow" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" +checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" dependencies = [ "backtrace", ] @@ -51,9 +51,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f" +checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" dependencies = [ "addr2line", "cc", @@ -64,12 +64,24 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64ct" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" + [[package]] name = "bitflags" version = "1.3.2" @@ -149,15 +161,15 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" [[package]] name = "cosmwasm-crypto" -version = "1.0.0-beta8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e70111e9701c3ec43bfbff0e523cd4cb115876b4d3433813436dd0934ee962" +checksum = "5eb0afef2325df81aadbf9be1233f522ed8f6e91df870c764bc44cca2b1415bd" dependencies = [ "digest", "ed25519-zebra", @@ -168,18 +180,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.0.0-beta8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc2ad5d86be5f6068833f63e20786768db6890019c095dd7775232184fb7b3" +checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.0.0-beta8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d75f6a05667d8613b24171ef2c77a8bf6fb9c14f9e3aaa39aa10e0c6416ed67" +checksum = "772e80bbad231a47a2068812b723a1ff81dd4a0d56c9391ac748177bea3a61da" dependencies = [ "schemars", "serde_json", @@ -187,9 +199,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.0.0-beta8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915ca82bd944f116f3a9717481f3fa657e4a73f28c4887288761ebb24e6fbe10" +checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195" dependencies = [ "base64", "cosmwasm-crypto", @@ -204,9 +216,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.0.0-beta8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4be9fd8c9d3ae7d0c32a925ecbc20707007ce0cba1f7538c0d78b7a2d3729b" +checksum = "d18403b07304d15d304dad11040d45bbcaf78d603b4be3fb5e2685c16f9229b5" dependencies = [ "cosmwasm-std", "serde", @@ -214,9 +226,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" dependencies = [ "libc", ] @@ -259,9 +271,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" +checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" dependencies = [ "cfg-if", "crossbeam-utils", @@ -280,10 +292,11 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9" +checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" dependencies = [ + "autocfg", "cfg-if", "crossbeam-utils", "lazy_static", @@ -293,9 +306,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" +checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ "cfg-if", "lazy_static", @@ -309,9 +322,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.2.11" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" dependencies = [ "generic-array", "rand_core 0.6.3", @@ -654,9 +667,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" dependencies = [ "const-oid", ] @@ -683,19 +696,19 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" +checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" dependencies = [ "der", "elliptic-curve", - "hmac", + "rfc6979", "signature", ] @@ -722,25 +735,27 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" dependencies = [ + "base16ct", "crypto-bigint", + "der", "ff", "generic-array", "group", - "pkcs8", "rand_core 0.6.3", + "sec1", "subtle", "zeroize", ] [[package]] name = "ff" -version = "0.10.1" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" dependencies = [ "rand_core 0.6.3", "subtle", @@ -775,9 +790,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" +checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if", "libc", @@ -792,9 +807,9 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" dependencies = [ "ff", "rand_core 0.6.3", @@ -849,28 +864,29 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" [[package]] name = "js-sys" -version = "0.3.56" +version = "0.3.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" +checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.9.6" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", + "sec1", "sha2", ] @@ -882,24 +898,24 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.119" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" +checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" [[package]] name = "log" -version = "0.4.14" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", ] [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" @@ -912,19 +928,18 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" dependencies = [ "adler", - "autocfg", ] [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] @@ -941,9 +956,9 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.28.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" dependencies = [ "memchr", ] @@ -962,12 +977,13 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" dependencies = [ "der", "spki", + "zeroize", ] [[package]] @@ -1006,9 +1022,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "proc-macro2" -version = "1.0.36" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa" dependencies = [ "unicode-xid", ] @@ -1038,9 +1054,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" dependencies = [ "proc-macro2", ] @@ -1081,14 +1097,14 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.5", + "getrandom 0.2.6", ] [[package]] name = "rayon" -version = "1.5.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" dependencies = [ "autocfg", "crossbeam-deque", @@ -1098,14 +1114,13 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" dependencies = [ "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "lazy_static", "num_cpus", ] @@ -1130,6 +1145,17 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +[[package]] +name = "rfc6979" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1147,9 +1173,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" [[package]] name = "same-file" @@ -1190,26 +1216,39 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + [[package]] name = "semver" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d" +checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" [[package]] name = "serde" -version = "1.0.136" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" dependencies = [ "serde_derive", ] [[package]] name = "serde-json-wasm" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "042ac496d97e5885149d34139bad1d617192770d7eb8f1866da2317ff4501853" +checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" dependencies = [ "serde", ] @@ -1226,9 +1265,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.136" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" dependencies = [ "proc-macro2", "quote", @@ -1248,11 +1287,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" +checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" dependencies = [ - "itoa 1.0.1", + "itoa 1.0.2", "ryu", "serde", ] @@ -1272,9 +1311,9 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" dependencies = [ "digest", "rand_core 0.6.3", @@ -1282,10 +1321,11 @@ dependencies = [ [[package]] name = "spki" -version = "0.4.1" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" dependencies = [ + "base64ct", "der", ] @@ -1303,9 +1343,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.86" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +checksum = "a07e33e919ebcd69113d5be0e4d70c5707004ff45188910106854f38b960df4a" dependencies = [ "proc-macro2", "quote", @@ -1323,18 +1363,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", @@ -1377,9 +1417,9 @@ checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" [[package]] name = "version_check" @@ -1412,9 +1452,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" +checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1422,9 +1462,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" +checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" dependencies = [ "bumpalo", "lazy_static", @@ -1437,9 +1477,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" +checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1447,9 +1487,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" +checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" dependencies = [ "proc-macro2", "quote", @@ -1460,15 +1500,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" +checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" [[package]] name = "web-sys" -version = "0.3.56" +version = "0.3.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" +checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" dependencies = [ "js-sys", "wasm-bindgen", @@ -1507,6 +1547,6 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "zeroize" -version = "1.4.3" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" +checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" diff --git a/packages/multi-test/src/executor.rs b/packages/multi-test/src/executor.rs index b6eb341e1..75be02d60 100644 --- a/packages/multi-test/src/executor.rs +++ b/packages/multi-test/src/executor.rs @@ -1,8 +1,7 @@ use std::fmt; use cosmwasm_std::{ - to_binary, Addr, Attribute, BankMsg, Binary, Coin, CosmosMsg, Event, SubMsgExecutionResponse, - WasmMsg, + to_binary, Addr, Attribute, BankMsg, Binary, Coin, CosmosMsg, Event, SubMsgResponse, WasmMsg, }; use cw_utils::{parse_execute_response_data, parse_instantiate_response_data}; use schemars::JsonSchema; @@ -52,8 +51,8 @@ impl AppResponse { /// They have the same shape, SubMsgExecutionResponse is what is returned in reply. /// This is just to make some test cases easier. -impl From for AppResponse { - fn from(reply: SubMsgExecutionResponse) -> Self { +impl From for AppResponse { + fn from(reply: SubMsgResponse) -> Self { AppResponse { data: reply.data, events: reply.events, diff --git a/packages/multi-test/src/test_helpers/contracts/echo.rs b/packages/multi-test/src/test_helpers/contracts/echo.rs index c1d51b3a5..fb87602a6 100644 --- a/packages/multi-test/src/test_helpers/contracts/echo.rs +++ b/packages/multi-test/src/test_helpers/contracts/echo.rs @@ -5,7 +5,7 @@ use cosmwasm_std::{ to_binary, Attribute, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Reply, Response, - StdError, SubMsg, SubMsgExecutionResponse, SubMsgResult, + StdError, SubMsg, SubMsgResponse, SubMsgResult, }; use serde::{de::DeserializeOwned, Deserialize, Serialize}; @@ -97,24 +97,22 @@ where let res = Response::new(); if let Reply { id, - result: - SubMsgResult::Ok(SubMsgExecutionResponse { - data: Some(data), .. - }), + result: SubMsgResult::Ok(SubMsgResponse { + data: Some(data), .. + }), } = msg { // We parse out the WasmMsg::Execute wrapper... // TODO: Handle all of Execute, Instantiate, and BankMsg replies differently. - let parsed_data; - if id < EXECUTE_REPLY_BASE_ID { - parsed_data = parse_instantiate_response_data(data.as_slice()) + let parsed_data = if id < EXECUTE_REPLY_BASE_ID { + parse_instantiate_response_data(data.as_slice()) .map_err(|e| StdError::generic_err(e.to_string()))? - .data; + .data } else { - parsed_data = parse_execute_response_data(data.as_slice()) + parse_execute_response_data(data.as_slice()) .map_err(|e| StdError::generic_err(e.to_string()))? - .data; - } + .data + }; if let Some(data) = parsed_data { Ok(res.set_data(data)) diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index 8182bc3c4..fc04787fe 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -5,7 +5,7 @@ use std::ops::Deref; use cosmwasm_std::{ to_binary, Addr, Api, Attribute, BankMsg, Binary, BlockInfo, Coin, ContractInfo, ContractInfoResponse, CustomQuery, Deps, DepsMut, Env, Event, MessageInfo, Order, Querier, - QuerierWrapper, Reply, ReplyOn, Response, StdResult, Storage, SubMsg, SubMsgExecutionResponse, + QuerierWrapper, Reply, ReplyOn, Response, StdResult, Storage, SubMsg, SubMsgResponse, SubMsgResult, TransactionInfo, WasmMsg, WasmQuery, }; use cosmwasm_storage::{prefixed, prefixed_read, PrefixedStorage, ReadonlyPrefixedStorage}; @@ -436,7 +436,7 @@ where if matches!(reply_on, ReplyOn::Always | ReplyOn::Success) { let reply = Reply { id, - result: SubMsgResult::Ok(SubMsgExecutionResponse { + result: SubMsgResult::Ok(SubMsgResponse { events: r.events.clone(), data: r.data, }), diff --git a/packages/storage-plus/src/prefix.rs b/packages/storage-plus/src/prefix.rs index 2ee04233a..260baf0e7 100644 --- a/packages/storage-plus/src/prefix.rs +++ b/packages/storage-plus/src/prefix.rs @@ -185,8 +185,7 @@ where max.map(|b| b.to_raw_bound()), order, ) - .map(move |kv| (de_fn)(store, &pk_name, kv).map(|(k, _)| Ok(k))) - .flatten(); + .flat_map(move |kv| (de_fn)(store, &pk_name, kv).map(|(k, _)| Ok(k))); Box::new(mapped) } } diff --git a/packages/utils/src/parse_reply.rs b/packages/utils/src/parse_reply.rs index 3b61f7474..468053de2 100644 --- a/packages/utils/src/parse_reply.rs +++ b/packages/utils/src/parse_reply.rs @@ -168,7 +168,7 @@ pub enum ParseReplyError { mod test { use super::*; use crate::parse_reply::ParseReplyError::{BrokenUtf8, ParseFailure}; - use cosmwasm_std::{SubMsgExecutionResponse, SubMsgResult}; + use cosmwasm_std::{SubMsgResponse, SubMsgResult}; use prost::Message; use std::str::from_utf8; @@ -466,7 +466,7 @@ mod test { // Build reply message let msg = Reply { id: 1, - result: SubMsgResult::Ok(SubMsgExecutionResponse { + result: SubMsgResult::Ok(SubMsgResponse { events: vec![], data: Some(encoded_instantiate_reply.into()), }), @@ -514,7 +514,7 @@ mod test { // Build reply message let msg = Reply { id: 1, - result: SubMsgResult::Ok(SubMsgExecutionResponse { + result: SubMsgResult::Ok(SubMsgResponse { events: vec![], data: Some(encoded_execute_reply.into()), }), From 9221b83b5eb22389edf946938e2d9a44b6561231 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 1 Jun 2022 19:18:32 +0200 Subject: [PATCH 326/352] Update packages to cw 1.0.0 --- packages/controllers/Cargo.toml | 2 +- packages/cw1/Cargo.toml | 4 ++-- packages/cw1155/Cargo.toml | 4 ++-- packages/cw2/Cargo.toml | 2 +- packages/cw20/Cargo.toml | 4 ++-- packages/cw3/Cargo.toml | 4 ++-- packages/cw4/Cargo.toml | 4 ++-- packages/multi-test/Cargo.toml | 4 ++-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index ed8607745..e02f1bba8 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -12,7 +12,7 @@ documentation = "https://docs.cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } cw-utils = { path = "../utils", version = "0.13.2" } cw-storage-plus = { path = "../storage-plus", version = "0.13.2" } schemars = "0.8.1" diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index f3584ce5b..d226895b2 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -10,9 +10,9 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 2ce6796aa..65cc9b28b 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 5b0ea1997..77c0c9a20 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0-beta8", default-features = false } +cosmwasm-std = { version = "1.0.0", default-features = false } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index 353ab8d9b..58031bfca 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index 6a9d45b41..40d39266f 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index 9d9c972bb..edb857543 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -11,9 +11,9 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cw-storage-plus = { path = "../storage-plus", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index 82505a7ba..d52788b8b 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -20,8 +20,8 @@ backtrace = ["anyhow/backtrace"] [dependencies] cw-utils = { path = "../../packages/utils", version = "0.13.2" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2"} -cosmwasm-std = { version = "1.0.0-beta8", features = ["staking"] } -cosmwasm-storage = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0", features = ["staking"] } +cosmwasm-storage = { version = "1.0.0" } itertools = "0.10.1" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 6656060d1..77dbcde21 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -18,7 +18,7 @@ iterator = ["cosmwasm-std/iterator"] bench = false [dependencies] -cosmwasm-std = { version = "1.0.0-beta8", default-features = false } +cosmwasm-std = { version = "1.0.0", default-features = false } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index 26e25d475..496bdfa71 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -12,7 +12,7 @@ documentation = "https://docs.cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } From 1659f50c38ab22e34712e275c7c985c4b3424af5 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 1 Jun 2022 19:24:24 +0200 Subject: [PATCH 327/352] Update contracts to cw 1.0.0 --- contracts/cw1-subkeys/Cargo.toml | 4 ++-- contracts/cw1-whitelist-ng/Cargo.toml | 4 ++-- contracts/cw1-whitelist/Cargo.toml | 4 ++-- contracts/cw1155-base/Cargo.toml | 4 ++-- contracts/cw20-base/Cargo.toml | 4 ++-- contracts/cw20-ics20/Cargo.toml | 4 ++-- contracts/cw3-fixed-multisig/Cargo.toml | 4 ++-- contracts/cw3-flex-multisig/Cargo.toml | 4 ++-- contracts/cw4-group/Cargo.toml | 4 ++-- contracts/cw4-stake/Cargo.toml | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 1e10ab7ea..7a602761c 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -23,7 +23,7 @@ cw-utils = { path = "../../packages/utils", version = "0.13.2" } cw1 = { path = "../../packages/cw1", version = "0.13.2" } cw2 = { path = "../../packages/cw2", version = "0.13.2" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.2", features = ["library"] } -cosmwasm-std = { version = "1.0.0-beta8", features = ["staking"] } +cosmwasm-std = { version = "1.0.0", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = "1.0.23" semver = "1" [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.2", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index 55eee448a..70c71b715 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -25,7 +25,7 @@ multitest = ["cw-multi-test", "anyhow"] cw-utils = { path = "../../packages/utils", version = "0.13.2" } cw1 = { path = "../../packages/cw1", version = "0.13.2" } cw2 = { path = "../../packages/cw2", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8", features = ["staking"] } +cosmwasm-std = { version = "1.0.0", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -36,6 +36,6 @@ anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index f9b549856..52330ed9a 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -22,7 +22,7 @@ test-utils = [] cw-utils = { path = "../../packages/utils", version = "0.13.2" } cw1 = { path = "../../packages/cw1", version = "0.13.2" } cw2 = { path = "../../packages/cw2", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8", features = ["staking"] } +cosmwasm-std = { version = "1.0.0", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,6 +31,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] anyhow = "1" assert_matches = "1" -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index b003fad9c..65668aad7 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -22,10 +22,10 @@ cw-utils = { path = "../../packages/utils", version = "0.13.2" } cw2 = { path = "../../packages/cw2", version = "0.13.2" } cw1155 = { path = "../../packages/cw1155", version = "0.13.2" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index b82698eb4..a67e07a57 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -22,10 +22,10 @@ cw-utils = { path = "../../packages/utils", version = "0.13.2" } cw2 = { path = "../../packages/cw2", version = "0.13.2" } cw20 = { path = "../../packages/cw20", version = "0.13.2" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 74c101605..4681ead22 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -21,7 +21,7 @@ library = [] cw-utils = { path = "../../packages/utils", version = "0.13.2" } cw2 = { path = "../../packages/cw2", version = "0.13.2" } cw20 = { path = "../../packages/cw20", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8", features = ["stargate"] } +cosmwasm-std = { version = "1.0.0", features = ["stargate"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } cw-controllers = { path = "../../packages/controllers", version = "0.13.2" } schemars = "0.8.1" @@ -30,4 +30,4 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index fab4ea012..a11fc3a72 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -22,13 +22,13 @@ cw-utils = { path = "../../packages/utils", version = "0.13.2" } cw2 = { path = "../../packages/cw2", version = "0.13.2" } cw3 = { path = "../../packages/cw3", version = "0.13.2" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } cw20 = { path = "../../packages/cw20", version = "0.13.2" } cw20-base = { path = "../cw20-base", version = "0.13.2", features = ["library"] } cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 16039cb72..8207a6486 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -24,12 +24,12 @@ cw3 = { path = "../../packages/cw3", version = "0.13.2" } cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.13.2", features = ["library"] } cw4 = { path = "../../packages/cw4", version = "0.13.2" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } cw4-group = { path = "../cw4-group", version = "0.13.2" } cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index a1b7e07ef..d1394af6b 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -31,10 +31,10 @@ cw2 = { path = "../../packages/cw2", version = "0.13.2" } cw4 = { path = "../../packages/cw4", version = "0.13.2" } cw-controllers = { path = "../../packages/controllers", version = "0.13.2" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index c0dfb9286..c2e95e166 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -32,10 +32,10 @@ cw4 = { path = "../../packages/cw4", version = "0.13.2" } cw20 = { path = "../../packages/cw20", version = "0.13.2" } cw-controllers = { path = "../../packages/controllers", version = "0.13.2" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } -cosmwasm-std = { version = "1.0.0-beta8" } +cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } [dev-dependencies] -cosmwasm-schema = { version = "1.0.0-beta8" } +cosmwasm-schema = { version = "1.0.0" } From f42a661fefbeb796f40aa30f1c315959b7cdccea Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 1 Jun 2022 19:24:45 +0200 Subject: [PATCH 328/352] Update optimizer in CI to latest version --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f62325e34..48b96f542 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -741,7 +741,7 @@ jobs: - run: name: Build development contracts command: | - docker run --volumes-from with_code cosmwasm/workspace-optimizer:0.12.4 + docker run --volumes-from with_code cosmwasm/workspace-optimizer:0.12.6 docker cp with_code:/code/artifacts ./artifacts - run: name: Show data From 58dbf80cc426d1c16e9aea436d5e5daf3a709d1b Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 1 Jun 2022 20:40:34 +0200 Subject: [PATCH 329/352] Allow untracked files when set version --- scripts/set_version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/set_version.sh b/scripts/set_version.sh index 019b8125d..dec6b8483 100755 --- a/scripts/set_version.sh +++ b/scripts/set_version.sh @@ -21,7 +21,7 @@ if [[ "$(realpath "$SCRIPT_DIR/..")" != "$(pwd)" ]]; then fi # Ensure repo is not dirty -CHANGES_IN_REPO=$(git status --porcelain) +CHANGES_IN_REPO=$(git status --porcelain --untracked-files=no) if [[ -n "$CHANGES_IN_REPO" ]]; then echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" git status && git --no-pager diff From fccf2aac1f5efd93231b99c5e1186bbe51bbf38d Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 1 Jun 2022 20:41:10 +0200 Subject: [PATCH 330/352] Set version: 0.13.3 --- Cargo.lock | 40 ++++++++++++------------- contracts/cw1-subkeys/Cargo.toml | 14 ++++----- contracts/cw1-whitelist-ng/Cargo.toml | 14 ++++----- contracts/cw1-whitelist/Cargo.toml | 12 ++++---- contracts/cw1155-base/Cargo.toml | 10 +++---- contracts/cw20-base/Cargo.toml | 10 +++---- contracts/cw20-ics20/Cargo.toml | 12 ++++---- contracts/cw3-fixed-multisig/Cargo.toml | 16 +++++----- contracts/cw3-flex-multisig/Cargo.toml | 18 +++++------ contracts/cw4-group/Cargo.toml | 12 ++++---- contracts/cw4-stake/Cargo.toml | 14 ++++----- packages/controllers/Cargo.toml | 6 ++-- packages/cw1/Cargo.toml | 2 +- packages/cw1155/Cargo.toml | 4 +-- packages/cw2/Cargo.toml | 4 +-- packages/cw20/Cargo.toml | 4 +-- packages/cw3/Cargo.toml | 4 +-- packages/cw4/Cargo.toml | 4 +-- packages/multi-test/Cargo.toml | 6 ++-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 4 +-- 21 files changed, 106 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df3eb49ec..877c40ec4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -379,7 +379,7 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -391,7 +391,7 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.13.2" +version = "0.13.3" dependencies = [ "anyhow", "cosmwasm-std", @@ -408,7 +408,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-std", "criterion", @@ -419,7 +419,7 @@ dependencies = [ [[package]] name = "cw-utils" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -431,7 +431,7 @@ dependencies = [ [[package]] name = "cw1" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -441,7 +441,7 @@ dependencies = [ [[package]] name = "cw1-subkeys" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -458,7 +458,7 @@ dependencies = [ [[package]] name = "cw1-whitelist" -version = "0.13.2" +version = "0.13.3" dependencies = [ "anyhow", "assert_matches", @@ -477,7 +477,7 @@ dependencies = [ [[package]] name = "cw1-whitelist-ng" -version = "0.13.2" +version = "0.13.3" dependencies = [ "anyhow", "assert_matches", @@ -496,7 +496,7 @@ dependencies = [ [[package]] name = "cw1155" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -507,7 +507,7 @@ dependencies = [ [[package]] name = "cw1155-base" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -522,7 +522,7 @@ dependencies = [ [[package]] name = "cw2" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -532,7 +532,7 @@ dependencies = [ [[package]] name = "cw20" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -543,7 +543,7 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -558,7 +558,7 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -575,7 +575,7 @@ dependencies = [ [[package]] name = "cw3" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -586,7 +586,7 @@ dependencies = [ [[package]] name = "cw3-fixed-multisig" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -604,7 +604,7 @@ dependencies = [ [[package]] name = "cw3-flex-multisig" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -623,7 +623,7 @@ dependencies = [ [[package]] name = "cw4" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -634,7 +634,7 @@ dependencies = [ [[package]] name = "cw4-group" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -650,7 +650,7 @@ dependencies = [ [[package]] name = "cw4-stake" -version = "0.13.2" +version = "0.13.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 7a602761c..2b2fa7eba 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-subkeys" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Implement subkeys for authorizing native tokens as a cw1 proxy contract" @@ -19,12 +19,12 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw1 = { path = "../../packages/cw1", version = "0.13.2" } -cw2 = { path = "../../packages/cw2", version = "0.13.2" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.2", features = ["library"] } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw1 = { path = "../../packages/cw1", version = "0.13.3" } +cw2 = { path = "../../packages/cw2", version = "0.13.3" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.3", features = ["library"] } cosmwasm-std = { version = "1.0.0", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.23" @@ -32,4 +32,4 @@ semver = "1" [dev-dependencies] cosmwasm-schema = { version = "1.0.0" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.2", features = ["library", "test-utils"] } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.3", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index 70c71b715..7b3deabcc 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist-ng" -version = "0.13.2" +version = "0.13.3" authors = ["Bartłomiej Kuras "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -22,20 +22,20 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw1 = { path = "../../packages/cw1", version = "0.13.2" } -cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw1 = { path = "../../packages/cw1", version = "0.13.3" } +cw2 = { path = "../../packages/cw2", version = "0.13.3" } cosmwasm-std = { version = "1.0.0", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2", optional = true } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.3", optional = true } anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.3" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index 52330ed9a..d74ec2518 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw1 = { path = "../../packages/cw1", version = "0.13.2" } -cw2 = { path = "../../packages/cw2", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw1 = { path = "../../packages/cw1", version = "0.13.3" } +cw2 = { path = "../../packages/cw2", version = "0.13.3" } cosmwasm-std = { version = "1.0.0", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -32,5 +32,5 @@ thiserror = { version = "1.0.23" } anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.3" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 65668aad7..469c6aadb 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155-base" -version = "0.13.2" +version = "0.13.3" authors = ["Huang Yi "] edition = "2018" description = "Basic implementation of a CosmWasm-1155 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw2 = { path = "../../packages/cw2", version = "0.13.2" } -cw1155 = { path = "../../packages/cw1155", version = "0.13.2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw2 = { path = "../../packages/cw2", version = "0.13.3" } +cw1155 = { path = "../../packages/cw1155", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index a67e07a57..e3407710f 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-base" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation of a CosmWasm-20 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw2 = { path = "../../packages/cw2", version = "0.13.2" } -cw20 = { path = "../../packages/cw20", version = "0.13.2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw2 = { path = "../../packages/cw2", version = "0.13.3" } +cw20 = { path = "../../packages/cw20", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index 4681ead22..c0eca3987 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw2 = { path = "../../packages/cw2", version = "0.13.2" } -cw20 = { path = "../../packages/cw20", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw2 = { path = "../../packages/cw2", version = "0.13.3" } +cw20 = { path = "../../packages/cw20", version = "0.13.3" } cosmwasm-std = { version = "1.0.0", features = ["stargate"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.3" } schemars = "0.8.1" semver = "1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index a11fc3a72..ce512afaa 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-fixed-multisig" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with an fixed group multisig" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw2 = { path = "../../packages/cw2", version = "0.13.2" } -cw3 = { path = "../../packages/cw3", version = "0.13.2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw2 = { path = "../../packages/cw2", version = "0.13.3" } +cw3 = { path = "../../packages/cw3", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -29,6 +29,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0" } -cw20 = { path = "../../packages/cw20", version = "0.13.2" } -cw20-base = { path = "../cw20-base", version = "0.13.2", features = ["library"] } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } +cw20 = { path = "../../packages/cw20", version = "0.13.3" } +cw20-base = { path = "../cw20-base", version = "0.13.3", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.3" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 8207a6486..3a1fdc66d 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-flex-multisig" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with multiple voting patterns and dynamic groups" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw2 = { path = "../../packages/cw2", version = "0.13.2" } -cw3 = { path = "../../packages/cw3", version = "0.13.2" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.13.2", features = ["library"] } -cw4 = { path = "../../packages/cw4", version = "0.13.2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw2 = { path = "../../packages/cw2", version = "0.13.3" } +cw3 = { path = "../../packages/cw3", version = "0.13.3" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.13.3", features = ["library"] } +cw4 = { path = "../../packages/cw4", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0" } -cw4-group = { path = "../cw4-group", version = "0.13.2" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.2" } +cw4-group = { path = "../cw4-group", version = "0.13.3" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.3" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index d1394af6b..e5f3912fc 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-group" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Simple cw4 implementation of group membership controlled by admin " @@ -26,11 +26,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw2 = { path = "../../packages/cw2", version = "0.13.2" } -cw4 = { path = "../../packages/cw4", version = "0.13.2" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw2 = { path = "../../packages/cw2", version = "0.13.3" } +cw4 = { path = "../../packages/cw4", version = "0.13.3" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index c2e95e166..aea5ea04d 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-stake" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "CW4 implementation of group based on staked tokens" @@ -26,12 +26,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw2 = { path = "../../packages/cw2", version = "0.13.2" } -cw4 = { path = "../../packages/cw4", version = "0.13.2" } -cw20 = { path = "../../packages/cw20", version = "0.13.2" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw2 = { path = "../../packages/cw2", version = "0.13.3" } +cw4 = { path = "../../packages/cw4", version = "0.13.3" } +cw20 = { path = "../../packages/cw20", version = "0.13.3" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index e02f1bba8..c6a9a4919 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-controllers" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Common controllers we can reuse in many contracts" @@ -13,8 +13,8 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0" } -cw-utils = { path = "../utils", version = "0.13.2" } -cw-storage-plus = { path = "../storage-plus", version = "0.13.2" } +cw-utils = { path = "../utils", version = "0.13.3" } +cw-storage-plus = { path = "../storage-plus", version = "0.13.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index d226895b2..9052d22d4 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-1 interface" diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 65cc9b28b..4f0bebe75 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155" -version = "0.13.2" +version = "0.13.3" authors = ["Huang Yi "] edition = "2018" description = "Definition and types for the CosmWasm-1155 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 77c0c9a20..4f5be5cd9 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw2" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-2 interface" @@ -11,6 +11,6 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0", default-features = false } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index 58031bfca..93f9f9c7a 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-20 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index 40d39266f..689817e1e 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-3 Interface: On-Chain MultiSig/Voting contracts" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } +cw-utils = { path = "../../packages/utils", version = "0.13.3" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index edb857543..2dcc39772 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-4 Interface: Groups Members" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-storage-plus = { path = "../storage-plus", version = "0.13.2" } +cw-storage-plus = { path = "../storage-plus", version = "0.13.3" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index d52788b8b..89fe38550 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-multi-test" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Test helpers for multi-contract interactions" @@ -18,8 +18,8 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.2" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2"} +cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3"} cosmwasm-std = { version = "1.0.0", features = ["staking"] } cosmwasm-storage = { version = "1.0.0" } itertools = "0.10.1" diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 77dbcde21..eb3fe602d 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-storage-plus" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Enhanced storage engines" diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index 496bdfa71..1931df61e 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-utils" -version = "0.13.2" +version = "0.13.3" authors = ["Ethan Frey "] edition = "2018" description = "Common helpers for other cw specs" @@ -18,5 +18,5 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } [dev-dependencies] -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.2" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } prost = "0.9" From aa285415126943e11dbfc1e8d8a91c3e51eb0b1e Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 1 Jun 2022 20:41:32 +0200 Subject: [PATCH 331/352] Update CHANGELOG --- CHANGELOG.md | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2d514dad..43ac66798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,47 @@ ## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.1...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.3...HEAD) + +## [v0.13.3](https://github.com/CosmWasm/cw-plus/tree/v0.13.3) (2022-06-01) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.2...v0.13.3) + +**Closed issues:** + +- Add code coverage tooling to the CI [\#172](https://github.com/CosmWasm/cw-plus/issues/172) + +**Merged pull requests:** + +- Repo reclippization [\#721](https://github.com/CosmWasm/cw-plus/pull/721) ([hashedone](https://github.com/hashedone)) +- Add code coverage to CI [\#715](https://github.com/CosmWasm/cw-plus/pull/715) ([maurolacy](https://github.com/maurolacy)) +- Update item.rs: typo [\#713](https://github.com/CosmWasm/cw-plus/pull/713) ([rtviii](https://github.com/rtviii)) +- Update link to new shared CosmWasm SECURITY.md [\#701](https://github.com/CosmWasm/cw-plus/pull/701) ([webmaster128](https://github.com/webmaster128)) +- Add existence checking to indexed map [\#700](https://github.com/CosmWasm/cw-plus/pull/700) ([shanev](https://github.com/shanev)) + +**Closed issues:** + +- error: could not compile `ff` when running cargo test on cw20-base contract [\#714](https://github.com/CosmWasm/cw-plus/issues/714) + +## [v0.13.2](https://github.com/CosmWasm/cw-plus/tree/v0.13.2) (2022-04-11) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.1...v0.13.2) + +**Closed issues:** + +- `KeyDeserialize` trait is private making custom keys and generics over keys not possible. [\#691](https://github.com/CosmWasm/cw-plus/issues/691) +- unresolved import cosmwasm\_std::testing [\#681](https://github.com/CosmWasm/cw-plus/issues/681) +- Add non-owned `range_de` [\#463](https://github.com/CosmWasm/cw-plus/issues/463) + +**Merged pull requests:** + +- Upgrade all contracts and packages to cosmwasm-std beta8 [\#699](https://github.com/CosmWasm/cw-plus/pull/699) ([the-frey](https://github.com/the-frey)) +- Remove dead links [\#698](https://github.com/CosmWasm/cw-plus/pull/698) ([Psyf](https://github.com/Psyf)) +- cw20-ics20: fix missing assert [\#697](https://github.com/CosmWasm/cw-plus/pull/697) ([giansalex](https://github.com/giansalex)) +- storage-plus: Implement u128 key [\#694](https://github.com/CosmWasm/cw-plus/pull/694) ([orkunkl](https://github.com/orkunkl)) +- Make `KeyDeserialize` trait public [\#692](https://github.com/CosmWasm/cw-plus/pull/692) ([maurolacy](https://github.com/maurolacy)) +- Typo in QueryMsg::DownloadLogo description [\#690](https://github.com/CosmWasm/cw-plus/pull/690) ([nnoln](https://github.com/nnoln)) +- Fix publish.sh help / args [\#689](https://github.com/CosmWasm/cw-plus/pull/689) ([maurolacy](https://github.com/maurolacy)) ## [v0.13.1](https://github.com/CosmWasm/cw-plus/tree/v0.13.1) (2022-03-25) From 4ca2f33a93f6ca4139bbaf63743ee02318506a53 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Wed, 1 Jun 2022 21:08:37 +0200 Subject: [PATCH 332/352] Update migrate version --- contracts/cw20-ics20/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index bcb71733c..ce48726af 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -204,7 +204,7 @@ pub fn execute_allow( const MIGRATE_MIN_VERSION: &str = "0.11.1"; const MIGRATE_VERSION_2: &str = "0.12.0-alpha1"; -const MIGRATE_VERSION_3: &str = "0.13.2"; +const MIGRATE_VERSION_3: &str = "0.13.3"; #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(mut deps: DepsMut, env: Env, msg: MigrateMsg) -> Result { From 9dcd0c2d29f2022e4b9ea1b7db68b0e8e2a98162 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 2 Jun 2022 12:09:55 +0200 Subject: [PATCH 333/352] Add dump_wasm_raw to App --- packages/multi-test/src/app.rs | 8 +- packages/multi-test/src/wasm.rs | 145 +++++++++++++++++--------------- 2 files changed, 82 insertions(+), 71 deletions(-) diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index 24f9be992..57db2fba8 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -5,7 +5,8 @@ use anyhow::Result as AnyResult; use cosmwasm_std::testing::{mock_env, MockApi, MockStorage}; use cosmwasm_std::{ from_slice, to_binary, Addr, Api, Binary, BlockInfo, ContractResult, CustomQuery, Empty, - Querier, QuerierResult, QuerierWrapper, QueryRequest, Storage, SystemError, SystemResult, + Querier, QuerierResult, QuerierWrapper, QueryRequest, Record, Storage, SystemError, + SystemResult, }; use schemars::JsonSchema; use serde::de::DeserializeOwned; @@ -565,6 +566,11 @@ where pub fn contract_data(&self, address: &Addr) -> AnyResult { self.read_module(|router, _, storage| router.wasm.load_contract(storage, address)) } + + /// This gets a raw state dump of all key-values held by a given contract + pub fn dump_wasm_raw(&self, address: &Addr) -> Vec { + self.read_module(|router, _, storage| router.wasm.dump_wasm_raw(storage, address)) + } } impl diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index fc04787fe..a5c72126c 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -5,7 +5,7 @@ use std::ops::Deref; use cosmwasm_std::{ to_binary, Addr, Api, Attribute, BankMsg, Binary, BlockInfo, Coin, ContractInfo, ContractInfoResponse, CustomQuery, Deps, DepsMut, Env, Event, MessageInfo, Order, Querier, - QuerierWrapper, Reply, ReplyOn, Response, StdResult, Storage, SubMsg, SubMsgResponse, + QuerierWrapper, Record, Reply, ReplyOn, Response, StdResult, Storage, SubMsg, SubMsgResponse, SubMsgResult, TransactionInfo, WasmMsg, WasmQuery, }; use cosmwasm_storage::{prefixed, prefixed_read, PrefixedStorage, ReadonlyPrefixedStorage}; @@ -191,6 +191,80 @@ impl WasmKeeper { .load(&prefixed_read(storage, NAMESPACE_WASM), address) .map_err(Into::into) } + + pub fn dump_wasm_raw(&self, storage: &dyn Storage, address: &Addr) -> Vec { + let storage = self.contract_storage_readonly(storage, address); + storage.range(None, None, Order::Ascending).collect() + } + + fn contract_namespace(&self, contract: &Addr) -> Vec { + let mut name = b"contract_data/".to_vec(); + name.extend_from_slice(contract.as_bytes()); + name + } + + fn contract_storage<'a>( + &self, + storage: &'a mut dyn Storage, + address: &Addr, + ) -> Box { + // We double-namespace this, once from global storage -> wasm_storage + // then from wasm_storage -> the contracts subspace + let namespace = self.contract_namespace(address); + let storage = PrefixedStorage::multilevel(storage, &[NAMESPACE_WASM, &namespace]); + Box::new(storage) + } + + // fails RUNTIME if you try to write. please don't + fn contract_storage_readonly<'a>( + &self, + storage: &'a dyn Storage, + address: &Addr, + ) -> Box { + // We double-namespace this, once from global storage -> wasm_storage + // then from wasm_storage -> the contracts subspace + let namespace = self.contract_namespace(address); + let storage = ReadonlyPrefixedStorage::multilevel(storage, &[NAMESPACE_WASM, &namespace]); + Box::new(storage) + } + + fn verify_attributes(attributes: &[Attribute]) -> AnyResult<()> { + for attr in attributes { + let key = attr.key.trim(); + let val = attr.value.trim(); + + if key.is_empty() { + bail!(Error::empty_attribute_key(val)); + } + + if val.is_empty() { + bail!(Error::empty_attribute_value(key)); + } + + if key.starts_with('_') { + bail!(Error::reserved_attribute_key(key)); + } + } + + Ok(()) + } + + fn verify_response(response: Response) -> AnyResult> + where + T: Clone + fmt::Debug + PartialEq + JsonSchema, + { + Self::verify_attributes(&response.attributes)?; + + for event in &response.events { + Self::verify_attributes(&event.attributes)?; + let ty = event.ty.trim(); + if ty.len() < 2 { + bail!(Error::event_type_too_short(ty)); + } + } + + Ok(response) + } } impl WasmKeeper @@ -782,75 +856,6 @@ where // it is lowercase to be compatible with the MockApi implementation of cosmwasm-std >= 1.0.0-beta8 Addr::unchecked(format!("contract{}", count)) } - - fn contract_namespace(&self, contract: &Addr) -> Vec { - let mut name = b"contract_data/".to_vec(); - name.extend_from_slice(contract.as_bytes()); - name - } - - fn contract_storage<'a>( - &self, - storage: &'a mut dyn Storage, - address: &Addr, - ) -> Box { - // We double-namespace this, once from global storage -> wasm_storage - // then from wasm_storage -> the contracts subspace - let namespace = self.contract_namespace(address); - let storage = PrefixedStorage::multilevel(storage, &[NAMESPACE_WASM, &namespace]); - Box::new(storage) - } - - // fails RUNTIME if you try to write. please don't - fn contract_storage_readonly<'a>( - &self, - storage: &'a dyn Storage, - address: &Addr, - ) -> Box { - // We double-namespace this, once from global storage -> wasm_storage - // then from wasm_storage -> the contracts subspace - let namespace = self.contract_namespace(address); - let storage = ReadonlyPrefixedStorage::multilevel(storage, &[NAMESPACE_WASM, &namespace]); - Box::new(storage) - } - - fn verify_attributes(attributes: &[Attribute]) -> AnyResult<()> { - for attr in attributes { - let key = attr.key.trim(); - let val = attr.value.trim(); - - if key.is_empty() { - bail!(Error::empty_attribute_key(val)); - } - - if val.is_empty() { - bail!(Error::empty_attribute_value(key)); - } - - if key.starts_with('_') { - bail!(Error::reserved_attribute_key(key)); - } - } - - Ok(()) - } - - fn verify_response(response: Response) -> AnyResult> - where - T: Clone + fmt::Debug + PartialEq + JsonSchema, - { - Self::verify_attributes(&response.attributes)?; - - for event in &response.events { - Self::verify_attributes(&event.attributes)?; - let ty = event.ty.trim(); - if ty.len() < 2 { - bail!(Error::event_type_too_short(ty)); - } - } - - Ok(response) - } } // TODO: replace with code in utils From 7f86a66fb70bd6f0e8f4051c33cf7c9602666558 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 2 Jun 2022 12:20:14 +0200 Subject: [PATCH 334/352] Add test for dump_wasm_raw --- packages/multi-test/src/wasm.rs | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index a5c72126c..42c350ffe 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -1055,6 +1055,57 @@ mod test { assert_eq!(expected, from_slice(&info).unwrap()); } + #[test] + fn can_dump_raw_wasm_state() { + let api = MockApi::default(); + let mut keeper = WasmKeeper::::new(); + let block = mock_env().block; + let code_id = keeper.store_code(payout::contract()); + + let mut wasm_storage = MockStorage::new(); + + let contract_addr = keeper + .register_contract( + &mut wasm_storage, + code_id, + Addr::unchecked("foobar"), + Addr::unchecked("admin"), + "label".to_owned(), + 1000, + ) + .unwrap(); + + // make a contract with state + let payout = coin(1500, "mlg"); + let msg = payout::InstantiateMessage { + payout: payout.clone(), + }; + keeper + .call_instantiate( + contract_addr.clone(), + &api, + &mut wasm_storage, + &mock_router(), + &block, + mock_info("foobar", &[]), + to_vec(&msg).unwrap(), + ) + .unwrap(); + + // dump state + let state = keeper.dump_wasm_raw(&wasm_storage, &contract_addr); + assert_eq!(state.len(), 2); + // check contents + let (k, v) = &state[0]; + assert_eq!(k.as_slice(), b"count"); + let count: u32 = from_slice(v).unwrap(); + assert_eq!(count, 1); + let (k, v) = &state[1]; + assert_eq!(k.as_slice(), b"payout"); + let stored_pay: payout::InstantiateMessage = from_slice(v).unwrap(); + assert_eq!(stored_pay.payout, payout); + } + #[test] fn contract_send_coins() { let api = MockApi::default(); From fc089febdab836400982eb096a545997a2bf4aed Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 2 Jun 2022 12:41:36 +0200 Subject: [PATCH 335/352] Set version: 0.13.4 --- Cargo.lock | 40 ++++++++++++------------- contracts/cw1-subkeys/Cargo.toml | 14 ++++----- contracts/cw1-whitelist-ng/Cargo.toml | 14 ++++----- contracts/cw1-whitelist/Cargo.toml | 12 ++++---- contracts/cw1155-base/Cargo.toml | 10 +++---- contracts/cw20-base/Cargo.toml | 10 +++---- contracts/cw20-ics20/Cargo.toml | 12 ++++---- contracts/cw3-fixed-multisig/Cargo.toml | 16 +++++----- contracts/cw3-flex-multisig/Cargo.toml | 18 +++++------ contracts/cw4-group/Cargo.toml | 12 ++++---- contracts/cw4-stake/Cargo.toml | 14 ++++----- packages/controllers/Cargo.toml | 6 ++-- packages/cw1/Cargo.toml | 2 +- packages/cw1155/Cargo.toml | 4 +-- packages/cw2/Cargo.toml | 4 +-- packages/cw20/Cargo.toml | 4 +-- packages/cw3/Cargo.toml | 4 +-- packages/cw4/Cargo.toml | 4 +-- packages/multi-test/Cargo.toml | 6 ++-- packages/storage-plus/Cargo.toml | 2 +- packages/utils/Cargo.toml | 4 +-- 21 files changed, 106 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 877c40ec4..b7cb3c849 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -379,7 +379,7 @@ dependencies = [ [[package]] name = "cw-controllers" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -391,7 +391,7 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.13.3" +version = "0.13.4" dependencies = [ "anyhow", "cosmwasm-std", @@ -408,7 +408,7 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-std", "criterion", @@ -419,7 +419,7 @@ dependencies = [ [[package]] name = "cw-utils" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -431,7 +431,7 @@ dependencies = [ [[package]] name = "cw1" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -441,7 +441,7 @@ dependencies = [ [[package]] name = "cw1-subkeys" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -458,7 +458,7 @@ dependencies = [ [[package]] name = "cw1-whitelist" -version = "0.13.3" +version = "0.13.4" dependencies = [ "anyhow", "assert_matches", @@ -477,7 +477,7 @@ dependencies = [ [[package]] name = "cw1-whitelist-ng" -version = "0.13.3" +version = "0.13.4" dependencies = [ "anyhow", "assert_matches", @@ -496,7 +496,7 @@ dependencies = [ [[package]] name = "cw1155" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -507,7 +507,7 @@ dependencies = [ [[package]] name = "cw1155-base" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -522,7 +522,7 @@ dependencies = [ [[package]] name = "cw2" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -532,7 +532,7 @@ dependencies = [ [[package]] name = "cw20" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -543,7 +543,7 @@ dependencies = [ [[package]] name = "cw20-base" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -558,7 +558,7 @@ dependencies = [ [[package]] name = "cw20-ics20" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -575,7 +575,7 @@ dependencies = [ [[package]] name = "cw3" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -586,7 +586,7 @@ dependencies = [ [[package]] name = "cw3-fixed-multisig" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -604,7 +604,7 @@ dependencies = [ [[package]] name = "cw3-flex-multisig" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -623,7 +623,7 @@ dependencies = [ [[package]] name = "cw4" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -634,7 +634,7 @@ dependencies = [ [[package]] name = "cw4-group" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -650,7 +650,7 @@ dependencies = [ [[package]] name = "cw4-stake" -version = "0.13.3" +version = "0.13.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 2b2fa7eba..73172f4f1 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-subkeys" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Implement subkeys for authorizing native tokens as a cw1 proxy contract" @@ -19,12 +19,12 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw1 = { path = "../../packages/cw1", version = "0.13.3" } -cw2 = { path = "../../packages/cw2", version = "0.13.3" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.3", features = ["library"] } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw1 = { path = "../../packages/cw1", version = "0.13.4" } +cw2 = { path = "../../packages/cw2", version = "0.13.4" } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.4", features = ["library"] } cosmwasm-std = { version = "1.0.0", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0.23" @@ -32,4 +32,4 @@ semver = "1" [dev-dependencies] cosmwasm-schema = { version = "1.0.0" } -cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.3", features = ["library", "test-utils"] } +cw1-whitelist = { path = "../cw1-whitelist", version = "0.13.4", features = ["library", "test-utils"] } diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index 7b3deabcc..fc231f04e 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist-ng" -version = "0.13.3" +version = "0.13.4" authors = ["Bartłomiej Kuras "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -22,20 +22,20 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw1 = { path = "../../packages/cw1", version = "0.13.3" } -cw2 = { path = "../../packages/cw2", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw1 = { path = "../../packages/cw1", version = "0.13.4" } +cw2 = { path = "../../packages/cw2", version = "0.13.4" } cosmwasm-std = { version = "1.0.0", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.3", optional = true } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.4", optional = true } anyhow = { version = "1", optional = true } [dev-dependencies] anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.3" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.4" } derivative = "2" diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index d74ec2518..f1666d5fb 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1-whitelist" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Implementation of an proxy contract using a whitelist" @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw1 = { path = "../../packages/cw1", version = "0.13.3" } -cw2 = { path = "../../packages/cw2", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw1 = { path = "../../packages/cw1", version = "0.13.4" } +cw2 = { path = "../../packages/cw2", version = "0.13.4" } cosmwasm-std = { version = "1.0.0", features = ["staking"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } @@ -32,5 +32,5 @@ thiserror = { version = "1.0.23" } anyhow = "1" assert_matches = "1" cosmwasm-schema = { version = "1.0.0" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.3" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.4" } derivative = "2" diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 469c6aadb..f0f0534c1 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155-base" -version = "0.13.3" +version = "0.13.4" authors = ["Huang Yi "] edition = "2018" description = "Basic implementation of a CosmWasm-1155 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw2 = { path = "../../packages/cw2", version = "0.13.3" } -cw1155 = { path = "../../packages/cw1155", version = "0.13.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw2 = { path = "../../packages/cw2", version = "0.13.4" } +cw1155 = { path = "../../packages/cw1155", version = "0.13.4" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index e3407710f..19367cb8b 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-base" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Basic implementation of a CosmWasm-20 compliant token" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw2 = { path = "../../packages/cw2", version = "0.13.3" } -cw20 = { path = "../../packages/cw20", version = "0.13.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw2 = { path = "../../packages/cw2", version = "0.13.4" } +cw20 = { path = "../../packages/cw20", version = "0.13.4" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index c0eca3987..c5d5a59b9 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw2 = { path = "../../packages/cw2", version = "0.13.3" } -cw20 = { path = "../../packages/cw20", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw2 = { path = "../../packages/cw2", version = "0.13.4" } +cw20 = { path = "../../packages/cw20", version = "0.13.4" } cosmwasm-std = { version = "1.0.0", features = ["stargate"] } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.4" } schemars = "0.8.1" semver = "1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index ce512afaa..5b44bee16 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-fixed-multisig" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with an fixed group multisig" @@ -18,10 +18,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw2 = { path = "../../packages/cw2", version = "0.13.3" } -cw3 = { path = "../../packages/cw3", version = "0.13.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw2 = { path = "../../packages/cw2", version = "0.13.4" } +cw3 = { path = "../../packages/cw3", version = "0.13.4" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -29,6 +29,6 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0" } -cw20 = { path = "../../packages/cw20", version = "0.13.3" } -cw20-base = { path = "../cw20-base", version = "0.13.3", features = ["library"] } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.3" } +cw20 = { path = "../../packages/cw20", version = "0.13.4" } +cw20-base = { path = "../cw20-base", version = "0.13.4", features = ["library"] } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.4" } diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 3a1fdc66d..d829ae454 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3-flex-multisig" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Implementing cw3 with multiple voting patterns and dynamic groups" @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw2 = { path = "../../packages/cw2", version = "0.13.3" } -cw3 = { path = "../../packages/cw3", version = "0.13.3" } -cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.13.3", features = ["library"] } -cw4 = { path = "../../packages/cw4", version = "0.13.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw2 = { path = "../../packages/cw2", version = "0.13.4" } +cw3 = { path = "../../packages/cw3", version = "0.13.4" } +cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.13.4", features = ["library"] } +cw4 = { path = "../../packages/cw4", version = "0.13.4" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } @@ -31,5 +31,5 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { version = "1.0.0" } -cw4-group = { path = "../cw4-group", version = "0.13.3" } -cw-multi-test = { path = "../../packages/multi-test", version = "0.13.3" } +cw4-group = { path = "../cw4-group", version = "0.13.4" } +cw-multi-test = { path = "../../packages/multi-test", version = "0.13.4" } diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index e5f3912fc..722150a1a 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-group" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Simple cw4 implementation of group membership controlled by admin " @@ -26,11 +26,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw2 = { path = "../../packages/cw2", version = "0.13.3" } -cw4 = { path = "../../packages/cw4", version = "0.13.3" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw2 = { path = "../../packages/cw2", version = "0.13.4" } +cw4 = { path = "../../packages/cw4", version = "0.13.4" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.4" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index aea5ea04d..d27c1e12e 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4-stake" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "CW4 implementation of group based on staked tokens" @@ -26,12 +26,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw2 = { path = "../../packages/cw2", version = "0.13.3" } -cw4 = { path = "../../packages/cw4", version = "0.13.3" } -cw20 = { path = "../../packages/cw20", version = "0.13.3" } -cw-controllers = { path = "../../packages/controllers", version = "0.13.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw2 = { path = "../../packages/cw2", version = "0.13.4" } +cw4 = { path = "../../packages/cw4", version = "0.13.4" } +cw20 = { path = "../../packages/cw20", version = "0.13.4" } +cw-controllers = { path = "../../packages/controllers", version = "0.13.4" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index c6a9a4919..0b3946cf9 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-controllers" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Common controllers we can reuse in many contracts" @@ -13,8 +13,8 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0" } -cw-utils = { path = "../utils", version = "0.13.3" } -cw-storage-plus = { path = "../storage-plus", version = "0.13.3" } +cw-utils = { path = "../utils", version = "0.13.4" } +cw-storage-plus = { path = "../storage-plus", version = "0.13.4" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index 9052d22d4..e4506bcc9 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-1 interface" diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 4f0bebe75..d49acb9c6 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw1155" -version = "0.13.3" +version = "0.13.4" authors = ["Huang Yi "] edition = "2018" description = "Definition and types for the CosmWasm-1155 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 4f5be5cd9..c240df878 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw2" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-2 interface" @@ -11,6 +11,6 @@ documentation = "https://docs.cosmwasm.com" [dependencies] cosmwasm-std = { version = "1.0.0", default-features = false } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index 93f9f9c7a..8a3181632 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Definition and types for the CosmWasm-20 interface" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index 689817e1e..7e585a17d 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw3" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-3 Interface: On-Chain MultiSig/Voting contracts" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } +cw-utils = { path = "../../packages/utils", version = "0.13.4" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index 2dcc39772..ff6f996fa 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw4" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "CosmWasm-4 Interface: Groups Members" @@ -10,7 +10,7 @@ homepage = "https://cosmwasm.com" documentation = "https://docs.cosmwasm.com" [dependencies] -cw-storage-plus = { path = "../storage-plus", version = "0.13.3" } +cw-storage-plus = { path = "../storage-plus", version = "0.13.4" } cosmwasm-std = { version = "1.0.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index 89fe38550..8a059e042 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-multi-test" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Test helpers for multi-contract interactions" @@ -18,8 +18,8 @@ staking = ["cosmwasm-std/staking"] backtrace = ["anyhow/backtrace"] [dependencies] -cw-utils = { path = "../../packages/utils", version = "0.13.3" } -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3"} +cw-utils = { path = "../../packages/utils", version = "0.13.4" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4"} cosmwasm-std = { version = "1.0.0", features = ["staking"] } cosmwasm-storage = { version = "1.0.0" } itertools = "0.10.1" diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index eb3fe602d..33bff7c05 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-storage-plus" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Enhanced storage engines" diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index 1931df61e..b31548e02 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-utils" -version = "0.13.3" +version = "0.13.4" authors = ["Ethan Frey "] edition = "2018" description = "Common helpers for other cw specs" @@ -18,5 +18,5 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.21" } [dev-dependencies] -cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.3" } +cw-storage-plus = { path = "../../packages/storage-plus", version = "0.13.4" } prost = "0.9" From 404cf35ae456104175fbd70871e3d511f6590465 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 2 Jun 2022 12:43:05 +0200 Subject: [PATCH 336/352] Update CHANGELOG --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43ac66798..ecdbf257a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ ## [Unreleased](https://github.com/CosmWasm/cw-plus/tree/HEAD) -[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.3...HEAD) +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.4...HEAD) + +## [v0.13.4](https://github.com/CosmWasm/cw-plus/tree/v0.13.4) (2022-06-02) + +[Full Changelog](https://github.com/CosmWasm/cw-plus/compare/v0.13.3...v0.13.4) + +**Merged pull requests:** + +- Dump state multitest [\#732](https://github.com/CosmWasm/cw-plus/pull/732) ([ethanfrey](https://github.com/ethanfrey)) ## [v0.13.3](https://github.com/CosmWasm/cw-plus/tree/v0.13.3) (2022-06-01) From c99db3a0c2deb81cb3ffc5bbe0ba3c506bc2a3ae Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 2 Jun 2022 12:48:23 +0200 Subject: [PATCH 337/352] Update migrate version for good --- contracts/cw20-ics20/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index ce48726af..07c25e14a 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -204,7 +204,7 @@ pub fn execute_allow( const MIGRATE_MIN_VERSION: &str = "0.11.1"; const MIGRATE_VERSION_2: &str = "0.12.0-alpha1"; -const MIGRATE_VERSION_3: &str = "0.13.3"; +const MIGRATE_VERSION_3: &str = CONTRACT_VERSION; #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(mut deps: DepsMut, env: Env, msg: MigrateMsg) -> Result { From 16b86925485c36bfacd0fedc514c2c5962f6a17e Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 2 Jun 2022 12:54:47 +0200 Subject: [PATCH 338/352] Update check_contract to latest version in CI --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 48b96f542..b2f1d6858 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -602,7 +602,7 @@ jobs: - run: name: Install check_contract # Uses --debug for compilation speed - command: cargo install --debug --version 1.0.0-beta8 --features iterator --example check_contract -- cosmwasm-vm + command: cargo install --debug --version 1.0.0 --features iterator --example check_contract -- cosmwasm-vm - save_cache: paths: - /usr/local/cargo/registry From 5a8cdbe6e16fd66cfe3d43d0da7277900e5cb627 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 2 Jun 2022 13:08:17 +0200 Subject: [PATCH 339/352] Properly fix ics20 migration tests, but patching test code not production code --- contracts/cw20-ics20/src/contract.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 07c25e14a..8d001b5ee 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -204,7 +204,8 @@ pub fn execute_allow( const MIGRATE_MIN_VERSION: &str = "0.11.1"; const MIGRATE_VERSION_2: &str = "0.12.0-alpha1"; -const MIGRATE_VERSION_3: &str = CONTRACT_VERSION; +// the new functionality starts in 0.13.1, this is the last release that needs to be migrated to v3 +const MIGRATE_VERSION_3: &str = "0.13.0"; #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(mut deps: DepsMut, env: Env, msg: MigrateMsg) -> Result { @@ -575,6 +576,8 @@ mod test { // balances set high deps.querier .update_balance(MOCK_CONTRACT_ADDR, coins(50000, native)); + // pretend this is an old contract - set version explicitly + set_contract_version(deps.as_mut().storage, CONTRACT_NAME, MIGRATE_VERSION_3).unwrap(); // channel state a bit lower (some in-flight acks) let state = ChannelState { From deef1df68c7d34bb917bf0dc09c2cc1eee7e4532 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 7 Jun 2022 10:13:52 +0200 Subject: [PATCH 340/352] Use standard CosmosMsg --- packages/multi-test/src/app.rs | 7 +- packages/multi-test/src/lib.rs | 1 - packages/multi-test/src/untyped_msg.rs | 95 -------------------------- 3 files changed, 4 insertions(+), 99 deletions(-) delete mode 100644 packages/multi-test/src/untyped_msg.rs diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index 57db2fba8..ac5fe558d 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -1,11 +1,12 @@ use std::fmt::{self, Debug}; use std::marker::PhantomData; +use anyhow::bail; use anyhow::Result as AnyResult; use cosmwasm_std::testing::{mock_env, MockApi, MockStorage}; use cosmwasm_std::{ - from_slice, to_binary, Addr, Api, Binary, BlockInfo, ContractResult, CustomQuery, Empty, - Querier, QuerierResult, QuerierWrapper, QueryRequest, Record, Storage, SystemError, + from_slice, to_binary, Addr, Api, Binary, BlockInfo, ContractResult, CosmosMsg, CustomQuery, + Empty, Querier, QuerierResult, QuerierWrapper, QueryRequest, Record, Storage, SystemError, SystemResult, }; use schemars::JsonSchema; @@ -18,7 +19,6 @@ use crate::executor::{AppResponse, Executor}; use crate::module::{FailingModule, Module}; use crate::staking::{Distribution, FailingDistribution, FailingStaking, Staking, StakingSudo}; use crate::transactions::transactional; -use crate::untyped_msg::CosmosMsg; use crate::wasm::{ContractData, Wasm, WasmKeeper, WasmSudo}; pub fn next_block(block: &mut BlockInfo) { @@ -799,6 +799,7 @@ where CosmosMsg::Distribution(msg) => self .distribution .execute(api, storage, self, block, sender, msg), + _ => bail!("Cannot execute {:?}", msg), } } diff --git a/packages/multi-test/src/lib.rs b/packages/multi-test/src/lib.rs index 543f07d3a..b532a8152 100644 --- a/packages/multi-test/src/lib.rs +++ b/packages/multi-test/src/lib.rs @@ -17,7 +17,6 @@ mod module; mod staking; mod test_helpers; mod transactions; -mod untyped_msg; mod wasm; pub use crate::app::{ diff --git a/packages/multi-test/src/untyped_msg.rs b/packages/multi-test/src/untyped_msg.rs deleted file mode 100644 index 9e857fdcb..000000000 --- a/packages/multi-test/src/untyped_msg.rs +++ /dev/null @@ -1,95 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use std::fmt; - -use cosmwasm_std::{BankMsg, DistributionMsg, Empty, StakingMsg, WasmMsg}; - -/// This is needed so we can embed CosmosMsg as a trait bound. -/// See https://github.com/CosmWasm/cosmwasm/pull/1098 for a proper solution -/// (when we can deprecate this one) -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum CosmosMsg { - Bank(BankMsg), - // by default we use RawMsg, but a contract can override that - // to call into more app-specific code (whatever they define) - Custom(T), - #[cfg(feature = "staking")] - Distribution(DistributionMsg), - #[cfg(feature = "staking")] - Staking(StakingMsg), - Wasm(WasmMsg), -} - -impl From> for cosmwasm_std::CosmosMsg -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - fn from(input: CosmosMsg) -> Self { - match input { - CosmosMsg::Bank(b) => cosmwasm_std::CosmosMsg::Bank(b), - CosmosMsg::Custom(c) => cosmwasm_std::CosmosMsg::Custom(c), - #[cfg(feature = "staking")] - CosmosMsg::Distribution(d) => cosmwasm_std::CosmosMsg::Distribution(d), - #[cfg(feature = "staking")] - CosmosMsg::Staking(s) => cosmwasm_std::CosmosMsg::Staking(s), - CosmosMsg::Wasm(w) => cosmwasm_std::CosmosMsg::Wasm(w), - } - } -} - -impl From> for CosmosMsg -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - fn from(input: cosmwasm_std::CosmosMsg) -> CosmosMsg { - match input { - cosmwasm_std::CosmosMsg::Bank(b) => CosmosMsg::Bank(b), - cosmwasm_std::CosmosMsg::Custom(c) => CosmosMsg::Custom(c), - #[cfg(feature = "staking")] - cosmwasm_std::CosmosMsg::Distribution(d) => CosmosMsg::Distribution(d), - #[cfg(feature = "staking")] - cosmwasm_std::CosmosMsg::Staking(s) => CosmosMsg::Staking(s), - cosmwasm_std::CosmosMsg::Wasm(w) => CosmosMsg::Wasm(w), - _ => panic!("Unsupported type"), - } - } -} - -impl From for CosmosMsg -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - fn from(msg: BankMsg) -> Self { - CosmosMsg::Bank(msg) - } -} - -#[cfg(feature = "staking")] -impl From for CosmosMsg -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - fn from(msg: StakingMsg) -> Self { - CosmosMsg::Staking(msg) - } -} - -#[cfg(feature = "staking")] -impl From for CosmosMsg -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - fn from(msg: DistributionMsg) -> Self { - CosmosMsg::Distribution(msg) - } -} - -impl From for CosmosMsg -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - fn from(msg: WasmMsg) -> Self { - CosmosMsg::Wasm(msg) - } -} From aef5e80fe8c1677129e35e259fba84da6b8b8a90 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Tue, 7 Jun 2022 10:26:08 +0200 Subject: [PATCH 341/352] Fix clippy warnings --- packages/multi-test/src/app.rs | 4 ++-- packages/multi-test/src/wasm.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/multi-test/src/app.rs b/packages/multi-test/src/app.rs index ac5fe558d..68995265c 100644 --- a/packages/multi-test/src/app.rs +++ b/packages/multi-test/src/app.rs @@ -627,7 +627,7 @@ where transactional(&mut *storage, |write_cache, _| { msgs.into_iter() - .map(|msg| router.execute(&*api, write_cache, block, sender.clone(), msg.into())) + .map(|msg| router.execute(&*api, write_cache, block, sender.clone(), msg)) .collect() }) } @@ -1499,7 +1499,7 @@ mod test { lucky_winner: winner.clone(), runner_up: second.clone(), }); - app.execute(Addr::unchecked("anyone"), msg.into()).unwrap(); + app.execute(Addr::unchecked("anyone"), msg).unwrap(); // see if coins were properly added let big_win = app.wrap().query_balance(&winner, denom).unwrap(); diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index 42c350ffe..cdbd06143 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -320,7 +320,7 @@ where amount: amount.to_vec(), } .into(); - let res = router.execute(api, storage, block, sender.into(), msg.into())?; + let res = router.execute(api, storage, block, sender.into(), msg)?; Ok(res) } else { Ok(AppResponse::default()) @@ -502,7 +502,7 @@ where // execute in cache let res = transactional(storage, |write_cache, _| { - router.execute(api, write_cache, block, contract.clone(), msg.into()) + router.execute(api, write_cache, block, contract.clone(), msg) }); // call reply if meaningful From 8f91cf61dea67e4f982f2ec590d52a9aee2ec08c Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Mon, 13 Jun 2022 15:19:03 +0200 Subject: [PATCH 342/352] README: bump workspace-optimizer version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd56c7cae..bcb3e607e 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ To compile all the contracts, run the following in the repo root: docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/workspace-optimizer:0.12.4 + cosmwasm/workspace-optimizer:0.12.6 ``` This will compile all packages in the `contracts` directory and output the From be477f395dc0566559f00bb81898649d5a852733 Mon Sep 17 00:00:00 2001 From: Janita Chalam Date: Mon, 30 May 2022 15:49:25 -0700 Subject: [PATCH 343/352] add execute msg to update minter --- contracts/cw20-base/src/contract.rs | 73 +++++++++++++++++++++++++++++ packages/cw20/src/msg.rs | 2 + 2 files changed, 75 insertions(+) diff --git a/contracts/cw20-base/src/contract.rs b/contracts/cw20-base/src/contract.rs index 72f7b3d53..145812ea8 100644 --- a/contracts/cw20-base/src/contract.rs +++ b/contracts/cw20-base/src/contract.rs @@ -225,6 +225,9 @@ pub fn execute( marketing, } => execute_update_marketing(deps, env, info, project, description, marketing), ExecuteMsg::UploadLogo(logo) => execute_upload_logo(deps, env, info, logo), + ExecuteMsg::UpdateMinter { new_minter } => { + execute_update_minter(deps, env, info, new_minter) + } } } @@ -377,6 +380,32 @@ pub fn execute_send( Ok(res) } +pub fn execute_update_minter( + deps: DepsMut, + _env: Env, + info: MessageInfo, + new_minter: String, +) -> Result { + let mut config = TOKEN_INFO.load(deps.storage)?; + // Check that sender is authorized to update minter + if config.mint.is_none() || config.mint.as_ref().unwrap().minter != info.sender { + return Err(ContractError::Unauthorized {}); + } + + let minter = deps.api.addr_validate(&new_minter)?; + let minter_data = MinterData { + minter, + cap: config.mint.unwrap().cap, + }; + config.mint = Some(minter_data); + + TOKEN_INFO.save(deps.storage, &config)?; + + Ok(Response::default() + .add_attribute("action", "update_minter") + .add_attribute("minter", new_minter)) +} + pub fn execute_update_marketing( deps: DepsMut, _env: Env, @@ -871,6 +900,50 @@ mod tests { assert_eq!(err, ContractError::Unauthorized {}); } + #[test] + fn minter_can_update_itself() { + let mut deps = mock_dependencies(); + let minter = String::from("minter"); + do_instantiate_with_minter( + deps.as_mut(), + &String::from("genesis"), + Uint128::new(1234), + &minter, + None, + ); + + let msg = ExecuteMsg::UpdateMinter { + new_minter: String::from("new_minter"), + }; + + let info = mock_info(&minter, &[]); + let env = mock_env(); + let res = execute(deps.as_mut(), env, info, msg); + assert!(res.is_ok()); + } + + #[test] + fn others_cannot_update_minter() { + let mut deps = mock_dependencies(); + let minter = String::from("minter"); + do_instantiate_with_minter( + deps.as_mut(), + &String::from("genesis"), + Uint128::new(1234), + &minter, + None, + ); + + let msg = ExecuteMsg::UpdateMinter { + new_minter: String::from("new_minter"), + }; + + let info = mock_info("not the minter", &[]); + let env = mock_env(); + let err = execute(deps.as_mut(), env, info, msg).unwrap_err(); + assert_eq!(err, ContractError::Unauthorized {}); + } + #[test] fn no_one_mints_if_minter_unset() { let mut deps = mock_dependencies(); diff --git a/packages/cw20/src/msg.rs b/packages/cw20/src/msg.rs index 4a7518b54..4cd6fba63 100644 --- a/packages/cw20/src/msg.rs +++ b/packages/cw20/src/msg.rs @@ -55,6 +55,8 @@ pub enum Cw20ExecuteMsg { /// Only with the "mintable" extension. If authorized, creates amount new tokens /// and adds to the recipient balance. Mint { recipient: String, amount: Uint128 }, + /// Only with the "mintable" extension. The current minter may set a new minter. + UpdateMinter { new_minter: String }, /// Only with the "marketing" extension. If authorized, updates marketing metadata. /// Setting None/null for any of these will leave it unchanged. /// Setting Some("") will clear this field on the contract storage From 0a6546bc3fb3b337d34a47bf4763c677520ea44a Mon Sep 17 00:00:00 2001 From: Janita Chalam Date: Wed, 8 Jun 2022 09:48:26 -0700 Subject: [PATCH 344/352] resolve comments --- contracts/cw20-base/src/contract.rs | 43 +++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/contracts/cw20-base/src/contract.rs b/contracts/cw20-base/src/contract.rs index 145812ea8..2bdf482cb 100644 --- a/contracts/cw20-base/src/contract.rs +++ b/contracts/cw20-base/src/contract.rs @@ -307,8 +307,17 @@ pub fn execute_mint( return Err(ContractError::InvalidZeroAmount {}); } - let mut config = TOKEN_INFO.load(deps.storage)?; - if config.mint.is_none() || config.mint.as_ref().unwrap().minter != info.sender { + let mut config = TOKEN_INFO + .may_load(deps.storage)? + .ok_or(ContractError::Unauthorized {})?; + + if config + .mint + .as_ref() + .ok_or(ContractError::Unauthorized {})? + .minter + != info.sender + { return Err(ContractError::Unauthorized {}); } @@ -386,16 +395,19 @@ pub fn execute_update_minter( info: MessageInfo, new_minter: String, ) -> Result { - let mut config = TOKEN_INFO.load(deps.storage)?; - // Check that sender is authorized to update minter - if config.mint.is_none() || config.mint.as_ref().unwrap().minter != info.sender { + let mut config = TOKEN_INFO + .may_load(deps.storage)? + .ok_or(ContractError::Unauthorized {})?; + + let mint = config.mint.as_ref().ok_or(ContractError::Unauthorized {})?; + if mint.minter != info.sender { return Err(ContractError::Unauthorized {}); } let minter = deps.api.addr_validate(&new_minter)?; let minter_data = MinterData { minter, - cap: config.mint.unwrap().cap, + cap: mint.cap, }; config.mint = Some(minter_data); @@ -403,7 +415,7 @@ pub fn execute_update_minter( Ok(Response::default() .add_attribute("action", "update_minter") - .add_attribute("minter", new_minter)) + .add_attribute("new_minter", new_minter)) } pub fn execute_update_marketing( @@ -901,25 +913,34 @@ mod tests { } #[test] - fn minter_can_update_itself() { + fn minter_can_update_minter_but_not_cap() { let mut deps = mock_dependencies(); let minter = String::from("minter"); + let cap = Some(Uint128::from(3000000u128)); do_instantiate_with_minter( deps.as_mut(), &String::from("genesis"), Uint128::new(1234), &minter, - None, + cap, ); + let new_minter = "new_minter"; let msg = ExecuteMsg::UpdateMinter { - new_minter: String::from("new_minter"), + new_minter: new_minter.to_string(), }; let info = mock_info(&minter, &[]); let env = mock_env(); - let res = execute(deps.as_mut(), env, info, msg); + let res = execute(deps.as_mut(), env.clone(), info, msg); assert!(res.is_ok()); + let query_minter_msg = QueryMsg::Minter {}; + let res = query(deps.as_ref(), env, query_minter_msg); + let mint: MinterResponse = from_binary(&res.unwrap()).unwrap(); + + // Minter cannot update cap. + assert!(mint.cap == cap); + assert!(mint.minter == new_minter) } #[test] From c154dc3c4a43bc82db747b0ab606ac20c5b233dd Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Sat, 18 Jun 2022 12:11:04 +0200 Subject: [PATCH 345/352] cw3-flex: Add implementation for optional executor --- contracts/cw3-flex-multisig/src/contract.rs | 24 +++++++++++++++++++-- contracts/cw3-flex-multisig/src/msg.rs | 5 +++++ contracts/cw3-flex-multisig/src/state.rs | 13 +++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 5616cba7d..7bc0978c1 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -19,7 +19,7 @@ use cw_utils::{maybe_addr, Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{Config, CONFIG}; +use crate::state::{Config, Executor, CONFIG}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw3-flex-multisig"; @@ -46,6 +46,7 @@ pub fn instantiate( threshold: msg.threshold, max_voting_period: msg.max_voting_period, group_addr, + executor: msg.executor, }; CONFIG.save(deps.storage, &cfg)?; @@ -192,7 +193,26 @@ pub fn execute_execute( info: MessageInfo, proposal_id: u64, ) -> Result { - // anyone can trigger this if the vote passed + let cfg = CONFIG.load(deps.storage)?; + + // Executor can be set in 3 ways: + // - Member: any member of the voting group can execute + // - Only: only passed address is able to execute + // - None: Anyone can execute message + if let Some(executor) = cfg.executor { + match executor { + Executor::Member => { + cfg.group_addr + .is_member(&deps.querier, &info.sender, None)? + .ok_or(ContractError::Unauthorized {})?; + } + Executor::Only(addr) => { + if addr != info.sender { + return Err(ContractError::Unauthorized {}); + } + } + } + } let mut prop = PROPOSALS.load(deps.storage, proposal_id)?; // we allow execution even after the proposal "expiration" as long as all vote come in before diff --git a/contracts/cw3-flex-multisig/src/msg.rs b/contracts/cw3-flex-multisig/src/msg.rs index 8d72cd37b..99437b26b 100644 --- a/contracts/cw3-flex-multisig/src/msg.rs +++ b/contracts/cw3-flex-multisig/src/msg.rs @@ -6,12 +6,17 @@ use cw3::Vote; use cw4::MemberChangedHookMsg; use cw_utils::{Duration, Expiration, Threshold}; +use crate::state::Executor; + #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct InstantiateMsg { // this is the group contract that contains the member list pub group_addr: String, pub threshold: Threshold, pub max_voting_period: Duration, + // who is able to execute passed proposals + // None means that anyone can execute + pub executor: Option, } // TODO: add some T variants? Maybe good enough as fixed Empty for now diff --git a/contracts/cw3-flex-multisig/src/state.rs b/contracts/cw3-flex-multisig/src/state.rs index 023662b8b..bdbc90456 100644 --- a/contracts/cw3-flex-multisig/src/state.rs +++ b/contracts/cw3-flex-multisig/src/state.rs @@ -1,16 +1,29 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use cosmwasm_std::Addr; use cw4::Cw4Contract; use cw_storage_plus::Item; use cw_utils::{Duration, Threshold}; +/// Defines who is able to execute proposals once passed +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +pub enum Executor { + /// Any member of the voting group, even with 0 points + Member, + /// Only the given address + Only(Addr), +} + #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct Config { pub threshold: Threshold, pub max_voting_period: Duration, // Total weight and voters are queried from this contract pub group_addr: Cw4Contract, + // who is able to execute passed proposals + // None means that anyone can execute + pub executor: Option, } // unique items From 57c11d65f692b4566a6bd01a7aba14ddd8a9efd3 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Sat, 18 Jun 2022 12:22:20 +0200 Subject: [PATCH 346/352] cw3-flex: Adjust existing test to new executor parameter --- contracts/cw3-flex-multisig/src/contract.rs | 49 ++++++++++++++------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 7bc0978c1..111b8f2ff 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -193,12 +193,18 @@ pub fn execute_execute( info: MessageInfo, proposal_id: u64, ) -> Result { - let cfg = CONFIG.load(deps.storage)?; + let mut prop = PROPOSALS.load(deps.storage, proposal_id)?; + // we allow execution even after the proposal "expiration" as long as all vote come in before + // that point. If it was approved on time, it can be executed any time. + if prop.current_status(&env.block) != Status::Passed { + return Err(ContractError::WrongExecuteStatus {}); + } // Executor can be set in 3 ways: // - Member: any member of the voting group can execute // - Only: only passed address is able to execute // - None: Anyone can execute message + let cfg = CONFIG.load(deps.storage)?; if let Some(executor) = cfg.executor { match executor { Executor::Member => { @@ -214,13 +220,6 @@ pub fn execute_execute( } } - let mut prop = PROPOSALS.load(deps.storage, proposal_id)?; - // we allow execution even after the proposal "expiration" as long as all vote come in before - // that point. If it was approved on time, it can be executed any time. - if prop.current_status(&env.block) != Status::Passed { - return Err(ContractError::WrongExecuteStatus {}); - } - // set it to executed prop.status = Status::Executed; PROPOSALS.save(deps.storage, proposal_id, &prop)?; @@ -517,12 +516,14 @@ mod tests { group: Addr, threshold: Threshold, max_voting_period: Duration, + executor: Option, ) -> Addr { let flex_id = app.store_code(contract_flex()); let msg = crate::msg::InstantiateMsg { group_addr: group.to_string(), threshold, max_voting_period, + executor, }; app.instantiate_contract(flex_id, Addr::unchecked(OWNER), &msg, &[], "flex", None) .unwrap() @@ -547,6 +548,7 @@ mod tests { max_voting_period, init_funds, multisig_as_group_admin, + None, ) } @@ -557,6 +559,7 @@ mod tests { max_voting_period: Duration, init_funds: Vec, multisig_as_group_admin: bool, + executor: Option, ) -> (Addr, Addr) { // 1. Instantiate group contract with members (and OWNER as admin) let members = vec![ @@ -571,7 +574,13 @@ mod tests { app.update_block(next_block); // 2. Set up Multisig backed by this group - let flex_addr = instantiate_flex(app, group_addr.clone(), threshold, max_voting_period); + let flex_addr = instantiate_flex( + app, + group_addr.clone(), + threshold, + max_voting_period, + executor, + ); app.update_block(next_block); // 3. (Optional) Set the multisig as the group owner @@ -636,6 +645,7 @@ mod tests { quorum: Decimal::percent(1), }, max_voting_period, + executor: None, }; let err = app .instantiate_contract( @@ -657,6 +667,7 @@ mod tests { group_addr: group_addr.to_string(), threshold: Threshold::AbsoluteCount { weight: 100 }, max_voting_period, + executor: None, }; let err = app .instantiate_contract( @@ -678,6 +689,7 @@ mod tests { group_addr: group_addr.to_string(), threshold: Threshold::AbsoluteCount { weight: 1 }, max_voting_period, + executor: None, }; let flex_addr = app .instantiate_contract( @@ -835,7 +847,8 @@ mod tests { threshold: Decimal::percent(80), quorum: Decimal::percent(20), }; - let (flex_addr, _) = setup_test_case(&mut app, threshold, voting_period, init_funds, false); + let (flex_addr, _) = + setup_test_case(&mut app, threshold, voting_period, init_funds, false, None); // create proposal with 1 vote power let proposal = pay_somebody_proposal(); @@ -930,7 +943,8 @@ mod tests { quorum: Decimal::percent(1), }; let voting_period = Duration::Time(2000000); - let (flex_addr, _) = setup_test_case(&mut app, threshold, voting_period, init_funds, false); + let (flex_addr, _) = + setup_test_case(&mut app, threshold, voting_period, init_funds, false, None); // create proposal with 0 vote power let proposal = pay_somebody_proposal(); @@ -1121,7 +1135,8 @@ mod tests { quorum: Decimal::percent(1), }; let voting_period = Duration::Time(2000000); - let (flex_addr, _) = setup_test_case(&mut app, threshold, voting_period, init_funds, true); + let (flex_addr, _) = + setup_test_case(&mut app, threshold, voting_period, init_funds, true, None); // ensure we have cash to cover the proposal let contract_bal = app.wrap().query_balance(&flex_addr, "BTC").unwrap(); @@ -1227,6 +1242,7 @@ mod tests { Duration::Time(voting_period), init_funds, true, + None, ); // ensure we have cash to cover the proposal @@ -1302,7 +1318,8 @@ mod tests { quorum: Decimal::percent(1), }; let voting_period = Duration::Height(2000000); - let (flex_addr, _) = setup_test_case(&mut app, threshold, voting_period, init_funds, true); + let (flex_addr, _) = + setup_test_case(&mut app, threshold, voting_period, init_funds, true, None); // create proposal with 0 vote power let proposal = pay_somebody_proposal(); @@ -1354,7 +1371,7 @@ mod tests { }; let voting_period = Duration::Time(20000); let (flex_addr, group_addr) = - setup_test_case(&mut app, threshold, voting_period, init_funds, false); + setup_test_case(&mut app, threshold, voting_period, init_funds, false, None); // VOTER1 starts a proposal to send some tokens (1/4 votes) let proposal = pay_somebody_proposal(); @@ -1600,7 +1617,7 @@ mod tests { }; let voting_period = Duration::Time(20000); let (flex_addr, group_addr) = - setup_test_case(&mut app, threshold, voting_period, init_funds, false); + setup_test_case(&mut app, threshold, voting_period, init_funds, false, None); // VOTER3 starts a proposal to send some tokens (3/12 votes) let proposal = pay_somebody_proposal(); @@ -1683,6 +1700,7 @@ mod tests { voting_period, init_funds, false, + None, ); // VOTER3 starts a proposal to send some tokens (3 votes) @@ -1753,6 +1771,7 @@ mod tests { voting_period, init_funds, false, + None, ); // create proposal From 467c4725200ab4c766c9569e6fce675fecb400b3 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Sat, 18 Jun 2022 13:49:14 +0200 Subject: [PATCH 347/352] cw3-flex: Add testcases that confirms executor works --- contracts/cw3-flex-multisig/src/contract.rs | 122 ++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 111b8f2ff..53e8032fd 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -1226,6 +1226,128 @@ mod tests { ); } + #[test] + fn execute_with_executor_member() { + let init_funds = coins(10, "BTC"); + let mut app = mock_app(&init_funds); + + let threshold = Threshold::ThresholdQuorum { + threshold: Decimal::percent(51), + quorum: Decimal::percent(1), + }; + let voting_period = Duration::Time(2000000); + let (flex_addr, _) = setup_test_case( + &mut app, + threshold, + voting_period, + init_funds, + true, + Some(crate::state::Executor::Member), + ); + + // create proposal with 0 vote power + let proposal = pay_somebody_proposal(); + let res = app + .execute_contract(Addr::unchecked(OWNER), flex_addr.clone(), &proposal, &[]) + .unwrap(); + + // Get the proposal id from the logs + let proposal_id: u64 = res.custom_attrs(1)[2].value.parse().unwrap(); + + // Vote it, so it passes + let vote = ExecuteMsg::Vote { + proposal_id, + vote: Vote::Yes, + }; + app.execute_contract(Addr::unchecked(VOTER4), flex_addr.clone(), &vote, &[]) + .unwrap(); + + let execution = ExecuteMsg::Execute { proposal_id }; + let err = app + .execute_contract( + Addr::unchecked(Addr::unchecked("anyone")), + flex_addr.clone(), + &execution, + &[], + ) + .unwrap_err(); + assert_eq!(ContractError::Unauthorized {}, err.downcast().unwrap()); + + app.execute_contract( + Addr::unchecked(Addr::unchecked(VOTER2)), + flex_addr, + &execution, + &[], + ) + .unwrap(); + } + + #[test] + fn execute_with_executor_only() { + let init_funds = coins(10, "BTC"); + let mut app = mock_app(&init_funds); + + let threshold = Threshold::ThresholdQuorum { + threshold: Decimal::percent(51), + quorum: Decimal::percent(1), + }; + let voting_period = Duration::Time(2000000); + let (flex_addr, _) = setup_test_case( + &mut app, + threshold, + voting_period, + init_funds, + true, + Some(crate::state::Executor::Only(Addr::unchecked(VOTER3))), + ); + + // create proposal with 0 vote power + let proposal = pay_somebody_proposal(); + let res = app + .execute_contract(Addr::unchecked(OWNER), flex_addr.clone(), &proposal, &[]) + .unwrap(); + + // Get the proposal id from the logs + let proposal_id: u64 = res.custom_attrs(1)[2].value.parse().unwrap(); + + // Vote it, so it passes + let vote = ExecuteMsg::Vote { + proposal_id, + vote: Vote::Yes, + }; + app.execute_contract(Addr::unchecked(VOTER4), flex_addr.clone(), &vote, &[]) + .unwrap(); + + let execution = ExecuteMsg::Execute { proposal_id }; + let err = app + .execute_contract( + Addr::unchecked(Addr::unchecked("anyone")), + flex_addr.clone(), + &execution, + &[], + ) + .unwrap_err(); + assert_eq!(ContractError::Unauthorized {}, err.downcast().unwrap()); + + let err = app + .execute_contract( + Addr::unchecked(Addr::unchecked(VOTER1)), + flex_addr.clone(), + &execution, + &[], + ) + .unwrap_err(); + assert_eq!(ContractError::Unauthorized {}, err.downcast().unwrap()); + + app.execute_contract( + Addr::unchecked(Addr::unchecked(VOTER3)), + flex_addr, + &execution, + &[], + ) + .unwrap(); + } + #[test] fn proposal_pass_on_expiration() { let init_funds = coins(10, "BTC"); From ad6a88930fb873675214cb83b31162cd1136078f Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Sun, 19 Jun 2022 12:17:18 +0200 Subject: [PATCH 348/352] cw3-flex: Create authorize method for Config structure --- contracts/cw3-flex-multisig/src/contract.rs | 21 ++-------------- contracts/cw3-flex-multisig/src/state.rs | 28 ++++++++++++++++++++- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 53e8032fd..4157a83c3 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -19,7 +19,7 @@ use cw_utils::{maybe_addr, Expiration, ThresholdResponse}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{Config, Executor, CONFIG}; +use crate::state::{Config, CONFIG}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw3-flex-multisig"; @@ -200,25 +200,8 @@ pub fn execute_execute( return Err(ContractError::WrongExecuteStatus {}); } - // Executor can be set in 3 ways: - // - Member: any member of the voting group can execute - // - Only: only passed address is able to execute - // - None: Anyone can execute message let cfg = CONFIG.load(deps.storage)?; - if let Some(executor) = cfg.executor { - match executor { - Executor::Member => { - cfg.group_addr - .is_member(&deps.querier, &info.sender, None)? - .ok_or(ContractError::Unauthorized {})?; - } - Executor::Only(addr) => { - if addr != info.sender { - return Err(ContractError::Unauthorized {}); - } - } - } - } + cfg.authorize(&deps.querier, &info.sender)?; // set it to executed prop.status = Status::Executed; diff --git a/contracts/cw3-flex-multisig/src/state.rs b/contracts/cw3-flex-multisig/src/state.rs index bdbc90456..721c43882 100644 --- a/contracts/cw3-flex-multisig/src/state.rs +++ b/contracts/cw3-flex-multisig/src/state.rs @@ -1,11 +1,13 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::Addr; +use cosmwasm_std::{Addr, QuerierWrapper}; use cw4::Cw4Contract; use cw_storage_plus::Item; use cw_utils::{Duration, Threshold}; +use crate::error::ContractError; + /// Defines who is able to execute proposals once passed #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub enum Executor { @@ -26,5 +28,29 @@ pub struct Config { pub executor: Option, } +impl Config { + // Executor can be set in 3 ways: + // - Member: any member of the voting group can execute + // - Only: only passed address is able to execute + // - None: Anyone can execute message + pub fn authorize(&self, querier: &QuerierWrapper, sender: &Addr) -> Result<(), ContractError> { + if let Some(executor) = &self.executor { + match executor { + Executor::Member => { + self.group_addr + .is_member(querier, sender, None)? + .ok_or(ContractError::Unauthorized {})?; + } + Executor::Only(addr) => { + if addr != sender { + return Err(ContractError::Unauthorized {}); + } + } + } + } + Ok(()) + } +} + // unique items pub const CONFIG: Item = Item::new("config"); From 1e1f6e582da162b9304fd02f975ca5f7420a6fbb Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Sun, 19 Jun 2022 12:23:42 +0200 Subject: [PATCH 349/352] cw3-flex: Adjust comments to match authorize methods better --- contracts/cw3-flex-multisig/src/contract.rs | 14 +++++++------- contracts/cw3-flex-multisig/src/state.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 4157a83c3..79ac0fc27 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -1225,7 +1225,7 @@ mod tests { voting_period, init_funds, true, - Some(crate::state::Executor::Member), + Some(crate::state::Executor::Member), // set executor as Member of voting group ); // create proposal with 0 vote power @@ -1248,7 +1248,7 @@ mod tests { let execution = ExecuteMsg::Execute { proposal_id }; let err = app .execute_contract( - Addr::unchecked(Addr::unchecked("anyone")), + Addr::unchecked(Addr::unchecked("anyone")), // anyone is not allowed to execute flex_addr.clone(), &execution, &[], @@ -1257,7 +1257,7 @@ mod tests { assert_eq!(ContractError::Unauthorized {}, err.downcast().unwrap()); app.execute_contract( - Addr::unchecked(Addr::unchecked(VOTER2)), + Addr::unchecked(Addr::unchecked(VOTER2)), // member of voting group is allowed to execute flex_addr, &execution, &[], @@ -1281,7 +1281,7 @@ mod tests { voting_period, init_funds, true, - Some(crate::state::Executor::Only(Addr::unchecked(VOTER3))), + Some(crate::state::Executor::Only(Addr::unchecked(VOTER3))), // only VOTER3 can execute proposal ); // create proposal with 0 vote power @@ -1304,7 +1304,7 @@ mod tests { let execution = ExecuteMsg::Execute { proposal_id }; let err = app .execute_contract( - Addr::unchecked(Addr::unchecked("anyone")), + Addr::unchecked(Addr::unchecked("anyone")), // anyone is not allowed to execute flex_addr.clone(), &execution, &[], @@ -1314,7 +1314,7 @@ mod tests { let err = app .execute_contract( - Addr::unchecked(Addr::unchecked(VOTER1)), + Addr::unchecked(Addr::unchecked(VOTER1)), // VOTER1 is not allowed to execute flex_addr.clone(), &execution, &[], @@ -1323,7 +1323,7 @@ mod tests { assert_eq!(ContractError::Unauthorized {}, err.downcast().unwrap()); app.execute_contract( - Addr::unchecked(Addr::unchecked(VOTER3)), + Addr::unchecked(Addr::unchecked(VOTER3)), // VOTER3 is allowed to execute flex_addr, &execution, &[], diff --git a/contracts/cw3-flex-multisig/src/state.rs b/contracts/cw3-flex-multisig/src/state.rs index 721c43882..a1e388777 100644 --- a/contracts/cw3-flex-multisig/src/state.rs +++ b/contracts/cw3-flex-multisig/src/state.rs @@ -30,9 +30,9 @@ pub struct Config { impl Config { // Executor can be set in 3 ways: - // - Member: any member of the voting group can execute - // - Only: only passed address is able to execute - // - None: Anyone can execute message + // - Member: any member of the voting group is authorized + // - Only: only passed address is authorized + // - None: Everyone are authorized pub fn authorize(&self, querier: &QuerierWrapper, sender: &Addr) -> Result<(), ContractError> { if let Some(executor) = &self.executor { match executor { From 5c1b39f68195c6b10c43529ba788d9a0746db6a3 Mon Sep 17 00:00:00 2001 From: Luke Park Date: Tue, 28 Jun 2022 22:19:06 +0900 Subject: [PATCH 350/352] fix: relocate contents --- packages/cw20/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/cw20/README.md b/packages/cw20/README.md index 970db35ff..35be5f736 100644 --- a/packages/cw20/README.md +++ b/packages/cw20/README.md @@ -144,6 +144,14 @@ the minter is a smart contract. This should be enabled with all blockchains that have iterator support. It allows us to get lists of results with pagination. +### Queries + +`AllAllowances{owner, start_after, limit}` - Returns the list of all non-expired allowances +by the given owner. `start_after` and `limit` provide pagination. + +`AllAccounts{start_after, limit}` - Returns the list of all accounts that have been created on +the contract (just the addresses). `start_after` and `limit` provide pagination. + ## Marketing This allows us to attach more metadata on the token to help with displaying the token in @@ -173,11 +181,3 @@ account, this will update some marketing-related metadata on the contract. `DownloadLogo{}` - If the token's logo was previously uploaded to the blockchain (see `UploadLogo` message), then it returns the raw data to be displayed in a browser. Return type is `DownloadLogoResponse{ mime_type, data }`. - -### Queries - -`AllAllowances{owner, start_after, limit}` - Returns the list of all non-expired allowances -by the given owner. `start_after` and `limit` provide pagination. - -`AllAccounts{start_after, limit}` - Returns the list of all accounts that have been created on -the contract (just the addresses). `start_after` and `limit` provide pagination. From 71b4d4b677b7f97f7fcabfb196ce019bf0043238 Mon Sep 17 00:00:00 2001 From: batphonghan Date: Mon, 4 Jul 2022 18:05:06 +0700 Subject: [PATCH 351/352] Export Distribution trailt --- packages/multi-test/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/multi-test/src/lib.rs b/packages/multi-test/src/lib.rs index a2071a08e..5e2c47a69 100644 --- a/packages/multi-test/src/lib.rs +++ b/packages/multi-test/src/lib.rs @@ -27,5 +27,5 @@ pub use crate::bank::{Bank, BankKeeper, BankSudo}; pub use crate::contracts::{Contract, ContractWrapper}; pub use crate::executor::{AppResponse, Executor}; pub use crate::module::Module; -pub use crate::staking::{FailingDistribution, FailingStaking, Staking, StakingSudo}; +pub use crate::staking::{Distribution, FailingDistribution, FailingStaking, Staking, StakingSudo}; pub use crate::wasm::{Wasm, WasmKeeper, WasmSudo}; From cf79b3edec5b16c472bea2d49b1e591e5e89fb63 Mon Sep 17 00:00:00 2001 From: batphonghan Date: Mon, 4 Jul 2022 20:26:54 +0700 Subject: [PATCH 352/352] Export FailingModule --- packages/multi-test/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/multi-test/src/lib.rs b/packages/multi-test/src/lib.rs index ea1a7b092..6c3fc0ebc 100644 --- a/packages/multi-test/src/lib.rs +++ b/packages/multi-test/src/lib.rs @@ -26,6 +26,6 @@ pub use crate::app::{ pub use crate::bank::{Bank, BankKeeper, BankSudo}; pub use crate::contracts::{Contract, ContractWrapper}; pub use crate::executor::{AppResponse, Executor}; -pub use crate::module::Module; +pub use crate::module::{FailingModule, Module}; pub use crate::staking::{Distribution, FailingDistribution, FailingStaking, Staking, StakingSudo}; pub use crate::wasm::{Wasm, WasmKeeper, WasmSudo};