Skip to content

Commit bddda20

Browse files
asgeir-sjuliopavilacedricwaxwingsamepantwa0x6e
authored
Add support for Delegate Registry v2 (#4492)
* feat: set form.to as delegate address * feat-wip: initial split delegation UI updates to SpaceDelegatesDelegateModal * choir: Adds addDelegate, deleteDelegate, deleteAllDelegates functions * wip: updates divide equally and cleans up definition * feat: add delegates logic for Delegate Row Form * Updates clear all delegates logic * Updates x button hover * Refactor the delegation setup to be agnostic to how the data fetching and setting happens * Add delegate registry v2 reading * Add delegate registry v2 balance * Make it possible to view delegateRegistryV2 delegates * Activate the delegates sidebar link for delegate registry v2 delegations * Fix prettier problems * [delegate registry v2]Add offset/skip to delegat query * Add separate delegation UI for different delegation types * Update DELEGATE_REGISTRY_BACKEND_URL * feat: Connect the logic for setting the delegation * Update weight calculation in handleConfirm function * Add expiration time to setDelegates function and get it from the Modal * WIP: Adds Expiration field * feat: implement expiration date logic * chore: clean code * chore: remove unnecessary variables * Default expiration time to one year in the future + Some refactoring * chore: Apply PR comments * fix: adjust file imports * fix orderBy filter * format units to default to 18 decimals * bug: remove wrong percentage format * add number of delegators to read * use new api structure * fix object key reference * fix units * add fetch method * rename registry v2 -> split delegation * adjust for api changes * cleanup split delegation modal * fix address ordering * fix sub-strategy param on fetch * update read.ts to new api schema * use delegators from new api schema * update api request body to match new schema * use strategy set backendUrl if available * PR fixups * display current delegations in modal * add error if weights are over 100 * switch to using delegatePortal settings where appropriate * adds ability to clear all delegations * chore: file renaming * refactor: centralize delegation portal enabling * refactor: DRY-ing modal definition * refactor: remove redundant import * refactor: modify ref inside same function for more readability * refactor: remove redundant return * refactor: follow coding style for error arg name * refactor: remove uneeded ref * fix: remove unused function * feat: set form.to as delegate address * feat-wip: initial split delegation UI updates to SpaceDelegatesDelegateModal * choir: Adds addDelegate, deleteDelegate, deleteAllDelegates functions * wip: updates divide equally and cleans up definition * feat: add delegates logic for Delegate Row Form * Updates clear all delegates logic * Updates x button hover * Refactor the delegation setup to be agnostic to how the data fetching and setting happens * Add delegate registry v2 reading * Add delegate registry v2 balance * Make it possible to view delegateRegistryV2 delegates * Activate the delegates sidebar link for delegate registry v2 delegations * Fix prettier problems * [delegate registry v2]Add offset/skip to delegat query * Add separate delegation UI for different delegation types * Update DELEGATE_REGISTRY_BACKEND_URL * feat: Connect the logic for setting the delegation * Update weight calculation in handleConfirm function * Add expiration time to setDelegates function and get it from the Modal * WIP: Adds Expiration field * feat: implement expiration date logic * chore: clean code * chore: remove unnecessary variables * Default expiration time to one year in the future + Some refactoring * chore: Apply PR comments * fix: adjust file imports * fix orderBy filter * format units to default to 18 decimals * bug: remove wrong percentage format * add number of delegators to read * use new api structure * fix object key reference * fix units * add fetch method * rename registry v2 -> split delegation * adjust for api changes * cleanup split delegation modal * fix address ordering * fix sub-strategy param on fetch * update read.ts to new api schema * use delegators from new api schema * update api request body to match new schema * use strategy set backendUrl if available * PR fixups * display current delegations in modal * add error if weights are over 100 * switch to using delegatePortal settings where appropriate * adds ability to clear all delegations * refactor: rename file to follow convention * chore: revert back changes to .env * chore: remove redundant file * fix: use property from composable to check valid delegation portal * refactor: refactor to follow coding style * refactor: refactor to follow coding style * refactor: removed uneeded variable * fix: show notification error on tx building error * fix: only use `hasDelegationPortal` from composable to check for delegation validity * fix: fix invalid variable type * fix: fix delegate statement not loading * fix: fix content flashing * fix: fix event triggering on page quit * fix: do not return undefined delegation * add sender to delegations when power < 100, clarify language * fix: handle floats when equally distributing power * fix: hide self delegate button on split delegation * fix(ui): delegate form should start with a blank delegate field * fix: add min and max to weight * fix: ensure all addresses are unique * fix: fix missing translation text * refactor: code standard * fix: remove empty string from duplicate addresses comparison * fix: remove unused ref * chore: remove leftover code from copy/paste * fix: UI fix * remove unused function, notify on wrong network * fix: refresh delegatingTo properly on account change * fix: fix wrong comparison --------- Co-authored-by: juliopavila <javila1997@gmail.com> Co-authored-by: Colin Spence <udappia@gmail.com> Co-authored-by: samepant <sampanter@gmail.com> Co-authored-by: samepant <samepant@users.noreply.github.com> Co-authored-by: Wan Qi Chen <495709+wa0x6e@users.noreply.github.com>
1 parent c820500 commit bddda20

25 files changed

+1248
-398
lines changed

src/components/BaseSearch.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const props = defineProps<{
44
placeholder?: string;
55
modal?: boolean;
66
focusOnMount?: boolean;
7+
isDisabled?: boolean;
78
}>();
89
910
const emit = defineEmits(['update:modelValue']);
@@ -49,6 +50,8 @@ watch(
4950
autocorrect="off"
5051
autocapitalize="none"
5152
class="input w-full border-none"
53+
:class="{ '!cursor-not-allowed': isDisabled }"
54+
:disabled="isDisabled"
5255
@input="handleInput"
5356
/>
5457
<i-ho-x-circle

src/components/SpaceDelegatesDelegateModal.vue

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const {
2020
const { notify } = useFlashNotification();
2121
const { t } = useI18n();
2222
const { resolveName } = useResolveName();
23-
const { setDelegate, loadDelegateBalance, isLoadingDelegateBalance } =
23+
const { setDelegates, loadDelegateBalance, isLoadingDelegateBalance } =
2424
useDelegates(props.space);
2525
const { formatCompactNumber } = useIntl();
2626
const { web3Account } = useWeb3();
@@ -73,7 +73,7 @@ async function handleConfirm() {
7373
const txPendingId = createPendingTransaction();
7474
try {
7575
isAwaitingSignature.value = true;
76-
const tx = await setDelegate(resolvedAddress.value);
76+
const tx = await setDelegates([resolvedAddress.value]);
7777
isAwaitingSignature.value = false;
7878
updatePendingTransaction(txPendingId, { hash: tx.hash });
7979
emit('close');
@@ -87,6 +87,7 @@ async function handleConfirm() {
8787
} catch (e) {
8888
console.log(e);
8989
isAwaitingSignature.value = false;
90+
notify(['red', 'An error occurred while building the transaction.']);
9091
removePendingTransaction(txPendingId);
9192
}
9293
}
@@ -137,19 +138,25 @@ watch(
137138
<div class="px-4 pt-1 text-left text-skin-heading">
138139
<h3 class="m-0">{{ $t('delegates.delegateModal.title') }}</h3>
139140
<span>{{ $t('delegates.delegateModal.sub') }}</span>
140-
<LoadingSpinner
141-
v-if="isLoadingDelegateBalance"
142-
class="inline-block pl-2"
143-
small
144-
/>
145-
<span v-else>
146-
{{ formatCompactNumber(Number(accountBalance)) }}
147-
{{ space.symbol }}
148-
</span>
149141
</div>
150142
</template>
151143

152144
<div class="space-y-3 p-4">
145+
<div>
146+
<LabelInput> Voting power </LabelInput>
147+
<div class="mt-1 flex items-center gap-1 text-skin-heading">
148+
<LoadingSpinner
149+
v-if="isLoadingDelegateBalance"
150+
class="inline-block"
151+
small
152+
/>
153+
<span v-else>
154+
{{ formatCompactNumber(Number(accountBalance)) }}
155+
{{ space.symbol }}
156+
</span>
157+
</div>
158+
</div>
159+
153160
<div>
154161
<LabelInput> Delegation scope </LabelInput>
155162
<div class="mt-1 flex items-center gap-1">

0 commit comments

Comments
 (0)