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

Expose cw20 logo and marketing info API on dso-token #38

Merged
merged 4 commits into from
Aug 10, 2021
Merged

Conversation

hashedone
Copy link
Collaborator

Closes #27

Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Just please remove the whitelist checks on the two update methods.

pub logo: Option<Logo>,
}

impl From<InstantiateMarketingInfo> for cw20_base::msg::InstantiateMarketingInfo {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use a different type as the root type doesn't have Debug, Clone, PartialEq, right?

After that is merged and released, you can just use the cw20_base type completely, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is the plan.

verify_sender_on_whitelist(&deps, &info.sender)?;
}

verify_sender_on_whitelist(&deps, &info.sender)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to check whitelist here.
We need the whitelist to move tokens, but it is not required if they just change the logo of the description.

It is likely they will be on the whitelist, but we can remove these two checks.

@@ -164,6 +161,7 @@ pub fn execute(
)
}
ExecuteMsg::UploadLogo(logo) => {
verify_sender_on_whitelist(&deps, &info.sender)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -202,11 +200,15 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
QueryMsg::AllAccounts { start_after, limit } => {
to_binary(&query_all_accounts(deps, start_after, limit)?)
}
QueryMsg::MarketingInfo {} => to_binary(&query_marketing_info(deps)?),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice query reuse

@@ -436,4 +442,163 @@ mod tests {
.unwrap();
assert!(!is_whitelisted.whitelisted);
}

#[test]
fn update_marketing() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to cover with tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we don't want to check for whitelist are those test needed at all? cw20 covers it pretty well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you can drop those tests.

}
);

let err = router
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this unauthorised check.
marketing can always adjust the logos regardless of whitelist

)
.unwrap_err();

assert_eq!(err, "Unauthorized".to_owned());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here... no need for unauthorised here

Copy link
Contributor

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@@ -30,7 +32,7 @@ pub fn instantiate(
decimals: msg.decimals,
initial_balances: msg.initial_balances,
mint: msg.mint,
marketing: None,
marketing: msg.marketing.map(Into::into),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-)

contracts/dso-token/src/msg.rs Outdated Show resolved Hide resolved
Comment on lines +7 to +10
pub project: Option<String>,
pub description: Option<String>,
pub marketing: Option<String>,
pub logo: Option<Logo>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong feelings, but shouldn't at least one of these (project?) be mandatory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not in original cw20 and I think it is nothing which would make it required. It is basically only for display, and if all are None, the whole structure would not be stored (which is handled in cw20).

@@ -3,7 +3,9 @@ use cosmwasm_std::{
};
use cw2::set_contract_version;
use cw20_base::allowances::query_allowance;
use cw20_base::contract::{query_balance, query_minter, query_token_info};
use cw20_base::contract::{
query_balance, query_download_logo, query_marketing_info, query_minter, query_token_info,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In passing: query_logo or download_logo instead of query_download_logo?

Copy link
Collaborator Author

@hashedone hashedone Aug 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unified convention in cw20_base - all functions called inside query (so partially taking care about handling query message) are in form of query_msg_enum_variant. I actually would strip this all query (possibly made a query as a submodule, but as it is cross-project change, I would leave it for now - especially that this would impact couple contracts already using cw20_base.

hashedone and others added 2 commits August 10, 2021 13:55
Co-authored-by: Mauro Lacy <maurolacy@users.noreply.github.com>
@ethanfrey ethanfrey merged commit 7dcfc0c into main Aug 10, 2021
@ethanfrey ethanfrey deleted the 27-logo-api branch August 10, 2021 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a logo for the Issued tokens
3 participants