Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cosmwasm-std #260

Merged
merged 92 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
af22dfa
update cosmwasm-std, change math api
yihuang Mar 26, 2021
c9e8d34
rename KV -> Pair
yihuang Apr 2, 2021
420dfec
address change: cw0,cw1,cw2,cw3,cw4
yihuang Apr 8, 2021
470c2ba
address change: cw20,cw721,cw1155
yihuang Apr 8, 2021
e654cef
address change: cw-controllers
yihuang Apr 8, 2021
a3dde73
address change: multi-test
yihuang Apr 8, 2021
01d4e95
address change: cw20-base,cw721-base,cw1155-base
yihuang Apr 8, 2021
be013e0
Adjust Addr/String in cw1,3,4
ethanfrey Apr 8, 2021
57d574d
Add cw1155 package+contract to CI
ethanfrey Apr 8, 2021
18df393
Add cw1155 to deploy scripts
ethanfrey Apr 8, 2021
0c08564
Update cw1-whitelist
ethanfrey Apr 8, 2021
2cf5432
cw1-subkey compiles, only Addr, no CanonicalAddr
ethanfrey Apr 8, 2021
5e8e8ba
Fix all tests for cw1-subkeys
ethanfrey Apr 8, 2021
5de3e18
Update schemas
ethanfrey Apr 8, 2021
401a2a7
Add AddrRef for better lifetimes
ethanfrey Apr 8, 2021
55f97f5
Use AddrRef in cw1-subkeys
ethanfrey Apr 8, 2021
49e2be0
Update package cw20
ethanfrey Apr 8, 2021
e3bfa99
Update cw721 spec
ethanfrey Apr 8, 2021
1335006
Update cw1155
ethanfrey Apr 8, 2021
7140497
Remove Canonical helpers
ethanfrey Apr 8, 2021
a82070c
Update controllers to store Addr, not CanonicalAddr
ethanfrey Apr 8, 2021
c4ea90c
cw3-fixed-multisig fixed, temporarily remove integration tests
ethanfrey Apr 8, 2021
c8a8468
Add maybe_addr() helper
maurolacy Apr 8, 2021
d213c97
cargo fmt
maurolacy Apr 8, 2021
bee6474
cw4-group compiles
maurolacy Apr 8, 2021
a332725
Migrate cw4-group unit tests
maurolacy Apr 8, 2021
924240e
cw20-base compiles, tests broken
ethanfrey Apr 8, 2021
b6f055e
Update cw4-group schema
ethanfrey Apr 8, 2021
385600c
cw4-stake compiles
maurolacy Apr 8, 2021
fbb6c17
Update cw4-stake schemas
maurolacy Apr 8, 2021
0ed8772
Remove commented code
maurolacy Apr 9, 2021
e23f7cf
Update cw4-group unit tests
maurolacy Apr 9, 2021
92eca49
Update/fix fw20-base tests
maurolacy Apr 9, 2021
40f2c7e
Use Cw20CoinVerified for Balance
maurolacy Apr 10, 2021
656964f
Use Addr / Cw20CoinVerified for state
maurolacy Apr 10, 2021
e0a3a94
Use String / Cw20Coin for msg
maurolacy Apr 10, 2021
38c40ea
cw20-escrow compiles
maurolacy Apr 10, 2021
a3a086a
Update cw20-escrow unit tests
maurolacy Apr 10, 2021
5ef5bba
Update cw20-escrow integration test
maurolacy Apr 10, 2021
319de31
Use Addr for state
maurolacy Apr 10, 2021
d04994a
Use String 7 Cw20Coin for msg
maurolacy Apr 10, 2021
ba8f272
Update cw20-atomic-swap
maurolacy Apr 10, 2021
42f76a2
Update cw20-escrow schemas
maurolacy Apr 10, 2021
f27698e
Update cw20-atomic-swap schemas
maurolacy Apr 10, 2021
2710be7
Use String for msg
maurolacy Apr 10, 2021
a8c3b4e
Update cw20-bonding
maurolacy Apr 10, 2021
f8edebd
Update cw20-bonding schemas
maurolacy Apr 10, 2021
83d0f6f
Update cw20-ics20
maurolacy Apr 10, 2021
9b927c5
Update cw20-ics20 schema
maurolacy Apr 10, 2021
f8b07cd
Add address validation
maurolacy Apr 10, 2021
11f1b34
Remove closure
maurolacy Apr 10, 2021
72f1650
cw20-staking compiles
maurolacy Apr 10, 2021
37ffc87
Update cw20-staking unit tests
maurolacy Apr 10, 2021
c6d50f5
Update cw20-staking schema
maurolacy Apr 10, 2021
e4f0c0c
Use Addr, member_key str key
maurolacy Apr 10, 2021
1ac1818
Use str key for ballots
maurolacy Apr 10, 2021
6cf17a7
Use String for msg and error
maurolacy Apr 10, 2021
0a1de48
cw3-flex-multisig compiles
maurolacy Apr 10, 2021
9d93a30
group_addr validation using map_err
maurolacy Apr 10, 2021
b88d6b0
Update cw3-flex-multisig schema
maurolacy Apr 10, 2021
6e20287
Remove redundant clone
maurolacy Apr 10, 2021
878950d
Update cw3-flex-multisig unit tests
maurolacy Apr 10, 2021
f90599b
Use Addr, &str key for state
maurolacy Apr 10, 2021
da499bb
Use String for msg
maurolacy Apr 10, 2021
010f5ab
cw721-base compiles
maurolacy Apr 10, 2021
90c1858
Add Approval is_expired() helper
maurolacy Apr 10, 2021
5b8f926
Update cw721-base schema
maurolacy Apr 11, 2021
d45e56f
Update cw721-base unit tests
maurolacy Apr 11, 2021
1f9818e
Use Vec::from
maurolacy Apr 11, 2021
87b4013
Add start_after addr validation to all paginated queries
maurolacy Apr 11, 2021
f427977
Remove redundant clones
maurolacy Apr 11, 2021
08c6388
Use Addr, &str keys for state
maurolacy Apr 11, 2021
cddeafd
Use String form msg
maurolacy Apr 11, 2021
e618606
cw1155-base compiles
maurolacy Apr 11, 2021
c2a2fa3
Add cw1155-base cargo config
maurolacy Apr 11, 2021
4e105a4
Update cw1155-base unit tests
maurolacy Apr 11, 2021
07ad611
Remove redundant calls
maurolacy Apr 11, 2021
779b4fe
cargo fmt
maurolacy Apr 11, 2021
6cb71b9
cargo clippy
maurolacy Apr 11, 2021
d8894e3
Update version of wasm checker
ethanfrey Apr 12, 2021
e8f3eb5
Add schema to cw1155-base
ethanfrey Apr 12, 2021
81f571f
Merge branch 'master' into update-cosmwas-std
ethanfrey Apr 12, 2021
f7c0e43
Implement PrimaryKey for &Addr
webmaster128 Apr 11, 2021
f35a0ab
Use &Addr in cw3-fixed-multisig
webmaster128 Apr 12, 2021
e529858
Use &Addr not AddrRef in cw1-subkeys
ethanfrey Apr 13, 2021
91c59cc
Remove AddrRef from storage-plus
ethanfrey Apr 13, 2021
f6c8ae0
Use &Addr not AddrRef in cw20-base
ethanfrey Apr 13, 2021
d68af14
Fix cw4-stake and cw4-group
ethanfrey Apr 13, 2021
c0ce30e
Update cw20-staking
ethanfrey Apr 13, 2021
7583b2e
Update cw3-flex-multisig
ethanfrey Apr 13, 2021
289d26a
Cleanup
ethanfrey Apr 13, 2021
120857d
Use Addr in cw1155 state keys
ethanfrey Apr 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions contracts/cw1-subkeys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ cw0 = { path = "../../packages/cw0", version = "0.6.0-alpha3" }
cw1 = { path = "../../packages/cw1", version = "0.6.0-alpha3" }
cw2 = { path = "../../packages/cw2", version = "0.6.0-alpha3" }
cw1-whitelist = { path = "../cw1-whitelist", version = "0.6.0-alpha3", features = ["library"] }
cosmwasm-std = { version = "0.14.0-beta1", features = ["iterator", "staking"] }
cosmwasm-std = { version = "0.14.0-beta2", features = ["iterator", "staking"] }
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-alpha3", features = ["iterator"] }
schemars = "0.7"
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.20" }

