4
4
Dialog ,
5
5
Heading ,
6
6
PlusSVG ,
7
+ RightArrowSVG ,
7
8
Spinner ,
8
9
Typography ,
9
10
} from '@ensdomains/thorin'
@@ -133,7 +134,7 @@ export function Manage() {
133
134
navigate ( '/strategy' )
134
135
}
135
136
136
- function handleUpdate ( ) {
137
+ function handleMultiDelegate ( ) {
137
138
if ( ! address ) return
138
139
139
140
if ( allocatedDelegates . map ( ( del ) => del [ 0 ] ) . includes ( address ) ) {
@@ -366,6 +367,19 @@ export function Manage() {
366
367
>
367
368
Add delegate
368
369
</ Button >
370
+
371
+ { /* <Button
372
+ prefix={<PlusSVG />}
373
+ onClick={() => {
374
+ write.writeContract({
375
+ ...ensTokenContract,
376
+ functionName: 'delegate',
377
+ args: [address!],
378
+ })
379
+ }}
380
+ >
381
+ Delegate all tokens natively
382
+ </Button> */ }
369
383
</ ButtonWrapper >
370
384
371
385
{ receipt . isSuccess && (
@@ -452,13 +466,60 @@ export function Manage() {
452
466
>
453
467
< Dialog . CloseButton onClick = { ( ) => setIsConfirmationModalOpen ( false ) } />
454
468
455
- < div className = "w-[28rem] max-w-full text-center" >
456
- < Typography >
457
- When you delegate your $ENS tokens they will be swapped for NFTs
458
- that represent each delegate. You can swap back to your tokens
459
- anytime by undelegating.
460
- </ Typography >
461
- </ div >
469
+ { ( ( ) => {
470
+ console . log ( { delegatesArr, allocatedDelegates, changingDelegates } )
471
+ console . log (
472
+ 'new balance of first delegate' ,
473
+ allocatedDelegates [ 0 ] ?. [ 1 ] ?. newBalance
474
+ )
475
+
476
+ // 95% of token balance
477
+ const almostFullBalance =
478
+ ( ( delegationInfo . data ?. balance ?? 0n ) * 95n ) / 100n
479
+
480
+ // If there's exactly one delegate AND the allocated amount is moast of the balance, present the option of native delegation
481
+ if (
482
+ 2 == 2
483
+ // allocatedDelegates.length === 1 &&
484
+ // allocatedDelegates[0][1].newBalance > almostFullBalance
485
+ ) {
486
+ return (
487
+ < div className = "flex w-[28rem] max-w-full flex-col gap-2" >
488
+ < div className = "bg-ens-blue-surface flex flex-row items-center gap-2 rounded-lg p-4" >
489
+ < Typography asProp = "p" >
490
+ Delegate a portion, swapping your $ENS for NFTs that
491
+ represent each delegate. You can undelegate anytime to swap
492
+ back, but new $ENS won’t be delegated automatically.
493
+ </ Typography >
494
+
495
+ < div >
496
+ < RightArrowSVG className = "text-ens-blue-dim" />
497
+ </ div >
498
+ </ div >
499
+ < div className = "bg-ens-blue-surface flex flex-row items-center gap-2 rounded-lg p-4" >
500
+ < Typography asProp = "p" >
501
+ Delegate all your $ENS to one person, including any new $ENS
502
+ you receive, for less gas.
503
+ </ Typography >
504
+
505
+ < div >
506
+ < RightArrowSVG className = "text-ens-blue-dim" />
507
+ </ div >
508
+ </ div >
509
+ </ div >
510
+ )
511
+ }
512
+
513
+ return (
514
+ < div className = "w-[28rem] max-w-full text-center" >
515
+ < Typography asProp = "p" >
516
+ When you delegate your $ENS tokens they will be swapped for NFTs
517
+ that represent each delegate. You can swap back to your tokens
518
+ anytime by undelegating.
519
+ </ Typography >
520
+ </ div >
521
+ )
522
+ } ) ( ) }
462
523
463
524
< Dialog . Footer
464
525
leading = {
@@ -472,7 +533,7 @@ export function Manage() {
472
533
trailing = {
473
534
< Button
474
535
colorStyle = "bluePrimary"
475
- onClick = { handleUpdate }
536
+ onClick = { handleMultiDelegate }
476
537
loading = { receipt . isLoading }
477
538
disabled = { toBeAllocated < 0n || changingDelegates . length === 0 }
478
539
>
0 commit comments