From 29031c9e67b89a849885d7162bb40e7ac849e7e4 Mon Sep 17 00:00:00 2001 From: Vlad Frolov Date: Sat, 2 Mar 2024 14:44:44 +0100 Subject: [PATCH] fix: Use bio_markdown instead of description for SocialDB profile description (#99) --- src/lib.rs | 19 ++++++++++++------- src/proposal/mod.rs | 2 +- tests/test_env.rs | 8 +++++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c5873811..50b91725 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -596,11 +596,11 @@ impl Contract { require!( self.has_moderator(editor_id.clone()) - || editor_id.clone() == env::current_account_id() - || current_timeline.is_draft() - && (proposal_body.timeline.is_empty_review() - || proposal_body.timeline.is_draft()) - || current_timeline.can_be_cancelled() && proposal_body.timeline.is_cancelled(), + || editor_id.clone() == env::current_account_id() + || current_timeline.is_draft() + && (proposal_body.timeline.is_empty_review() + || proposal_body.timeline.is_draft()) + || current_timeline.can_be_cancelled() && proposal_body.timeline.is_cancelled(), "This account is only allowed to change proposal status from DRAFT to REVIEW" ); @@ -827,7 +827,8 @@ impl Contract { require!(community.handle == handle, "Community handle cannot be changed"); require!(env::prepaid_gas() >= UPDATE_COMMUNITY_GAS, "Require at least 30 Tgas"); self.communities.insert(&handle, &community); - let community_page_link = format!("/devhub.near/widget/app?page=community&handle={}", community.handle); + let community_page_link = + format!("/devhub.near/widget/app?page=community&handle={}", community.handle); social_db_contract().with_unused_gas_weight(1).set(json!({ get_devhub_community_account(&community.handle): { "profile": { @@ -841,7 +842,11 @@ impl Contract { "telegram": community.telegram_handle, "website": format!("near.social{community_page_link}"), }, - "description": format!("{}\n\nLearn more about our community [on DevHub]({}).", community.description, community_page_link), + "description": format!( + "{}\n\nLearn more about our community [on DevHub]({}).", + community.bio_markdown.as_ref().unwrap_or(&community.description), + community_page_link + ), "backgroundImage": { "url": community.banner_url, }, diff --git a/src/proposal/mod.rs b/src/proposal/mod.rs index b078e899..3817bc80 100644 --- a/src/proposal/mod.rs +++ b/src/proposal/mod.rs @@ -151,4 +151,4 @@ pub enum ProposalFundingCurrency { USDT, USDC, OTHER, -} \ No newline at end of file +} diff --git a/tests/test_env.rs b/tests/test_env.rs index 3201bff0..2d19c680 100644 --- a/tests/test_env.rs +++ b/tests/test_env.rs @@ -1,4 +1,4 @@ -use near_sdk::{NearToken, AccountIdRef}; +use near_sdk::{AccountIdRef, NearToken}; use near_workspaces::network::Sandbox; use near_workspaces::types::{AccessKey, KeyType, SecretKey}; use near_workspaces::{Account, Worker}; @@ -7,13 +7,15 @@ use serde_json::json; const DEVHUB_CONTRACT_PREFIX: &str = "devhub"; const DEVHUB_CONTRACT: &AccountIdRef = AccountIdRef::new_or_panic("devhub.near"); -const DEVHUB_COMMUNITY_CONTRACT: &AccountIdRef = AccountIdRef::new_or_panic("community.devhub.near"); +const DEVHUB_COMMUNITY_CONTRACT: &AccountIdRef = + AccountIdRef::new_or_panic("community.devhub.near"); const COMMUNITY_FACTORY_PREFIX: &str = "community"; const NEAR_SOCIAL: &AccountIdRef = AccountIdRef::new_or_panic("social.near"); const _TEST_NEAR_SOCIAL: &AccountIdRef = AccountIdRef::new_or_panic("v1.social08.testnet"); const TEST_SEED: &str = "testificate"; const DEVHUB_CONTRACT_PATH: &str = "./target/near/devhub.wasm"; -const COMMUNITY_FACTORY_CONTRACT_PATH: &str = "./community-factory/target/near/devhub_community_factory.wasm"; +const COMMUNITY_FACTORY_CONTRACT_PATH: &str = + "./community-factory/target/near/devhub_community_factory.wasm"; #[allow(dead_code)] pub async fn init_contracts_from_mainnet() -> anyhow::Result {