[dev-dependencies]
cosmwasm-schema = { version = "0.14.0-beta1" }
cosmwasm-schema = { version = "0.14.0-beta2" }
5 changes: 1 addition & 4 deletions contracts/cw1-subkeys/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,10 +1186,7 @@ mod tests {

// And then cannot (not enough funds anymore)
let err = execute(deps.as_mut(), mock_env(), info, execute_msg.clone()).unwrap_err();
assert!(matches!(
err,
ContractError::Std(StdError::Underflow { .. })
));
assert!(matches!(err, ContractError::Std(StdError::Overflow { .. })));

// Owner / admins can do anything (at the contract level)
let info = mock_info(&owner.clone(), &[]);
Expand Down
6 changes: 3 additions & 3 deletions contracts/cw1-whitelist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ library = []
cw0 = { path = "../../packages/cw0", version = "0.6.0-alpha3" }
cw1 = { path = "../../packages/cw1", version = "0.6.0-alpha3" }
cw2 = { path = "../../packages/cw2", version = "0.6.0-alpha3" }
cosmwasm-std = { version = "0.14.0-beta1", features = ["iterator"] }
cosmwasm-std = { version = "0.14.0-beta2", features = ["iterator"] }
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-alpha3", features = ["iterator"] }
schemars = "0.7"
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.20" }

[dev-dependencies]
cosmwasm-schema = { version = "0.14.0-beta1" }
cosmwasm-schema = { version = "0.14.0-beta2" }
4 changes: 2 additions & 2 deletions contracts/cw1155-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ cw0 = { path = "../../packages/cw0", version = "0.6.0-alpha3" }
cw2 = { path = "../../packages/cw2", version = "0.6.0-alpha3" }
cw1155 = { path = "../../packages/cw1155", version = "0.6.0-alpha3" }
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-alpha3" , features = ["iterator"]}
cosmwasm-std = { version = "0.14.0-beta1", features = ["iterator"] }
schemars = "0.7"
cosmwasm-std = { version = "0.14.0-beta2", features = ["iterator"] }
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.20" }

Expand Down
53 changes: 28 additions & 25 deletions contracts/cw1155-base/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Api, Binary, Deps, DepsMut, Env, HumanAddr, MessageInfo, Order, Response, StdResult,
Uint128, KV,
to_binary, Api, Binary, Deps, DepsMut, Env, HumanAddr, MessageInfo, Order, Pair, Response,
StdResult, Uint128,
};
use cw_storage_plus::Bound;

