Repository: public-awesome/launchpad
Pull request #508 (2023-02-19 17:47:41)

rename variables to improve readability

codecov[bot]: # [Codecov](https://codecov.io/gh/public-awesome/launchpad/pull/508?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=public-awesome) Report
Base: **75.91**% // Head: **75.92**% // Increases project coverage by **`+0.01%`** :tada:
> Coverage data is based on head [(`d128468`)](https://codecov.io/gh/public-awesome/launchpad/pull/508?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=public-awesome) compared to base [(`c61254f`)](https://codecov.io/gh/public-awesome/launchpad/commit/c61254f2e9f29f3343116d61dea9916a17bf7f1a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=public-awesome).
> Patch coverage: 100.00% of modified lines in pull request are covered.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main     #508      +/-   ##
==========================================
+ Coverage   75.91%   75.92%   +0.01%     
==========================================
  Files          59       59              
  Lines        2225     2226       +1     
==========================================
+ Hits         1689     1690       +1     
  Misses        536      536              
```


| [Impacted Files](https://codecov.io/gh/public-awesome/launchpad/pull/508?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=public-awesome) | Coverage Δ | |
|---|---|---|
| [contracts/sg721-base/src/contract.rs](https://codecov.io/gh/public-awesome/launchpad/pull/508?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=public-awesome#diff-Y29udHJhY3RzL3NnNzIxLWJhc2Uvc3JjL2NvbnRyYWN0LnJz) | `68.88% <100.00%> (+0.17%)` | :arrow_up: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=public-awesome). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=public-awesome)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/public-awesome/launchpad/pull/508?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=public-awesome).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=public-awesome).

github-actions[bot]: <h1>Cosm-Orc Gas Usage</h1> 
 
 No gas diff larger than 0.5% 
 
 <details><summary>Raw Report for d128468270801f95a6216b24810c3660994d9e31 </summary><br/> 

| Contract | Op Name | Gas Used | Gas Wanted | File | 
 | --- | --- | --- | --- | --- |
| vending_factory | Instantiate__factory_inst | 184067 | 253034 | e2e/src/helpers/helper.rs:35 |
| vending_factory | Execute__factory_exec_minter_inst_w_trading_time | 3848345 | 5749314 | e2e/src/tests/factory_test.rs:244 |
| vending_factory | Store__Store | 2694998 | 4019357 | e2e/src/helpers/chain.rs:78 |
| vending_factory | Execute__factory_exec_minter_inst | 34027941 | 51018702 | e2e/src/tests/factory_test.rs:98 |
| multiple_contracts | Execute__minter_batch_exec_mint_token_w_trading_time | 1938975 | 2879615 | e2e/src/tests/factory_test.rs:314 |
| multiple_contracts | Execute__minter_batch_exec_mint_token | 18751975 | 28115355 | e2e/src/tests/factory_test.rs:164 |
| base_factory | Store__Store | 2489897 | 3711705 | e2e/src/helpers/chain.rs:78 |
| base_minter | Store__Store | 6925804 | 10365501 | e2e/src/helpers/chain.rs:78 |
| sg721_base | Store__Store | 7877969 | 11793753 | e2e/src/helpers/chain.rs:78 |
| sg721_metadata_onchain | Store__Store | 8363376 | 12521864 | e2e/src/helpers/chain.rs:78 |
| sg721_nt | Store__Store | 7454481 | 11158521 | e2e/src/helpers/chain.rs:78 |
| sg_eth_airdrop | Store__Store | 3209811 | 4791576 | e2e/src/helpers/chain.rs:78 |
| sg_splits | Store__Store | 2781162 | 4148603 | e2e/src/helpers/chain.rs:78 |
| sg_whitelist | Store__Store | 3449544 | 5151176 | e2e/src/helpers/chain.rs:78 |
| vending_minter | Store__Store | 8270036 | 12381854 | e2e/src/helpers/chain.rs:78 |
| whitelist_immutable | Store__Store | 2139222 | 3185693 | e2e/src/helpers/chain.rs:78 |
</details>

Patch:
diff --git a/contracts/sg721-base/src/contract.rs b/contracts/sg721-base/src/contract.rs
index ba62e93c..44a74b02 100644
--- a/contracts/sg721-base/src/contract.rs
+++ b/contracts/sg721-base/src/contract.rs
@@ -197,22 +197,24 @@ where
 
         // convert collection royalty info to response for comparison
         // convert from response to royalty info for storage
-        let royalty_info_res = collection
+        let current_royalty_info = collection
             .royalty_info
             .as_ref()
             .map(|royalty_info| royalty_info.to_response());
 
-        let response = collection_msg
+        let new_royalty_info = collection_msg
             .royalty_info
-            .unwrap_or_else(|| royalty_info_res.clone());
+            .unwrap_or_else(|| current_royalty_info.clone());
 
         // reminder: collection_msg.royalty_info is Option<Option<RoyaltyInfoResponse>>
-        collection.royalty_info = if let Some(royalty_info) = response {
+        collection.royalty_info = if let Some(royalty_info) = new_royalty_info {
             // update royalty info to equal or less, else throw error
-            if let Some(royalty_info_res) = royalty_info_res {
+            if let Some(royalty_info_res) = current_royalty_info {
                 if royalty_info.share > royalty_info_res.share {
                     return Err(ContractError::RoyaltyShareIncreased {});
                 }
+            } else {
+                return Err(ContractError::RoyaltyShareIncreased {});
             }
 
             Some(RoyaltyInfo {


Test patch:
diff --git a/test-suite/src/sg721_base/tests/integration_tests.rs b/test-suite/src/sg721_base/tests/integration_tests.rs
index c7e477c3..8bf8a651 100644
--- a/test-suite/src/sg721_base/tests/integration_tests.rs
+++ b/test-suite/src/sg721_base/tests/integration_tests.rs
@@ -74,7 +74,6 @@ mod tests {
         let cosmos_msg = factory_contract.call_with_funds(msg, creation_fee).unwrap();
 
         let res = app.execute(Addr::unchecked(ADMIN), cosmos_msg);
-        dbg!("{:?}", &res);
         assert!(res.is_ok());
 
         (app, Addr::unchecked("contract2"))
@@ -105,7 +104,6 @@ mod tests {
         let cosmos_msg = factory_contract.call_with_funds(msg, creation_fee).unwrap();
 
         let res = app.execute(Addr::unchecked(ADMIN), cosmos_msg);
-        dbg!("{:?}", &res);
         assert!(res.is_ok());
 
         (app, Addr::unchecked("contract2"))
@@ -248,6 +246,36 @@ mod tests {
         use super::*;
         use sg721_base::msg::{CollectionInfoResponse, QueryMsg};
 
+        #[test]
+        fn royalty_updates() {
+            let mut params = mock_collection_params();
+            params.info.external_link = None;
+            params.info.royalty_info = None;
+            let custom_create_minter_msg =
+                mock_create_minter_init_msg(params, mock_init_extension(None, None));
+            let (mut app, contract) = custom_proper_instantiate(custom_create_minter_msg);
+            let creator = Addr::unchecked("creator".to_string());
+
+            let royalty_info: Option<RoyaltyInfoResponse> = Some(RoyaltyInfoResponse {
+                payment_address: creator.to_string(),
+                share: Decimal::percent(11),
+            });
+            let res = app.execute_contract(
+                creator,
+                contract,
+                &Sg721ExecuteMsg::<Empty, Empty>::UpdateCollectionInfo {
+                    collection_info: UpdateCollectionInfoMsg {
+                        description: None,
+                        image: None,
+                        external_link: None,
+                        explicit_content: None,
+                        royalty_info: Some(royalty_info),
+                    },
+                },
+                &[],
+            );
+            assert!(res.is_err());
+        }
         #[test]
         fn update_collection_info() {
             // customize params so external_link is None