From f220217d0807f9c17d00fa64ef2c395c576e1686 Mon Sep 17 00:00:00 2001 From: Youssef Date: Mon, 11 Sep 2023 14:03:16 +0330 Subject: [PATCH 1/4] chore(attest): dynamic import the package --- src/helpers/attest.ts | 64 +++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/helpers/attest.ts b/src/helpers/attest.ts index 52f7fc8d674..b6614ad5b44 100644 --- a/src/helpers/attest.ts +++ b/src/helpers/attest.ts @@ -1,9 +1,9 @@ -import { - SchemaRegistry, - EAS, - SchemaEncoder, - AttestationRequestData -} from '@ethereum-attestation-service/eas-sdk'; +// import { +// SchemaRegistry, +// EAS, +// SchemaEncoder, +// AttestationRequestData +// } from '@ethereum-attestation-service/eas-sdk'; import type { Web3Provider } from '@ethersproject/providers'; import type { Wallet } from '@ethersproject/wallet'; import { EASNetworks } from './constants'; @@ -12,47 +12,47 @@ import { calcPercentageOfSum } from '@snapshot-labs/snapshot.js/src/voting/quadr export const WEIGHTED_VOTING_PROPOSAL_SCHEMA_UID = '0x30457fc9ddd2ce5cc0c8ae9ca5e327db7ec51ea2f766eb7067bbc2e16fbfb783'; -export async function createWeightedVotingProposalSchema( - web3: Web3Provider | Wallet -) { - const signer = 'getSigner' in web3 ? web3.getSigner() : web3; - const network = await signer.getChainId(); - const easConfig = EASNetworks[network]; - console.log({ easConfig, network }); - const schemaRegistryContractAddress = easConfig.SchemaRegistry; - const schemaRegistry = new SchemaRegistry(schemaRegistryContractAddress); +// export async function createWeightedVotingProposalSchema( +// web3: Web3Provider | Wallet +// ) { +// const signer = 'getSigner' in web3 ? web3.getSigner() : web3; +// const network = await signer.getChainId(); +// const easConfig = EASNetworks[network]; +// console.log({ easConfig, network }); +// const schemaRegistryContractAddress = easConfig.SchemaRegistry; +// const schemaRegistry = new SchemaRegistry(schemaRegistryContractAddress); - schemaRegistry.connect(signer as any); +// schemaRegistry.connect(signer as any); - const schema = 'string choice, uint16 percent, bytes32 proposalId'; - // const resolverAddress: string = ZERO_ADDRESS; +// const schema = 'string choice, uint16 percent, bytes32 proposalId'; +// // const resolverAddress: string = ZERO_ADDRESS; - const revocable = true; +// const revocable = true; - const transaction = await schemaRegistry.register({ - schema, - // resolverAddress, - revocable - }); +// const transaction = await schemaRegistry.register({ +// schema, +// // resolverAddress, +// revocable +// }); - // Optional: Wait for transaction to be validated - await transaction.wait(); -} +// // Optional: Wait for transaction to be validated +// await transaction.wait(); +// } export async function weightedVotingProposalAttest( proposalId: string, web3: Web3Provider | Wallet, data: Record ) { + const module = await import('@ethereum-attestation-service/eas-sdk'); console.log('proposalId: ', proposalId); - console.log({ data }); const signer = 'getSigner' in web3 ? web3.getSigner() : web3; // const signer = 'getSigner' in web3 ? web3.getSigner() : web3; // console.log({ signer }); const network = await signer.getChainId(); const easConfig = EASNetworks[network]; - const eas = new EAS(easConfig.EASDeployment); - const schemaRegistry = new SchemaRegistry(easConfig.SchemaRegistry); + const eas = new module.EAS(easConfig.EASDeployment); + const schemaRegistry = new module.SchemaRegistry(easConfig.SchemaRegistry); // const _signer = { // ...signer, @@ -65,7 +65,7 @@ export async function weightedVotingProposalAttest( const schema = await schemaRegistry.getSchema({ uid: WEIGHTED_VOTING_PROPOSAL_SCHEMA_UID }); - const schemaEncoder = new SchemaEncoder(schema.schema); + const schemaEncoder = new module.SchemaEncoder(schema.schema); const selectedChoices: number[] = []; const weights: number[] = []; Object.entries(data).forEach(([choiceId, value]) => { @@ -77,7 +77,7 @@ export async function weightedVotingProposalAttest( ); try { - const multiAttestData = [true].map((): AttestationRequestData => { + const multiAttestData = [true].map((): any => { const encodedData = schemaEncoder.encodeData([ { name: 'proposalId', From 95c51f7a6d590fedd5c1b8644d43371dbfd3448a Mon Sep 17 00:00:00 2001 From: Youssef Date: Tue, 12 Sep 2023 16:57:25 +0330 Subject: [PATCH 2/4] feat(attestaions): assign VP --- src/components/SpaceProposalPage.vue | 1 + src/components/SpaceProposalResults.vue | 1 - src/components/SpaceProposalVote.vue | 9 +++- src/components/SpaceProposalVotesList.vue | 2 +- src/components/SpaceProposalVotesModal.vue | 2 +- src/composables/useProposalVotes.ts | 57 +++++++++++++++++----- src/helpers/queries.ts | 11 ++++- 7 files changed, 64 insertions(+), 19 deletions(-) diff --git a/src/components/SpaceProposalPage.vue b/src/components/SpaceProposalPage.vue index 4af1571f0fc..4337a5f2f9d 100644 --- a/src/components/SpaceProposalPage.vue +++ b/src/components/SpaceProposalPage.vue @@ -183,6 +183,7 @@ onMounted(() => setMessageVisibility(props.proposal.flagged)); v-if="proposal?.state === 'active'" v-model="selectedChoices" :proposal="proposal" + :space="space" @open="modalOpen = true" @clickVote="clickVote" /> diff --git a/src/components/SpaceProposalResults.vue b/src/components/SpaceProposalResults.vue index 65a35aa6df3..bf5e6d81e20 100644 --- a/src/components/SpaceProposalResults.vue +++ b/src/components/SpaceProposalResults.vue @@ -16,7 +16,6 @@ const props = defineProps<{ }>(); const emit = defineEmits(['reload']); - const ts = Number((Date.now() / 1e3).toFixed()); const isInvalidScore = computed( diff --git a/src/components/SpaceProposalVote.vue b/src/components/SpaceProposalVote.vue index 25b1d11f3dd..a1fa12e1b68 100644 --- a/src/components/SpaceProposalVote.vue +++ b/src/components/SpaceProposalVote.vue @@ -1,8 +1,9 @@