Skip to content

Commit

Permalink
Change the hashing algo to keccak marketplace v2
Browse files Browse the repository at this point in the history
  • Loading branch information
tasiov committed Apr 19, 2024
1 parent e8f7476 commit dd02d4e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

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

29 changes: 13 additions & 16 deletions contracts/stargaze-marketplace-v2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ homepage = { workspace = true }
repository = { workspace = true }
license = { workspace = true }

exclude = [
"contract.wasm",
"hash.txt",
]
exclude = ["contract.wasm", "hash.txt"]


[lib]
Expand All @@ -28,30 +25,30 @@ doc = false

[features]
backtraces = ["cosmwasm-std/backtraces"]
library = []
library = []

[dependencies]
cosmwasm-schema = "1.5.3"
cosmwasm-std = { version = "1.5.3" }
cosmwasm-std = { version = "1.5.3" }
cw-address-like = "1.0.4"
cw-storage-plus = "1.2.0"
cw-utils = "1.0.3"
cw2 = "1.1.2"
cw721 = "0.18.0"

sg-marketplace-common = { path = "../../packages/sg-marketplace-common" }
sg-index-query = "0.1.1"
sg-marketplace-common = { path = "../../packages/sg-marketplace-common" }
sg-index-query = "0.1.1"

serde = "1.0.196"
semver = "1.0.21"
thiserror = "1.0.56"
sha2 = "0.10.0"
digest = "0.10.0"
sha3 = "0.10"

[dev-dependencies]
cw-multi-test = "0.20.0"
cw721-base = { version = "0.18.0", features = ["library"] }
stargaze-royalty-registry = { git = "https://github.com/public-awesome/core.git", rev = "d41ce961481322557313635a863991cb4856a261", package = "stargaze-royalty-registry", features = ["library"] }
cute = "0.3.0"
anyhow = "1.0.79"

cw-multi-test = "0.20.0"
cw721-base = { version = "0.18.0", features = ["library"] }
stargaze-royalty-registry = { git = "https://github.com/public-awesome/core.git", rev = "d41ce961481322557313635a863991cb4856a261", package = "stargaze-royalty-registry", features = [
"library",
] }
cute = "0.3.0"
anyhow = "1.0.79"
4 changes: 2 additions & 2 deletions contracts/stargaze-marketplace-v2/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use sg_marketplace_common::{
nft::transfer_nft, royalties::fetch_or_set_royalties, sale::NftSaleProcessor,
MarketplaceStdError,
};
use sha2::{Digest, Sha256};
use sha3::{Digest, Keccak256};
use std::{cmp::min, ops::Sub};

pub fn build_collection_token_index_str(collection: &str, token_id: &TokenId) -> String {
Expand All @@ -20,7 +20,7 @@ pub fn build_collection_token_index_str(collection: &str, token_id: &TokenId) ->
}

pub fn generate_id(components: Vec<&[u8]>) -> String {
let mut hasher = Sha256::new();
let mut hasher = Keccak256::new();
for component in components {
hasher.update(component);
}
Expand Down
11 changes: 7 additions & 4 deletions contracts/stargaze-marketplace-v2/src/tests/unit_tests/sales.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,10 @@ fn try_sale_fee_breakdown() {
let protocol_reward_event = find_attrs(app_response.clone(), "wasm-finalize-sale", "protocol")
.pop()
.unwrap();
assert_eq!(protocol_reward_event, protocol_reward_coin.to_string());
assert_eq!(
protocol_reward_event,
protocol_reward_coin.amount.to_string()
);

// Verify maker reward
let maker_reward_coin = coin(maker_reward.u128(), NATIVE_DENOM);
Expand All @@ -670,7 +673,7 @@ fn try_sale_fee_breakdown() {
let maker_reward_event = find_attrs(app_response.clone(), "wasm-finalize-sale", "maker")
.pop()
.unwrap();
assert_eq!(maker_reward_event, maker_reward_coin.to_string());
assert_eq!(maker_reward_event, maker_reward_coin.amount.to_string());

// Verify taker reward
let taker_reward_coin = coin(taker_reward.u128(), NATIVE_DENOM);
Expand All @@ -681,7 +684,7 @@ fn try_sale_fee_breakdown() {
let taker_reward_event = find_attrs(app_response.clone(), "wasm-finalize-sale", "taker")
.pop()
.unwrap();
assert_eq!(taker_reward_event, taker_reward_coin.to_string());
assert_eq!(taker_reward_event, taker_reward_coin.amount.to_string());

// Verify seller reward
let seller_coin = coin(seller_amount.u128(), NATIVE_DENOM);
Expand All @@ -692,7 +695,7 @@ fn try_sale_fee_breakdown() {
let seller_event = find_attrs(app_response.clone(), "wasm-finalize-sale", "seller")
.pop()
.unwrap();
assert_eq!(seller_event, seller_coin.to_string());
assert_eq!(seller_event, seller_coin.amount.to_string());

// Verify bidder paid
assert_eq!(
Expand Down

0 comments on commit dd02d4e

Please sign in to comment.