Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Feature: Safe apps social links (#1053)
Browse files Browse the repository at this point in the history
add safe app social profiles
  • Loading branch information
mmv08 authored Jan 24, 2023
1 parent e6b35f2 commit a5717c8
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 3 deletions.
29 changes: 29 additions & 0 deletions src/common/converters/tests/safe_app.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::common::models::backend::safe_apps::SafeApp as BackendSafeApp;
use crate::routes::safe_apps::models::{
SafeApp, SafeAppAccessControlPolicies, SafeAppDomainAllowlistPolicy, SafeAppProvider,
SafeAppSocialProfile,
};

#[test]
Expand Down Expand Up @@ -41,6 +42,13 @@ fn safe_apps_several_apps() {
access_control: SafeAppAccessControlPolicies::NoRestrictions,
tags: vec!["tag1".to_string()],
features: vec![],
developer_website: Some("https://curve.fi".to_string()),
social_profiles: vec![
SafeAppSocialProfile {
platform: "TWITTER".to_string(),
url: "https://twitter.com/curvefinance".to_string(),
},
],
},
SafeApp {
id: 24,
Expand All @@ -51,6 +59,8 @@ fn safe_apps_several_apps() {
chain_ids: vec!["1".to_string(), "4".to_string(),"10".to_string(),"56".to_string(),"100".to_string(),"137".to_string(),"246".to_string(), "42161".to_string(), "43114".to_string(), "73799".to_string()],
provider: None,
access_control: SafeAppAccessControlPolicies::NoRestrictions,
developer_website: None,
social_profiles: vec![],
tags: vec!["tag2".to_string()],
features: vec![],
},
Expand All @@ -70,6 +80,21 @@ fn safe_apps_several_apps() {
}),
tags: vec![],
features: vec!["BATCHED_TRANSACTIONS".to_string()],
developer_website: Some("https://1inch.io/".to_string()),
social_profiles: vec![
SafeAppSocialProfile {
platform: "TWITTER".to_string(),
url: "https://twitter.com/1inchExchange".to_string(),
},
SafeAppSocialProfile {
platform: "DISCORD".to_string(),
url: "https://discord.gg/1inch".to_string(),
},
SafeAppSocialProfile {
platform: "GITHUB".to_string(),
url: "https://github.com/1inch".to_string(),
}
],
},
SafeApp {
id: 30,
Expand All @@ -82,6 +107,8 @@ fn safe_apps_several_apps() {
access_control: SafeAppAccessControlPolicies::NoRestrictions,
tags: vec![],
features: vec![],
developer_website: None,
social_profiles: vec![],
},
SafeApp {
id: 25,
Expand All @@ -92,6 +119,8 @@ fn safe_apps_several_apps() {
chain_ids: vec!["1".to_string(), "4".to_string(), "10".to_string(),"56".to_string(),"100".to_string(),"137".to_string(),"246".to_string(), "73799".to_string(), "42161".to_string(), "43114".to_string()],
provider: None,
access_control: SafeAppAccessControlPolicies::NoRestrictions,
developer_website: None,
social_profiles: vec![],
tags: vec!["tag1".to_string(), "tag2".to_string()],
features: vec![],
},
Expand Down
9 changes: 9 additions & 0 deletions src/common/models/backend/safe_apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ pub struct SafeApp {
#[serde(default)]
pub tags: Vec<String>,
pub features: Vec<String>,
pub developer_website: Option<String>,
pub social_profiles: Vec<SafeAppSocialProfile>,
}

#[derive(Deserialize, Debug, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
pub struct SafeAppSocialProfile {
pub platform: String,
pub url: String,
}

#[derive(Deserialize, Debug, PartialEq, Clone)]
Expand Down
10 changes: 10 additions & 0 deletions src/routes/safe_apps/converters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::common::models::backend::safe_apps::{
};
use crate::routes::safe_apps::models::{
SafeApp, SafeAppAccessControlPolicies, SafeAppDomainAllowlistPolicy, SafeAppProvider,
SafeAppSocialProfile,
};

impl From<BackendSafeApp> for SafeApp {
Expand Down Expand Up @@ -34,6 +35,15 @@ impl From<BackendSafeApp> for SafeApp {
_ => SafeAppAccessControlPolicies::Unknown,
},
tags: safe_app.tags,
developer_website: safe_app.developer_website,
social_profiles: safe_app
.social_profiles
.into_iter()
.map(|profile| SafeAppSocialProfile {
platform: profile.platform.to_string(),
url: profile.url.to_string(),
})
.collect(),
features: safe_app.features,
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/routes/safe_apps/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ pub struct SafeApp {
#[serde(default)]
pub tags: Vec<String>,
pub features: Vec<String>,
pub developer_website: Option<String>,
pub social_profiles: Vec<SafeAppSocialProfile>,
}

#[derive(Serialize, Debug, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(test, derive(serde::Deserialize))]
pub struct SafeAppSocialProfile {
pub platform: String,
pub url: String,
}

#[derive(Serialize, Debug, PartialEq, Clone)]
Expand Down
30 changes: 29 additions & 1 deletion src/routes/safe_apps/tests/json/response_safe_apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
"accessControl": {
"type": "NO_RESTRICTIONS"
},
"developerWebsite": "https://curve.fi",
"socialProfiles": [
{
"platform": "TWITTER",
"url": "https://twitter.com/curvefinance"
}
],
"tags": [
"tag1"
],
Expand Down Expand Up @@ -40,6 +47,8 @@
"accessControl": {
"type": "NO_RESTRICTIONS"
},
"developerWebsite": null,
"socialProfiles": [],
"tags": [
"tag2"
],
Expand All @@ -60,6 +69,21 @@
"type": "DOMAIN_ALLOWLIST",
"value": ["https://gnosis-safe.io", "https://dev.gnosis-safe.io"]
},
"developerWebsite": "https://1inch.io/",
"socialProfiles": [
{
"platform": "TWITTER",
"url": "https://twitter.com/1inchExchange"
},
{
"platform": "DISCORD",
"url": "https://discord.gg/1inch"
},
{
"platform": "GITHUB",
"url": "https://github.com/1inch"
}
],
"tags": [],
"features": ["BATCHED_TRANSACTIONS"]
},
Expand All @@ -75,7 +99,9 @@
"type": "NO_RESTRICTIONS"
},
"tags": [],
"features": []
"features": [],
"developerWebsite": null,
"socialProfiles": []
},
{
"id": 25,
Expand All @@ -99,6 +125,8 @@
"accessControl": {
"type": "NO_RESTRICTIONS"
},
"developerWebsite": null,
"socialProfiles": [],
"tags": [
"tag1",
"tag2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"accessControl": {
"type": "NO_RESTRICTIONS"
},
"developerWebsite": null,
"tags": [],
"socialProfiles": [],
"features": []
}
]
4 changes: 3 additions & 1 deletion src/tests/json/safe_apps/polygon_safe_app_url_query.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"type": "NO_RESTRICTIONS"
},
"tags": [],
"features": []
"features": [],
"developerWebsite": null,
"socialProfiles": []
}
]
30 changes: 29 additions & 1 deletion src/tests/json/safe_apps/polygon_safe_apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
"accessControl": {
"type": "NO_RESTRICTIONS"
},
"developerWebsite": "https://curve.fi",
"socialProfiles": [
{
"platform": "TWITTER",
"url": "https://twitter.com/curvefinance"
}
],
"tags": [
"tag1"
],
Expand All @@ -29,6 +36,8 @@
"accessControl": {
"type": "NO_RESTRICTIONS"
},
"developerWebsite": null,
"socialProfiles": [],
"tags": ["tag2"],
"features": []
},
Expand All @@ -47,6 +56,21 @@
"type": "DOMAIN_ALLOWLIST",
"value": ["https://gnosis-safe.io", "https://dev.gnosis-safe.io"]
},
"developerWebsite": "https://1inch.io/",
"socialProfiles": [
{
"platform": "TWITTER",
"url": "https://twitter.com/1inchExchange"
},
{
"platform": "DISCORD",
"url": "https://discord.gg/1inch"
},
{
"platform": "GITHUB",
"url": "https://github.com/1inch"
}
],
"tags": [],
"features": ["BATCHED_TRANSACTIONS"]
},
Expand All @@ -62,7 +86,9 @@
"type": "NO_RESTRICTIONS"
},
"tags": [],
"features": []
"features": [],
"developerWebsite": null,
"socialProfiles": []
},
{
"id": 25,
Expand All @@ -75,6 +101,8 @@
"accessControl": {
"type": "NO_RESTRICTIONS"
},
"developerWebsite": null,
"socialProfiles": [],
"tags": ["tag1", "tag2"],
"features": []
}
Expand Down

0 comments on commit a5717c8

Please sign in to comment.