-
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: Add osnap plugin #4312
Merged
Merged
feat: Add osnap plugin #4312
Changes from all commits
Commits
Show all changes
146 commits
Select commit
Hold shift + click to select a range
2d362ff
add activate osnap button
ryanwolhuter 14205b4
bubble emits up
ryanwolhuter b19db70
add is osnap enabled prop
ryanwolhuter ca822d2
add safe app link
ryanwolhuter 3443ba3
add disclaimer
ryanwolhuter c2b0c7d
reduce text size
ryanwolhuter e6f4525
update safe app url
ryanwolhuter 88ac0c4
fix tailwind mistake
ryanwolhuter af54369
use params object
ryanwolhuter 9bcef7a
feat: add osnap buttons for enabling disabling in treasury
daywiss beb8a2c
add is osnap enabled check
ryanwolhuter b1131c1
add new osnap plugin
ryanwolhuter aa07dc6
use presence of plugin to determine if is enabled
ryanwolhuter bcca536
move enable osnap logic out of settings
ryanwolhuter bcb39f7
switch to composition api
ryanwolhuter 2f03b70
update types
ryanwolhuter 2ecf085
remove batch logic from transactions
ryanwolhuter c89884e
remove multisend from contract interaction
ryanwolhuter 006fc03
remove multisend from transfer funds
ryanwolhuter 7dfc735
add correct token type
ryanwolhuter da37389
refactor transfer nft
ryanwolhuter 9bfa582
refactor raw transaction input
ryanwolhuter 2942b5b
add model value and config types
ryanwolhuter 87c9a4f
add model value types
ryanwolhuter 9428152
add transactions by treasury address type
ryanwolhuter 0bd22f8
add high level interface types
ryanwolhuter 34c7732
remove batches logic
ryanwolhuter bd3ed9b
wire up module address query
ryanwolhuter 9ddc894
refactor raw transaction
ryanwolhuter eb55b4f
refactor contract interaction
ryanwolhuter 2a7abf0
only allow one safe
ryanwolhuter 733ff63
refactor proposal component
ryanwolhuter 7334473
rename prop for clarity
ryanwolhuter 7af76d1
auto select safe on mount
ryanwolhuter 7464f3f
fix reference error
ryanwolhuter 16da265
fix collectable fetch bug
ryanwolhuter 3d8d9c2
fix short name in type
ryanwolhuter 2e9d674
remove redundant labels
ryanwolhuter ad45c5f
add types for token fetch logic
ryanwolhuter 6d0da5f
fix typo
ryanwolhuter 4704830
use update for event name
ryanwolhuter ad566f6
add update transaction event to raw
ryanwolhuter 63f6a57
add placeholder data display
ryanwolhuter 063416b
add types for transfer nft
ryanwolhuter f38c14c
rename is proposal to is read only
ryanwolhuter 7997a52
add contract interaction validation
ryanwolhuter cd40bf8
clear parameter on method change
ryanwolhuter 1d2e0e1
add individual parameter examples
ryanwolhuter 6981320
use disabled inputs for read only
ryanwolhuter 1b77f8e
remove unused files
ryanwolhuter 8af0637
remove legacy function code
ryanwolhuter 9c84436
organize exports
ryanwolhuter e9fdf4b
rename for clarity
ryanwolhuter a6218ae
use method name instead of index
ryanwolhuter ed448d1
use existing data if it exists
ryanwolhuter a80b302
use list of one collectable when is read only
ryanwolhuter 07cbdba
re-add activate osnap button
ryanwolhuter 7bf1af0
only show osnap button when plugin is present
ryanwolhuter c1b0114
handle undefined assets
ryanwolhuter 052fe96
make transaction fields possibly undefined
ryanwolhuter 372f798
disable dropdown when read only
ryanwolhuter ad85182
add loading safes state
ryanwolhuter 22a40d3
use modal select for transaction type
ryanwolhuter da18b25
add transaction builder styles
ryanwolhuter 9d5bf72
add style variant for proposal
ryanwolhuter d79bc0f
re-add osnap modal
ryanwolhuter 4ef7ed9
use separate page for read only
ryanwolhuter bce625b
fix import error
ryanwolhuter f93cc9a
make address required
ryanwolhuter ab5ea57
use transfer funds as default
ryanwolhuter 787b1aa
add legacy plugin warning
ryanwolhuter c33870f
update is osnap enabled on window focus
ryanwolhuter 9794df5
extract safe link logic
ryanwolhuter ee3e203
use modal for safe select
ryanwolhuter e563146
add comments for types
ryanwolhuter dde174e
remove redundant functions
ryanwolhuter 6f5960f
rename for clarity
ryanwolhuter ece6aeb
remove weird thing
ryanwolhuter 38633b0
apply formatting
ryanwolhuter c532087
revert original changes
ryanwolhuter 3a25c86
undo old changes
ryanwolhuter 20630fb
add end newlines to match old
ryanwolhuter 93d26f8
update import
ryanwolhuter d949d9f
undo accidental rename
ryanwolhuter c94d259
handle legacy plugin
ryanwolhuter 66652c0
add no safes warning
ryanwolhuter 05fe67e
undo wrong change
ryanwolhuter 51d8aa3
remove old redundant styles
ryanwolhuter fdc31c0
add doc comments for functions
ryanwolhuter 27ae6cc
add proposal details types
ryanwolhuter 13b0913
add comments
ryanwolhuter df2a95c
add address input types
ryanwolhuter d7bc0fb
add amount input types
ryanwolhuter e3ed541
rename component for clarity
ryanwolhuter d967812
add tokens modal types
ryanwolhuter 1a71938
add tokens modal item types
ryanwolhuter 4c329cd
rename for clarity
ryanwolhuter 9d71c70
extract submit proposal modal to component
ryanwolhuter f995c80
add error notifications
ryanwolhuter 9add05c
simplify proposal state
ryanwolhuter 7f28a19
split steps into components
ryanwolhuter 7e133e2
remove redundant action button state
ryanwolhuter 5c47f29
use shared header
ryanwolhuter 6762b3c
don't format amount on change
ryanwolhuter 5c91513
add assertion failed in oo state
ryanwolhuter c8c6795
remove balance logic from details query
ryanwolhuter 7b57dda
separate proposal details chain call
ryanwolhuter e6a36fb
refactor proposal state fetching
ryanwolhuter a9d5fb8
warn about disputed proposals
ryanwolhuter 5ed4cd4
run prettier
ryanwolhuter 711c37b
remove unused types
ryanwolhuter b30f797
move get paged events to events
ryanwolhuter 4ab1e68
add doc comments
ryanwolhuter be564cf
rename for clarity
ryanwolhuter eda8f12
do not show edit plugin modal when is osnap
ryanwolhuter 18498e3
add readme
ryanwolhuter 83e7d0c
Merge remote-tracking branch 'origin/master' into add-osnap-plugin
ryanwolhuter ff199d4
apply formatting
ryanwolhuter fe12f03
fix wrong function interface
ryanwolhuter 01c8cd4
Merge remote-tracking branch 'origin/master' into add-osnap-plugin
ryanwolhuter 84711c1
format
ryanwolhuter 8b84600
merge latest from origin
daywiss 10c08e0
Merge remote-tracking branch 'upstream/master' into add-osnap-plugin
daywiss 080b9c3
Merge remote-tracking branch 'upstream/master' into add-osnap-plugin
daywiss d5e8d6d
fix network id interpretation, and crash when in space.members
daywiss 3f783d0
update changes from master
daywiss adbc4f3
Merge remote-tracking branch 'upstream/master' into add-osnap-plugin
daywiss d63fa29
fix: spacing changes on outcomes page for osnap plugin (#103)
gsteenkamp89 2fae6d7
feat: improve look and feel of transaction builder in osnap (#104)
gsteenkamp89 583b1bc
Merge remote-tracking branch 'upstream/master' into temp
daywiss 3164b29
fix: formatting
daywiss f8e2d58
fix: reset to snapshot's standard 42px height (#105)
gsteenkamp89 8cbb6e2
feat: uma 1936 add dark mode osnap buttons (#106)
gsteenkamp89 b9253fa
fix: cosmetic issues (#107)
gsteenkamp89 f1bb2d6
fix: remove extra spacing (#108)
gsteenkamp89 56bc0e0
fix: change osnap activated to use snapshot's primary blue color (#109)
gsteenkamp89 32963eb
fix: font colors in configure osnap modal (#111)
gsteenkamp89 aab1910
fix: simplify osnap transactions (#112)
gsteenkamp89 b5f250f
fix: shorten module address in snapshot proposal transaction (#110)
gsteenkamp89 1830349
Merge remote-tracking branch 'upstream/master' into add-osnap-plugin
daywiss c0c426c
fix: change osnap opt in instructions container and checkbox (#113)
gsteenkamp89 858f2a7
fix: remove View on IPFS link (#114)
gsteenkamp89 ea96165
fix: show pending notification on signed tx (#115)
gsteenkamp89 6c0a1fd
fix: remove custom inactive osnap button styles (#116)
gsteenkamp89 994f55f
Merge remote-tracking branch 'upstream/master' into add-osnap-plugin
daywiss ad26b98
fix: remove request transaction execution warning message (#117)
gsteenkamp89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<script setup lang="ts"> | ||
import { TreasuryWallet } from '@/helpers/interfaces'; | ||
import { Network } from '@/plugins/oSnap/types'; | ||
import { makeConfigureOsnapUrl } from '@/plugins/oSnap/utils/getters'; | ||
|
||
const props = defineProps<{ | ||
open: boolean; | ||
isOsnapEnabled: boolean; | ||
treasury: TreasuryWallet; | ||
spaceName: string; | ||
}>(); | ||
defineEmits<{ | ||
(e: 'close'): void; | ||
}>(); | ||
const spaceUrl = window.location.href.replace('/settings', ''); | ||
const href = computed(() => | ||
makeConfigureOsnapUrl({ | ||
spaceUrl, | ||
spaceName: props.spaceName, | ||
safeAddress: props.treasury.address, | ||
network: props.treasury.network as Network | ||
}) | ||
); | ||
</script> | ||
|
||
<template> | ||
<BaseModal :open="open" @close="$emit('close')"> | ||
<template #header> | ||
<h3 v-text="'Configure oSnap'" /> | ||
</template> | ||
<div class="m-4 grid grid-cols-[auto,auto] gap-2"> | ||
<i-ho-information-circle class="mt-1 text-sm" /> | ||
<p class="text-sm"> | ||
oSnap seamlessly integrates with Snapshot and your treasury, | ||
automatically executing governance votes on-chain. Bypass the need for | ||
privileged signers to create a DAO that's more efficient and truly | ||
decentralized. | ||
<BaseLink class="mt-1 block text-skin-link" link="https://uma.xyz/osnap" | ||
>Learn more</BaseLink | ||
> | ||
</p> | ||
</div> | ||
|
||
<template #footer> | ||
<a | ||
:href="href" | ||
target="_blank" | ||
class="block w-full rounded-full py-[12px] text-white" | ||
:class=" | ||
isOsnapEnabled ? 'bg-[hsl(349,65%,52%)]' : 'bg-[hsl(240,83%,58%)]' | ||
" | ||
@click.stop="$emit('close')" | ||
> | ||
{{ isOsnapEnabled ? 'Deactivate' : 'Activate' }} oSnap | ||
<i-ho-external-link class="mb-[2px] ml-1 inline-block text-xs" /> | ||
</a> | ||
<p class="mt-2 text-xs text-skin-text"> | ||
Note that the deactivation process takes place in the Safe app | ||
</p> | ||
</template> | ||
</BaseModal> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<script setup lang="ts"> | ||
import { TreasuryWallet } from '@/helpers/interfaces'; | ||
import { Network } from '@/plugins/oSnap/types'; | ||
import { getIsOsnapEnabled } from '@/plugins/oSnap/utils/getters'; | ||
|
||
const props = defineProps<{ | ||
treasury: TreasuryWallet; | ||
treasuryIndex: number; | ||
isViewOnly?: boolean; | ||
hasOsnapPlugin: boolean; | ||
}>(); | ||
|
||
const emit = defineEmits<{ | ||
removeTreasury: [index: number]; | ||
editTreasury: [index: number]; | ||
configureOsnap: [index: number, isEnabled: boolean]; | ||
}>(); | ||
|
||
const isOsnapEnabled = ref(false); | ||
|
||
async function updateIsOsnapEnabled() { | ||
if (!props.hasOsnapPlugin) return; | ||
isOsnapEnabled.value = await getIsOsnapEnabled( | ||
props.treasury.network as Network, | ||
props.treasury.address | ||
); | ||
} | ||
|
||
onMounted(async () => { | ||
await updateIsOsnapEnabled(); | ||
window.addEventListener('focus', updateIsOsnapEnabled); | ||
}); | ||
|
||
onUnmounted(() => { | ||
window.removeEventListener('focus', updateIsOsnapEnabled); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<button | ||
class="flex h-full w-full items-center justify-between truncate rounded-md border p-4" | ||
:class="{ 'cursor-default': isViewOnly }" | ||
@click="emit('editTreasury', treasuryIndex)" | ||
> | ||
<div class="flex items-center gap-2 truncate pr-[20px] text-left"> | ||
<h4 class="truncate">{{ treasury.name }}</h4> | ||
</div> | ||
<div class="ml-auto mr-3"> | ||
<SettingsTreasuryActivateOsnapButton | ||
v-show="hasOsnapPlugin" | ||
:is-osnap-enabled="isOsnapEnabled" | ||
@click.stop=" | ||
!isViewOnly && emit('configureOsnap', treasuryIndex, isOsnapEnabled) | ||
" | ||
/> | ||
</div> | ||
<BaseButtonIcon | ||
v-show="!isViewOnly" | ||
class="-mr-2" | ||
@click.stop="emit('removeTreasury', treasuryIndex)" | ||
> | ||
<BaseIcon name="close" size="14" /> | ||
</BaseButtonIcon> | ||
</button> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script setup lang="ts"> | ||
defineProps<{ | ||
isOsnapEnabled: boolean; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<button | ||
v-if="isOsnapEnabled" | ||
class="flex items-center gap-2 rounded-full px-3 py-2 bg-skin-primary text-white" | ||
> | ||
<span class="block h-[6px] w-[6px] rounded-full bg-green" />oSnap activated | ||
</button> | ||
<button | ||
v-else | ||
class="bg-skin-link text-skin-bg flex items-center gap-2 rounded-full px-3 py-2" | ||
> | ||
<span class="block h-[6px] w-[6px] rounded-full bg-skin-bg opacity-30" /> | ||
Activate oSnap | ||
</button> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<script setup lang="ts"> | ||
import { ExtendedSpace } from '@/helpers/interfaces'; | ||
|
||
defineProps<{ | ||
space: ExtendedSpace | undefined; | ||
legacyOsnap: { selection: boolean }; | ||
}>(); | ||
|
||
defineEmits<{ | ||
(event: 'legacyOsnapToggle'): void; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<div class="mb-4"> | ||
<div v-if="space?.voting?.type && space.voting.type !== 'basic'"> | ||
<h6>Where is oSnap?</h6> | ||
<p class="mb-3"> | ||
oSnap is currently disabled because your space's voting settings | ||
disallow the basic voting type which is a requirement for oSnap to work | ||
properly. | ||
</p> | ||
<p> | ||
Have your admin visit your | ||
<a :href="`#/${space.id}/settings`">settings page</a> under Voting -> | ||
Type, and make sure either "Any" or "Basic Voting" is selected. This | ||
will allow you to create oSnap proposals. | ||
</p> | ||
</div> | ||
<div v-else> | ||
<h6>oSnap Proposal</h6> | ||
<p> | ||
Are you planning for this proposal to initiate a transaction that your | ||
organizations Safe will execute if approved? (Remember, oSnap enables | ||
trustless and permissionless execution) | ||
</p> | ||
<br /> | ||
<input | ||
id="toggleOsnap" | ||
type="checkbox" | ||
:checked="legacyOsnap.selection" | ||
@change="$emit('legacyOsnapToggle')" | ||
/> | ||
<label for="toggleOsnap"> | ||
Yes, use oSnap for transactions (this will restrict voting type to | ||
Basic). | ||
</label> | ||
</div> | ||
</div> | ||
</template> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think we should handle it like we do when selecting the plugin in the modal, when the plugin doesn't have
defaults
definedhttps://github.com/snapshot-labs/snapshot/blob/335f6f2d59546023c96c17c4a763c8765fce02a9/src/components/ModalPlugins.vue#L32
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.
could you go into more detail? i dont understand if you want me to remove the changes in the
handleEditPlugins
and instetad put it in theselectPlugin
function instead, or move the default checking fromselectPlugin
tohandleEditPlugins
function