Expand Down Expand Up @@ -103,7 +103,9 @@ fn execute_transfer_inner<'a>(
BALANCES.update(
deps.storage,
(from_raw.as_slice(), token_id),
|balance: Option<Uint128>| balance.unwrap_or_default() - amount,
|balance: Option<Uint128>| -> StdResult<_> {
Ok(balance.unwrap_or_default().checked_sub(amount)?)
},
)?;
}

Expand All @@ -112,7 +114,9 @@ fn execute_transfer_inner<'a>(
BALANCES.update(
deps.storage,
(canonical_to.as_slice(), token_id),
|balance: Option<Uint128>| -> StdResult<_> { Ok(balance.unwrap_or_default() + amount) },
|balance: Option<Uint128>| -> StdResult<_> {
Ok(balance.unwrap_or_default().checked_add(amount)?)
},
)?;
}

Expand Down Expand Up @@ -445,7 +449,7 @@ pub fn query(deps: Deps, env: Env, msg: Cw1155QueryMsg) -> StdResult<Binary> {
}
}

fn parse_approval(api: &dyn Api, item: StdResult<KV<Expiration>>) -> StdResult<cw1155::Approval> {
fn parse_approval(api: &dyn Api, item: StdResult<Pair<Expiration>>) -> StdResult<cw1155::Approval> {
item.and_then(|(k, expires)| {
let spender = api.human_address(&k.into())?;
Ok(cw1155::Approval { spender, expires })
Expand Down Expand Up @@ -511,8 +515,8 @@ fn query_all_tokens(

#[cfg(test)]
mod tests {
use cosmwasm_std::attr;
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
use cosmwasm_std::{attr, OverflowError, StdError};

use super::*;

Expand Down Expand Up @@ -1181,19 +1185,13 @@ mod tests {
}

#[test]
#[should_panic(expected = "attempt to add with overflow")]
fn mint_overflow() {
let mut deps = mock_dependencies(&[]);
let token1 = "token1".to_owned();
let minter: HumanAddr = "minter".into();
let user1: HumanAddr = "user1".into();

let env = {
let mut env = mock_env();
env.block.height = 10;
env
};

let env = mock_env();
let msg = InitMsg {
minter: minter.clone(),
};
Expand All @@ -1213,17 +1211,22 @@ mod tests {
)
.unwrap();

execute(
deps.as_mut(),
env.clone(),
mock_info(minter.clone(), &[]),
Cw1155ExecuteMsg::Mint {
to: user1.clone(),
token_id: token1.clone(),
value: 1u64.into(),
msg: None,
},
)
.unwrap();
assert!(matches!(
execute(
deps.as_mut(),
env.clone(),
mock_info(minter.clone(), &[]),
Cw1155ExecuteMsg::Mint {
to: user1.clone(),
token_id: token1.clone(),
value: 1u64.into(),
msg: None,
},
),
Err(ContractError::Std(StdError::Overflow {
source: OverflowError { .. },
..
}))
));
}
}
6 changes: 3 additions & 3 deletions contracts/cw20-atomic-swap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ library = []
cw0 = { path = "../../packages/cw0", version = "0.6.0-alpha3" }
cw2 = { path = "../../packages/cw2", version = "0.6.0-alpha3" }
cw20 = { path = "../../packages/cw20", version = "0.6.0-alpha3" }
cosmwasm-std = { version = "0.14.0-beta1", features = ["iterator"] }
cosmwasm-std = { version = "0.14.0-beta2", features = ["iterator"] }
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-alpha3", features = ["iterator"] }
schemars = "0.7"
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.20" }
hex = "0.3.1"
sha2 = "0.8.0"

[dev-dependencies]
cosmwasm-schema = { version = "0.14.0-beta1" }
cosmwasm-schema = { version = "0.14.0-beta2" }
6 changes: 3 additions & 3 deletions contracts/cw20-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ cw0 = { path = "../../packages/cw0", version = "0.6.0-alpha3" }
cw2 = { path = "../../packages/cw2", version = "0.6.0-alpha3" }
cw20 = { path = "../../packages/cw20", version = "0.6.0-alpha3" }
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.0-alpha3", features = ["iterator"] }
cosmwasm-std = { version = "0.14.0-beta1", features = ["iterator"] }
schemars = "0.7"
cosmwasm-std = { version = "0.14.0-beta2", features = ["iterator"] }
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.20" }

[dev-dependencies]
cosmwasm-schema = { version = "0.14.0-beta1" }
cosmwasm-schema = { version = "0.14.0-beta2" }
Loading