Skip to content

Commit

Permalink
Merge branch 'master' into fix-clear-delegation-button-not-hidding-wh…
Browse files Browse the repository at this point in the history
…en-irrelevant
  • Loading branch information
wa0x6e authored Dec 1, 2024
2 parents 6578cde + 8f47858 commit 9347d57
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<a href="https://discord.snapshot.org/">
<img src="https://img.shields.io/discord/707079246388133940.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2" alt="Discord">
</a>
<a href="https://twitter.com/SnapshotLabs">
<a href="https://x.com/SnapshotLabs">
<img src="https://img.shields.io/twitter/follow/SnapshotLabs?label=SnapshotLabs&style=social">
</a>
</div>
Expand All @@ -27,7 +27,7 @@
<a href="https://features.snapshot.org/feature-requests"><b>Feature requests</b></a>
<a href="https://docs.snapshot.org/guides/contribute"><b>Contribute</b></a>
<a href="https://docs.snapshot.org/introduction#contributing"><b>Contribute</b></a>
</div>

## Project setup
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@shutter-network/shutter-crypto": "1.0.1",
"@snapshot-labs/lock": "^0.2.8",
"@snapshot-labs/pineapple": "^1.1.0",
"@snapshot-labs/snapshot.js": "^0.12.23",
"@snapshot-labs/snapshot.js": "^0.12.33",
"@vue/apollo-composable": "4.0.0-beta.11",
"@vueuse/core": "^10.6.1",
"@vueuse/head": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion snapshot-spaces
48 changes: 42 additions & 6 deletions src/components/SettingsDelegationBlock.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,60 @@
<script setup lang="ts">
import schemas from '@snapshot-labs/snapshot.js/src/schemas';
const delegationDefinition =
schemas.space.properties.delegationPortal.properties;
const props = defineProps<{
context: 'setup' | 'settings';
isViewOnly?: boolean;
}>();
const { form, validationErrors, addRef } = useFormSpaceSettings(props.context);
const delegationTypes = computed(() => {
return delegationDefinition.delegationType.anyOf.map((item: any) => ({
value: item.const,
name: item.title
}));
});
</script>

<template>
<BaseBlock :title="$t('settings.delegationPortal.title')">
<BaseMessageBlock level="info" class="mb-3">
{{ $t('settings.delegationPortal.information') }}
</BaseMessageBlock>
<TuneForm
:ref="addRef"
v-model="form.delegationPortal"
:definition="schemas.space.properties.delegationPortal"
:error="validationErrors?.delegationPortal || {}"
/>

<div class="space-y-2">
<TuneListbox
:ref="addRef"
:items="delegationTypes"
:model-value="form.delegationPortal.delegationType"
:definition="delegationDefinition.delegationType"
@update:model-value="
value => (form.delegationPortal.delegationType = value)
"
/>
<TuneInput
:ref="addRef"
v-model="form.delegationPortal.delegationContract"
:definition="delegationDefinition.delegationContract"
:error="validationErrors.delegationPortal?.delegationContract"
/>

