From df9b82ab5fcff681ae57acc0182c60c838293011 Mon Sep 17 00:00:00 2001 From: Tushar Ojha Date: Wed, 21 Jun 2023 17:32:53 +0530 Subject: [PATCH 1/3] added dappforce notice file --- NOTICE.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 NOTICE.md diff --git a/NOTICE.md b/NOTICE.md new file mode 100644 index 0000000..156a3e8 --- /dev/null +++ b/NOTICE.md @@ -0,0 +1,10 @@ +# NOTICE +subsocial-js — JavaScript SDK for Subsocial blockchain. — by DAPPFORCE PTE. LTD. + +Copyright (C) 2021-2023 DAPPFORCE PTE. LTD. + +This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at https://github.com/dappforce/subsocial-js/blob/master/LICENSE. + +You should have received a copy of the GNU General Public License along with this program. If not, see . \ No newline at end of file From 841f38e6d654a967c18ae928ff0d4d2abc440ad4 Mon Sep 17 00:00:00 2001 From: mckrava Date: Wed, 11 Oct 2023 13:01:46 +0300 Subject: [PATCH 2/3] feat: added space to social schema --- packages/resource-discussions/src/graph.ts | 4 ++++ packages/resource-discussions/src/types/social.ts | 12 ++++++++++-- .../tests/resourceLinking.test.ts | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/resource-discussions/src/graph.ts b/packages/resource-discussions/src/graph.ts index 682f8ca..ce739b3 100644 --- a/packages/resource-discussions/src/graph.ts +++ b/packages/resource-discussions/src/graph.ts @@ -151,6 +151,10 @@ export class ResourceGraph { socialResourceTypes.profile, socialResourceValues.id ) + this.graph.addDirectedEdge( + socialResourceTypes.space, + socialResourceValues.id + ) /** * Chain diff --git a/packages/resource-discussions/src/types/social.ts b/packages/resource-discussions/src/types/social.ts index 16fcc8a..bddb85e 100644 --- a/packages/resource-discussions/src/types/social.ts +++ b/packages/resource-discussions/src/types/social.ts @@ -1,10 +1,11 @@ import { socialApps } from '../constants' -type SocialResourceType = 'post' | 'profile' +type SocialResourceType = 'post' | 'profile' | 'space' export const socialResourceTypes = { post: 'post', - profile: 'profile' + profile: 'profile', + space: 'space' } as const export const socialResourceValueRequiredState = { @@ -19,6 +20,8 @@ export type SocialResourceValue = R extends 'post' ? { id: string } : R extends 'profile' ? { id: string } + : R extends 'space' + ? { id: string } : never type SocialPostResourceType = { @@ -29,10 +32,15 @@ type SocialProfileResourceType = { resourceType: 'profile' resourceValue: SocialResourceValue<'profile'> } +type SocialSpaceResourceType = { + resourceType: 'space' + resourceValue: SocialResourceValue<'space'> +} type SocialResourceTypeValue = | SocialPostResourceType | SocialProfileResourceType + | SocialSpaceResourceType export type SocialSchemaParameters = { schema: 'social' } & { app: (typeof socialApps)[number] | string diff --git a/packages/resource-discussions/tests/resourceLinking.test.ts b/packages/resource-discussions/tests/resourceLinking.test.ts index 2f5f69a..297ef54 100644 --- a/packages/resource-discussions/tests/resourceLinking.test.ts +++ b/packages/resource-discussions/tests/resourceLinking.test.ts @@ -139,4 +139,19 @@ describe('Resource Linking Unit', () => { 'Provided parameters for resource are invalid. Please, check field "schema".' ) }) + + test('SocialResource should ingest parameters with "schema === social"', () => { + const resourceValue: Resource = new Resource({ + schema: 'social', + app: 'subid', + resourceType: 'space', + resourceValue: { + id: 'spaceId' + } + }) + + expect(resourceValue.toResourceId()).toEqual( + 'social://app:subid/resourceType:space/id:spaceId' + ) + }) }) From ebdc0348d19c0650bf8569ba90240d3c6d934865 Mon Sep 17 00:00:00 2001 From: mckrava Date: Wed, 11 Oct 2023 13:26:08 +0300 Subject: [PATCH 3/3] feat: added creator to substrate chains --- packages/resource-discussions/src/constants.ts | 4 +++- packages/resource-discussions/src/graph.ts | 4 ++++ packages/resource-discussions/src/types/chain.ts | 12 +++++++++++- .../resource-discussions/src/utiils/chainUtils.ts | 1 + .../tests/resourceLinking.test.ts | 13 +++++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/resource-discussions/src/constants.ts b/packages/resource-discussions/src/constants.ts index 5fc8495..04cfede 100644 --- a/packages/resource-discussions/src/constants.ts +++ b/packages/resource-discussions/src/constants.ts @@ -31,5 +31,7 @@ export const socialApps = [ 'medium', 'github', 'reddit', - 'linkedin' + 'linkedin', + 'subid', + 'polkaverse', ] as const diff --git a/packages/resource-discussions/src/graph.ts b/packages/resource-discussions/src/graph.ts index ce739b3..77c3615 100644 --- a/packages/resource-discussions/src/graph.ts +++ b/packages/resource-discussions/src/graph.ts @@ -204,6 +204,10 @@ export class ResourceGraph { chainResourceTypes.market, chainResourceValues.id ) + this.graph.addDirectedEdge( + chainResourceTypes.creator, + chainResourceValues.id + ) return this } diff --git a/packages/resource-discussions/src/types/chain.ts b/packages/resource-discussions/src/types/chain.ts index 32f9ec3..afc1ab1 100644 --- a/packages/resource-discussions/src/types/chain.ts +++ b/packages/resource-discussions/src/types/chain.ts @@ -7,7 +7,8 @@ export const chainResourceTypes = { account: 'account', proposal: 'proposal', market: 'market', - nft: 'nft' + nft: 'nft', + creator: 'creator' } as const export const chainResourceValueRequiredState = { @@ -49,6 +50,7 @@ type ChainResourceType = | 'proposal' | 'market' | 'nft' + | 'creator' export type ChainResourceValue = R extends 'block' ? { blockNumber: BlockNumber } @@ -62,6 +64,8 @@ export type ChainResourceValue = R extends 'block' ? { id: Id } : R extends 'market' ? { id: Id } + : R extends 'creator' + ? { id: Id } : R extends 'nft' ? { collectionId: CollectionId; nftId?: NftId; standard?: Standard } : never @@ -100,6 +104,11 @@ type ChainNftResourceType = { resourceValue: ChainResourceValue<'nft'> } +type ChainCreatorResourceType = { + resourceType: 'creator' + resourceValue: ChainResourceValue<'creator'> +} + type ChainResourceTypeValueBase = | ChainBlockResourceType | ChainNftResourceType @@ -111,6 +120,7 @@ type SubstrateChainResourceTypeValue = | ChainResourceTypeValueBase | ChainMarkerResourceType | ChainProposalResourceType + | ChainCreatorResourceType type EvmChainResourceTypeValue = ChainResourceTypeValueBase type AnyChainResourceTypeValue = diff --git a/packages/resource-discussions/src/utiils/chainUtils.ts b/packages/resource-discussions/src/utiils/chainUtils.ts index 499e78c..bff780d 100644 --- a/packages/resource-discussions/src/utiils/chainUtils.ts +++ b/packages/resource-discussions/src/utiils/chainUtils.ts @@ -75,6 +75,7 @@ export function initChainSubstrateAllNodesEdges(graph: Graph) { graph.addDirectedEdge(chainName, chainResourceTypes.token) graph.addDirectedEdge(chainName, chainResourceTypes.nft) graph.addDirectedEdge(chainName, chainResourceTypes.proposal) + graph.addDirectedEdge(chainName, chainResourceTypes.creator) if (chainName === 'zeitgeist') graph.addDirectedEdge(chainName, chainResourceTypes.market) }) diff --git a/packages/resource-discussions/tests/resourceLinking.test.ts b/packages/resource-discussions/tests/resourceLinking.test.ts index 297ef54..b25eb34 100644 --- a/packages/resource-discussions/tests/resourceLinking.test.ts +++ b/packages/resource-discussions/tests/resourceLinking.test.ts @@ -150,6 +150,19 @@ describe('Resource Linking Unit', () => { } }) + const resourceCreator: Resource = new Resource({ + schema: 'chain', + chainType: 'substrate', + chainName: 'subsocial', + resourceType: 'creator', + resourceValue: { + id: 'spaceId' + } + }) + + expect(resourceCreator.toResourceId()).toEqual( + 'chain://chainType:substrate/chainName:subsocial/resourceType:creator/id:spaceId' + ) expect(resourceValue.toResourceId()).toEqual( 'social://app:subid/resourceType:space/id:spaceId' )