Skip to content

Commit

Permalink
feat: handle proposing through Safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Sekhmet committed Dec 10, 2024
1 parent aae357a commit 1d95a6d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<script setup lang="ts">
type Messages = {
title?: string;
title: string;
subtitle?: string;
};
withDefaults(
defineProps<{
open: boolean;
messages?: Messages;
messages: Messages;
showIcon?: boolean;
}>(),
{
messages: () => ({
title: 'Confirm vote in Safe app',
subtitle: 'Go back to Safe app to confirm your vote'
}),
showIcon: true
}
);
Expand Down Expand Up @@ -49,7 +45,7 @@ const emit = defineEmits<{
>
hash-verifier <IH-arrow-sm-right class="inline-block -rotate-45" />
</AppLink>
to validate vote data.
to validate the data.
</div>
</div>
</UiModal>
Expand Down
6 changes: 5 additions & 1 deletion apps/ui/src/components/Modal/Vote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,12 @@ watchEffect(async () => {
}"
@close="modalShareOpen = false"
/>
<ModalVoteConfirmOnSafe
<ModalConfirmOnSafe
:open="modalValidateOnSafeOpen"
:messages="{
title: 'Confirm vote in Safe app',
subtitle: 'Go back to Safe app to confirm your vote'
}"
@close="modalValidateOnSafeOpen = false"
/>
</teleport>
Expand Down
4 changes: 2 additions & 2 deletions apps/ui/src/composables/useActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export function useActions() {

const network = getNetwork(space.network);

await wrapPromise(
const txHash = await wrapPromise(
space.network,
network.actions.propose(
auth.web3,
Expand All @@ -321,7 +321,7 @@ export function useActions() {
)
);

return true;
return txHash;
}

async function updateProposal(
Expand Down
48 changes: 35 additions & 13 deletions apps/ui/src/views/Space/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const timestamp = useTimestamp({ interval: 1000 });
const modalOpen = ref(false);
const modalOpenTerms = ref(false);
const modalValidateOnSafeOpen = ref(false);
const previewEnabled = ref(false);
const sending = ref(false);
const enforcedVoteType = ref<VoteType | null>(null);
Expand Down Expand Up @@ -203,6 +204,24 @@ const proposalMaxEnd = computed(() => {
);
});
function navigateToProposal() {
if (!proposal.value) return;
if (
proposal.value.proposalId &&
offchainNetworks.includes(props.space.network)
) {
router.push({
name: 'space-proposal-overview',
params: {
proposal: proposal.value.proposalId
}
});
} else {
router.push({ name: 'space-proposals' });
}
}
async function handleProposeClick() {
if (!proposal.value) return;
Expand Down Expand Up @@ -267,19 +286,9 @@ async function handleProposeClick() {
if (result) {
proposalsStore.reset(props.space.id, props.space.network);
if (
proposal.value.proposalId &&
offchainNetworks.includes(props.space.network)
) {
router.push({
name: 'space-proposal-overview',
params: {
proposal: proposal.value.proposalId
}
});
} else {
router.push({ name: 'space-proposals' });
}
navigateToProposal();
} else {
modalValidateOnSafeOpen.value = true;
}
} finally {
sending.value = false;
Expand All @@ -291,6 +300,11 @@ function handleAcceptTerms() {
handleProposeClick();
}
function handleConfirmOnSafeClosed() {
modalValidateOnSafeOpen.value = false;
navigateToProposal();
}
function handleExecutionUpdated(
strategyAddress: string,
transactions: Transaction[]
Expand Down Expand Up @@ -628,6 +642,14 @@ watchEffect(() => {
@add="handleTransactionAccept"
@close="reset"
/>
<ModalConfirmOnSafe
:open="modalValidateOnSafeOpen"
:messages="{
title: 'Confirm proposal in Safe app',
subtitle: 'Go back to Safe app to confirm your proposal'
}"
@close="handleConfirmOnSafeClosed"
/>
</teleport>
</div>
</template>

0 comments on commit 1d95a6d

Please sign in to comment.