<ComboboxNetwork
:ref="addRef"
label="Delegation network"
:hint="delegationDefinition.delegationContract.description"
:network="form.delegationPortal.delegationNetwork"
@select="value => (form.delegationPortal.delegationNetwork = value)"
/>
<TuneInput
:ref="addRef"
v-model="form.delegationPortal.delegationApi"
:definition="delegationDefinition.delegationApi"
:error="validationErrors.delegationPortal?.delegationApi"
/>
</div>
</BaseBlock>
</template>
2 changes: 1 addition & 1 deletion src/composables/useClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function useClient() {
body: payload.body,
discussion: payload.discussion,
choices: payload.choices,
labels: [],
labels: payload.labels,
plugins: JSON.stringify(plugins)
});
} else if (type === 'vote') {
Expand Down
3 changes: 3 additions & 0 deletions src/composables/useFormSpaceProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface ProposalForm {
body: string;
discussion: string;
choices: { key: number; text: string }[];
labels: string[];
start: number;
end: number;
snapshot: number;
Expand All @@ -29,6 +30,7 @@ const EMPTY_PROPOSAL: ProposalForm = {
{ key: 0, text: '' },
{ key: 1, text: '' }
],
labels: [],
start: parseInt((Date.now() / 1e3).toFixed()),
end: 0,
snapshot: 0,
Expand Down Expand Up @@ -60,6 +62,7 @@ export function useFormSpaceProposal({ spaceType = 'default' } = {}) {
name: string;
body: string;
choices: { key: number; text: string }[];
labels: string[];
isBodySet: boolean;
}>(`snapshot.proposal.${route.params.key}`, clone(EMPTY_PROPOSAL_DRAFT));

Expand Down
2 changes: 2 additions & 0 deletions src/composables/useFormSpaceSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const DEFAULT_VOTE_VALIDATION = { name: 'any', params: {} };
const DEFAULT_DELEGATION = {
delegationType: 'compound-governor',
delegationContract: '',
delegationNetwork: '1',
delegationApi: ''
};
const EMPTY_SPACE_FORM = {
strategies: [],
categories: [],
labels: [],
treasuries: [],
admins: [],
moderators: [],
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const connectors = {
projectId: 'e6454bd61aba40b786e866a69bd4c5c6',
chains: [],
optionalChains: [
1, 4, 5, 10, 42, 56, 100, 137, 246, 1088, 42161, 73799, 11155111
1, 4, 5, 10, 42, 56, 100, 137, 246, 250, 4002, 1088, 42161, 73799,
11155111
],
optionalMethods: [
'eth_sendTransaction',
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const KNOWN_HOSTS = [
'wallet.ambire.com',
'multisig.moonbeam.network',
'worldassociation.org',
'safe.mainnet.frax.com'
'safe.mainnet.frax.com',
'safe.fantom.network'
];

// All subdomains of these domains are allowed
Expand Down
1 change: 1 addition & 0 deletions src/helpers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export interface ExtendedSpace {
export interface DelegatesConfig {
delegationType: DelegationTypes;
delegationContract: string;
delegationNetwork: string;
delegationApi: string;
}
export interface SpaceValidation {
Expand Down
8 changes: 8 additions & 0 deletions src/helpers/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const PROPOSAL_QUERY = gql`
body
discussion
choices
labels
start
end
snapshot
Expand Down Expand Up @@ -460,6 +461,12 @@ export const SPACE_QUERY = gql`
moderators
members
categories
labels {
id
name
description
color
}
plugins
followersCount
template
Expand Down Expand Up @@ -515,6 +522,7 @@ export const SPACE_QUERY = gql`
delegationPortal {
delegationType
delegationContract
delegationNetwork
delegationApi
}
treasuries {
Expand Down
32 changes: 22 additions & 10 deletions src/views/DelegateView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { debouncedWatch } from '@vueuse/core';
import { isAddress } from '@ethersproject/address';
import { getAddress, isAddress } from '@ethersproject/address';
import networks from '@snapshot-labs/snapshot.js/src/networks.json';
import {
getScores,
Expand Down Expand Up @@ -125,7 +125,9 @@ const delegationStrategies = [
'delegation',
'erc20-balance-of-delegation',
'delegation-with-cap',
'delegation-with-overrides'
'delegation-with-overrides',
'with-delegation',
'erc20-balance-of-delegation-with-delegation'
];
async function getDelegatesWithScore() {
Expand All @@ -145,9 +147,17 @@ async function getDelegatesWithScore() {
const uniqueDelegators = Array.from(
new Set(delegations.map(d => d.delegate))
).map(delegate => {
return delegations.find(a => a.delegate === delegate);
});
)
.map(delegate => {
return delegations.find(a => a.delegate === delegate);
})
.map(delegation => {
return {
...delegation,
delegate: getAddress(delegation.delegate),
delegator: getAddress(delegation.delegator)
};
});
const delegatesAddresses = uniqueDelegators.map(d => d.delegate);
Expand All @@ -161,11 +171,13 @@ async function getDelegatesWithScore() {
);
uniqueDelegators.forEach(delegate => {
const delegationScore = scores[0];
Object.entries(delegationScore).forEach(([address, score]) => {
if (address === delegate.delegate) {
delegate.score = score;
}
delegate.score = 0;
scores.forEach(delegationScore => {
Object.entries(delegationScore).forEach(([address, score]) => {
if (address === delegate.delegate) {
delegate.score += score;
}
});
});
});
Expand Down
1 change: 1 addition & 0 deletions src/views/SpaceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ function setSourceProposal(proposal) {
body: proposal.body,
discussion: proposal.discussion,
choices: proposal.choices,
labels: proposal.labels,
start: proposal.start,
end: proposal.end,
snapshot: proposal.snapshot,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1679,10 +1679,10 @@
resolved "https://registry.yarnpkg.com/@snapshot-labs/prettier-config/-/prettier-config-0.1.0-beta.15.tgz#07e5ae35ed36304250462218e115bab1c1609812"
integrity sha512-va6zYSl8oIraBJeIZWEatOI292rfJQouyyvEeHv8qi9ns+LgxMsKayQtXSqn9GcmAfdWQVs/P9bDaCQ77FyJYw==

"@snapshot-labs/snapshot.js@^0.12.23":
version "0.12.23"
resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot.js/-/snapshot.js-0.12.23.tgz#31fea49f8cb1d3fccf9d5898f05edd9c68500d69"
integrity sha512-n3qJUblvZFhaGzqW+TUL32YkNnPl7uAKwrofx1rG6em3E/LjE9Wr2HdbFtdBzIK0QiZQPYdHzQNokjE6jJJ+tw==
"@snapshot-labs/snapshot.js@^0.12.33":
version "0.12.33"
resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot.js/-/snapshot.js-0.12.33.tgz#3ce3166419931ef31f1070449318b98b9c482078"
integrity sha512-N5diNuGsglbcQ/t63EdnpUvl2bQO6TerpJE4bA+QHCEoqy/XQdqUjksosn/MWKt1gQfBjTYiN3aPGV4uj1mspA==
dependencies:
"@ensdomains/eth-ens-namehash" "^2.0.15"
"@ethersproject/abi" "^5.6.4"
Expand Down

0 comments on commit 9347d57

Please sign in to comment.