Skip to content

Commit

Permalink
Add socials to world metadata (#1042)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev authored Oct 14, 2023
1 parent 4dcefb3 commit 119f096
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/dojo-world/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashMap;
use std::io::Cursor;
use std::path::PathBuf;

Expand Down Expand Up @@ -72,6 +73,8 @@ pub struct WorldMetadata {
pub description: Option<String>,
pub cover_uri: Option<Uri>,
pub icon_uri: Option<Uri>,
pub website: Option<Url>,
pub socials: HashMap<String, String>,
}

#[derive(Default, Deserialize, Clone, Debug)]
Expand Down
10 changes: 10 additions & 0 deletions crates/dojo-world/src/metadata_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use std::collections::HashMap;

use url::Url;

use super::WorldMetadata;
use crate::metadata::{Metadata, Uri};

Expand All @@ -18,6 +22,8 @@ name = "example"
description = "example world"
cover_uri = "file://example_cover.png"
icon_uri = "file://example_icon.png"
website = "https://dojoengine.org"
socials.twitter = "https://x.com/dojostarknet"
"#,
)
.unwrap();
Expand Down Expand Up @@ -48,6 +54,8 @@ icon_uri = "file://example_icon.png"
assert_eq!(world.description(), Some("example world"));
assert_eq!(world.cover_uri, Some(Uri::File("example_cover.png".into())));
assert_eq!(world.icon_uri, Some(Uri::File("example_icon.png".into())));
assert_eq!(world.website, Some(Url::parse("https://dojoengine.org").unwrap()));
assert_eq!(world.socials.get("twitter"), Some(&"https://x.com/dojostarknet".to_string()));
}

#[tokio::test]
Expand All @@ -57,6 +65,8 @@ async fn world_metadata_hash_and_upload() {
description: Some("A world used for testing".to_string()),
cover_uri: Some(Uri::File("src/metadata_test_data/cover.png".into())),
icon_uri: None,
website: Some(Url::parse("https://dojoengine.org").unwrap()),
socials: HashMap::from([("twitter".to_string(), "https://x.com/dojostarknet".to_string())]),
};

let _ = meta.upload().await.unwrap();
Expand Down

0 comments on commit 119f096

Please sign in to comment.