-
Notifications
You must be signed in to change notification settings - Fork 359
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
Cw20 logo spec #370
Merged
Merged
Cw20 logo spec #370
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"$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<u8> 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<u8>", | ||
"type": "string" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"$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", | ||
"type": [ | ||
"string", | ||
"null" | ||
] | ||
}, | ||
"project": { | ||
"description": "A URL pointing to the project behind this token.", | ||
"type": [ | ||
"string", | ||
"null" | ||
] | ||
} | ||
}, | ||
"definitions": { | ||
"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", | ||
"anyOf": [ | ||
{ | ||
"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 | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use cosmwasm_std::Binary; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// This is used for uploading logo data, or setting it in InstantiateData | ||
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum Logo { | ||
/// A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL. | ||
Url(String), | ||
/// Logo content stored on the blockchain. Enforce maximum size of 5KB on all variants | ||
Embedded(EmbeddedLogo), | ||
} | ||
|
||
/// This is used to store the logo on the blockchain in an accepted format. | ||
/// Enforce maximum size of 5KB on all variants. | ||
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum EmbeddedLogo { | ||
/// 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) | ||
Svg(Binary), | ||
/// Store the Logo as a PNG file. This will likely only support up to 64x64 or so | ||
/// within the 5KB limit. | ||
Png(Binary), | ||
} | ||
|
||
/// This is used to display logo info, provide a link or inform there is one | ||
/// that can be downloaded from the blockchain itself | ||
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum LogoInfo { | ||
/// A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL. | ||
Url(String), | ||
/// There is an embedded logo on the chain, make another call to download it. | ||
Embedded, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being honest I find this method even more dangerous as passing URL. Someone needs to download the binary image (in particular PNG, SVG is easier to verify) and then display it, but if image is malicious I can imagine that bug in displaying it might be vulnerability - but I would believe, that both
<img>
and css image embedding is pretty much well tested in modern browsers and should not be dangerous.