-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Space settings to allow voting with alias #3973
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…into todmy/vote-alias
same for me |
@samuveth @aurelianoB fixed, please check |
Proposal creation is not working for me when I enable alias actions. First I tried without alias setting and it worked, but when I enable it I get: You can test here: https://snapshot-8uiprmz57-snapshot.vercel.app/#/samuv.eth/create |
@@ -10,6 +10,7 @@ export function useClient() { | |||
const { web3 } = useWeb3(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This composable has become a little hard to read. Can we try something like this?
const ACTIONS = {
proposal: 'proposal',
vote: 'vote',
deleteProposal: 'delete-proposal',
settings: 'settings',
deleteSpace: 'delete-space'
};
export function useClient() {
async function executeAndHandleError(func) {
isSending.value = true;
try {
return await func();
} catch (e: any) {
errorNotification(e?.error_description || '');
return e;
} finally {
isSending.value = false;
}
}
function bindWithAlias(actionFn) {
return (client, payload) => {
return actionWithAlias(aliasWallet =>
actionFn(client, payload, {
provider: aliasWallet,
address: aliasWallet.address
})
);
};
}
async function sendEIP712(space, type, payload) {
const client = isGnosisSafe.value ? clientGnosisSafe : clientEIP712;
const shouldUseAlias = space.voting?.aliased && !isGnosisSafe.value;
switch (type) {
case ACTIONS.proposal:
return executeAndHandleError(() => sendProposal(space, payload, client, shouldUseAlias));
case ACTIONS.vote:
return executeAndHandleError(() => sendVote(space, payload, client, shouldUseAlias));
case ACTIONS.deleteProposal:
return executeAndHandleError(() => sendDeleteProposal(space, payload, client, shouldUseAlias));
case ACTIONS.settings:
return executeAndHandleError(() => sendSettings(space, payload, client));
case ACTIONS.deleteSpace:
return executeAndHandleError(() => sendDeleteSpace(space, client));
default:
throw new Error(`Unknown action type: ${type}`);
}
}
function sendProposal(space, payload, client, shouldUseAlias) {
const actionFn = shouldUseAlias ? bindWithAlias(proposal) : proposal;
let plugins = {};
if (Object.keys(payload.metadata?.plugins).length !== 0)
plugins = payload.metadata.plugins;
const proposalPayload = {
space: space.id,
type: payload.type,
title: payload.name,
body: payload.body,
discussion: payload.discussion,
choices: payload.choices,
start: payload.start,
end: payload.end,
snapshot: payload.snapshot,
plugins: JSON.stringify(plugins),
app: definedApp,
from: web3.value.account
};
return actionFn(client, proposalPayload);
}
// Similarly implement sendVote, sendDeleteProposal, sendSettings, and sendDeleteSpace
}
Issues
#3265
#3852
Changes
How to test
Allow actions with session keys
. Save settingsAllow actions with session keys
-> Save settingsTo-Do
Self-review checklist
yarn cypress:test:e2e
, and they have passed