Skip to content

Commit

Permalink
feat: save and get labels on sx spaces and proposals (#864)
Browse files Browse the repository at this point in the history
* feat: Index labels on spaces

* fix typecheck

* fix tests

* Index labels on sx proposals

* Store labels as array of strings

* remove API related changes

* Update apps/ui/src/networks/common/graphqlApi/index.ts

Co-authored-by: Wiktor Tkaczyński <wiktor.tkaczynski@gmail.com>

* Update apps/ui/src/networks/common/graphqlApi/index.ts

Co-authored-by: Wiktor Tkaczyński <wiktor.tkaczynski@gmail.com>

---------

Co-authored-by: Wiktor Tkaczyński <wiktor.tkaczynski@gmail.com>
  • Loading branch information
ChaituVR and Sekhmet authored Oct 24, 2024
1 parent 0997e54 commit 96fe9c4
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 2 deletions.
16 changes: 16 additions & 0 deletions apps/ui/src/helpers/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ describe('utils', () => {
address: '0x000000000000000000000000000000000000dead'
}
],
labels: [
{
id: 'test',
name: 'Test',
description: 'Test description',
color: '#000000'
}
],
delegations: [
{
name: 'sample',
Expand Down Expand Up @@ -102,6 +110,14 @@ describe('utils', () => {
address: '0x000000000000000000000000000000000000dead'
}
],
labels: [
{
id: 'test',
name: 'Test',
description: 'Test description',
color: '#000000'
}
],
delegations: [
{
name: 'sample',
Expand Down
6 changes: 6 additions & 0 deletions apps/ui/src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ export function createErc1155Metadata(
network: treasury.network,
address: treasury.address
})),
labels: metadata.labels?.map(label => ({
id: label.id,
name: label.name,
description: label.description,
color: label.color
})),
delegations: metadata.delegations.map(delegation => ({
name: delegation.name,
api_type: delegation.apiType,
Expand Down
6 changes: 5 additions & 1 deletion apps/ui/src/networks/common/graphqlApi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ function formatSpace(
chainId: CHAIN_IDS[network]
};
}),
labels: space.metadata.labels.map(label => {
const { id, name, description, color } = JSON.parse(label);
return { id, name, description, color };
}),
delegations: space.metadata.delegations.map(delegation => {
const { name, api_type, api_url, contract } = JSON.parse(delegation);

Expand Down Expand Up @@ -255,7 +259,7 @@ function formatProposal(
metadata_uri: proposal.metadata.id,
type: 'basic',
choices: BASIC_CHOICES,
labels: [],
labels: proposal.metadata.labels,
scores: [proposal.scores_1, proposal.scores_2, proposal.scores_3],
title: proposal.metadata.title ?? '',
body: proposal.metadata.body ?? '',
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/src/networks/common/graphqlApi/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const SPACE_FRAGMENT = gql`
discord
voting_power_symbol
treasuries
labels
delegations
executors
executors_types
Expand Down Expand Up @@ -122,6 +123,7 @@ const PROPOSAL_FRAGMENT = gql`
body
discussion
execution
labels
}
start
min_end
Expand Down
3 changes: 3 additions & 0 deletions apps/ui/src/networks/common/graphqlApi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type ApiSpace = {
executors_destinations: string[];
executors_strategies: ApiExecutorStrategy[];
treasuries: string[];
labels: string[];
delegations: string[];
};
controller: string;
Expand Down Expand Up @@ -71,6 +72,7 @@ export type ApiProposal = {
body: string | null;
discussion: string | null;
execution: string | null;
labels: string[];
};
space: {
id: string;
Expand All @@ -80,6 +82,7 @@ export type ApiProposal = {
avatar: string;
voting_power_symbol: string;
treasuries: string[];
labels: string[];
executors: string[];
executors_types: string[];
executors_strategies: ApiExecutorStrategy[];
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/src/networks/evm/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export function createActions(
type,
app: app || EDITOR_APP_NAME,
choices: choices.filter(c => !!c),
labels,
execution: executionInfo?.transactions ?? []
});
if (!pinned || !pinned.cid) return false;
Expand Down Expand Up @@ -323,6 +324,7 @@ export function createActions(
discussion,
type,
choices: choices.filter(c => !!c),
labels,
execution: executionInfo?.transactions ?? []
});
if (!pinned || !pinned.cid) return false;
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/src/networks/starknet/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export function createActions(
type,
app: app || EDITOR_APP_NAME,
choices: choices.filter(c => !!c),
labels,
execution: executionInfo?.transactions ?? []
});
if (!pinned || !pinned.cid) return false;
Expand Down Expand Up @@ -341,6 +342,7 @@ export function createActions(
discussion,
type,
choices: choices.filter(c => !!c),
labels,
execution: executionInfo?.transactions ?? []
});
if (!pinned || !pinned.cid) return false;
Expand Down
1 change: 1 addition & 0 deletions apps/ui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export type SpaceMetadata = {
discord: string;
votingPowerSymbol: string;
treasuries: SpaceMetadataTreasury[];
labels: SpaceMetadataLabel[];
delegations: SpaceMetadataDelegation[];
};

Expand Down
1 change: 1 addition & 0 deletions apps/ui/src/views/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const metadataForm: SpaceMetadata = reactive(
discord: '',
votingPowerSymbol: '',
treasuries: [],
labels: [],
delegations: []
})
);
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/views/Space/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const tabs = computed<Tab[]>(
{
id: 'labels',
name: 'Labels',
visible: isOffchainNetwork.value
visible: true
},
{
id: 'execution',
Expand Down

0 comments on commit 96fe9c4

Please sign in to comment.