@huma-finance/widgets 0.0.62-beta.719 → 0.0.62-beta.721
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +41 -3
- package/dist/cjs/index.cjs +777 -316
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +37 -11
- package/dist/index.js +780 -320
- package/dist/index.js.map +1 -1
- package/package.json +7 -9
- package/src/components/Lend/solanaEnableAutoRedemption/1-ApproveAllowance.tsx +6 -8
- package/src/components/Lend/solanaSupply/3-ChooseAmount.tsx +1 -1
- package/src/components/Lend/solanaSupply/4-Transfer.tsx +12 -13
- package/src/components/Lend/stellarSupply/1-Evaluation.tsx +9 -0
- package/src/components/Lend/stellarSupply/2-ChooseTranche.tsx +116 -0
- package/src/components/Lend/stellarSupply/3-ChooseAmount.tsx +129 -0
- package/src/components/Lend/stellarSupply/4-Transfer.tsx +69 -0
- package/src/components/Lend/stellarSupply/5-Success.tsx +61 -0
- package/src/components/Lend/stellarSupply/index.tsx +159 -0
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +1 -1
- package/src/components/StellarTxDoneModal.tsx +119 -0
- package/src/components/StellarTxSendModal.tsx +43 -0
- package/src/components/StellarViewOnExplorer.tsx +29 -0
- package/src/index.tsx +44 -21
- package/src/store/widgets.reducers.ts +5 -0
- package/src/store/widgets.store.ts +1 -0
|
@@ -111,7 +111,7 @@ export function ChooseAmount({
|
|
|
111
111
|
<InputAmountModal
|
|
112
112
|
title='Enter Amount'
|
|
113
113
|
subTitle={`Depositing to ${
|
|
114
|
-
isUniTranche ? 'uni
|
|
114
|
+
isUniTranche ? 'uni' : selectedTranche
|
|
115
115
|
} tranche`}
|
|
116
116
|
tokenSymbol={symbol}
|
|
117
117
|
currentAmount={currentAmount}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Box, Button, css, Typography, useTheme } from '@mui/material'
|
|
2
|
+
import React, { useCallback } from 'react'
|
|
3
|
+
|
|
4
|
+
import { StellarChainEnum } from '@huma-finance/shared'
|
|
5
|
+
import { useAppDispatch } from '../hooks/useRedux'
|
|
6
|
+
import { resetState } from '../store/widgets.reducers'
|
|
7
|
+
import { CheckIcon } from './icons'
|
|
8
|
+
import { StellarViewOnExplorer } from './StellarViewOnExplorer'
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
chainId: StellarChainEnum
|
|
12
|
+
content: string[]
|
|
13
|
+
subContent?: string[]
|
|
14
|
+
buttonText?: string
|
|
15
|
+
txHash?: string
|
|
16
|
+
handleAction: () => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function StellarTxDoneModal({
|
|
20
|
+
chainId,
|
|
21
|
+
content,
|
|
22
|
+
subContent,
|
|
23
|
+
txHash,
|
|
24
|
+
buttonText,
|
|
25
|
+
handleAction,
|
|
26
|
+
}: Props): React.ReactElement {
|
|
27
|
+
const theme = useTheme()
|
|
28
|
+
const dispatch = useAppDispatch()
|
|
29
|
+
|
|
30
|
+
const styles = {
|
|
31
|
+
wrapper: css`
|
|
32
|
+
height: 518px;
|
|
33
|
+
position: relative;
|
|
34
|
+
`,
|
|
35
|
+
header: css`
|
|
36
|
+
${theme.cssMixins.rowHCentered};
|
|
37
|
+
margin-top: ${theme.spacing(-0.5)};
|
|
38
|
+
`,
|
|
39
|
+
content: css`
|
|
40
|
+
${theme.cssMixins.colVCentered};
|
|
41
|
+
font-weight: ${subContent ? 700 : 400};
|
|
42
|
+
font-size: 18px;
|
|
43
|
+
color: ${theme.palette.text.secondary};
|
|
44
|
+
margin-top: ${theme.spacing(8)};
|
|
45
|
+
text-align: center;
|
|
46
|
+
`,
|
|
47
|
+
subContent: css`
|
|
48
|
+
${theme.cssMixins.colVCentered};
|
|
49
|
+
font-weight: 400;
|
|
50
|
+
font-size: 18px;
|
|
51
|
+
color: ${theme.palette.text.primary};
|
|
52
|
+
margin-top: ${theme.spacing(2)};
|
|
53
|
+
text-align: center;
|
|
54
|
+
`,
|
|
55
|
+
check: css`
|
|
56
|
+
width: 100%;
|
|
57
|
+
${theme.cssMixins.rowHCentered};
|
|
58
|
+
margin-top: ${theme.spacing(10)};
|
|
59
|
+
`,
|
|
60
|
+
bottomButtonGroup: css`
|
|
61
|
+
width: 100%;
|
|
62
|
+
position: absolute;
|
|
63
|
+
bottom: 0;
|
|
64
|
+
display: flex;
|
|
65
|
+
row-gap: ${theme.spacing(1)};
|
|
66
|
+
column-gap: ${theme.spacing(1)};
|
|
67
|
+
|
|
68
|
+
button {
|
|
69
|
+
height: 40px;
|
|
70
|
+
margin-top: ${theme.spacing(1)};
|
|
71
|
+
}
|
|
72
|
+
`,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const handleCloseModal = useCallback(() => {
|
|
76
|
+
dispatch(resetState())
|
|
77
|
+
handleAction()
|
|
78
|
+
}, [dispatch, handleAction])
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Box css={styles.wrapper}>
|
|
82
|
+
<Typography variant='h6' css={styles.header}>
|
|
83
|
+
Transaction Completed
|
|
84
|
+
</Typography>
|
|
85
|
+
<Box css={styles.check}>
|
|
86
|
+
<CheckIcon />
|
|
87
|
+
</Box>
|
|
88
|
+
<Box css={styles.content}>
|
|
89
|
+
{content.map((item) => (
|
|
90
|
+
<Box sx={{ marginTop: theme.spacing(1) }} key={item}>
|
|
91
|
+
{item}
|
|
92
|
+
</Box>
|
|
93
|
+
))}
|
|
94
|
+
</Box>
|
|
95
|
+
{subContent && (
|
|
96
|
+
<Box css={styles.subContent}>
|
|
97
|
+
{subContent.map((item) => (
|
|
98
|
+
<Box sx={{ marginTop: theme.spacing(1) }} key={item}>
|
|
99
|
+
{item}
|
|
100
|
+
</Box>
|
|
101
|
+
))}
|
|
102
|
+
</Box>
|
|
103
|
+
)}
|
|
104
|
+
<Box css={styles.bottomButtonGroup}>
|
|
105
|
+
{txHash && chainId && (
|
|
106
|
+
<StellarViewOnExplorer chainId={chainId} txHash={txHash} />
|
|
107
|
+
)}
|
|
108
|
+
<Button
|
|
109
|
+
className='transaction-done-modal-close-btn'
|
|
110
|
+
variant='contained'
|
|
111
|
+
fullWidth
|
|
112
|
+
onClick={handleCloseModal}
|
|
113
|
+
>
|
|
114
|
+
{!buttonText ? 'DONE' : buttonText}
|
|
115
|
+
</Button>
|
|
116
|
+
</Box>
|
|
117
|
+
</Box>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
|
+
import AssembledTransaction from '@stellar/stellar-sdk'
|
|
3
|
+
import { useAppDispatch } from '../hooks/useRedux'
|
|
4
|
+
import { setError, setTxHash } from '../store/widgets.reducers'
|
|
5
|
+
import { LoadingModal } from './LoadingModal'
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
tx?: typeof AssembledTransaction
|
|
9
|
+
handleSuccess: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function StellarTxSendModal({
|
|
13
|
+
tx,
|
|
14
|
+
handleSuccess,
|
|
15
|
+
}: Props): React.ReactElement | null {
|
|
16
|
+
const dispatch = useAppDispatch()
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
async function sendTx() {
|
|
20
|
+
if (!tx) {
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const txResult = await tx.signAndSend()
|
|
26
|
+
const { hash } = txResult.sendTransactionResponse
|
|
27
|
+
dispatch(setTxHash(hash))
|
|
28
|
+
handleSuccess()
|
|
29
|
+
} catch (error: unknown) {
|
|
30
|
+
const err = error as Error
|
|
31
|
+
dispatch(setError({ errorMessage: err?.message || '' }))
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
sendTx()
|
|
35
|
+
}, [dispatch, handleSuccess, tx])
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<LoadingModal
|
|
39
|
+
title='Transaction Pending'
|
|
40
|
+
description='Waiting for confirmation...'
|
|
41
|
+
/>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Box, Button } from '@mui/material'
|
|
2
|
+
import {
|
|
3
|
+
getStellarExplorerUrl,
|
|
4
|
+
openInNewTab,
|
|
5
|
+
StellarChainEnum,
|
|
6
|
+
} from '@huma-finance/shared'
|
|
7
|
+
import React from 'react'
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
chainId: StellarChainEnum
|
|
11
|
+
txHash: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function StellarViewOnExplorer({
|
|
15
|
+
chainId,
|
|
16
|
+
txHash,
|
|
17
|
+
}: Props): React.ReactElement | null {
|
|
18
|
+
const link = getStellarExplorerUrl(chainId, txHash)
|
|
19
|
+
|
|
20
|
+
if (!link) {
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Button fullWidth variant='outlined' onClick={() => openInNewTab(link)}>
|
|
26
|
+
<Box component='span'>VIEW ON EXPLORER</Box>
|
|
27
|
+
</Button>
|
|
28
|
+
)
|
|
29
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -90,6 +90,10 @@ import {
|
|
|
90
90
|
SolanaPaymentProps,
|
|
91
91
|
} from './components/CreditLine/solanaPayment'
|
|
92
92
|
import { NotifiContextWrapper } from './components/Notifi/NotifiContextWrapper'
|
|
93
|
+
import {
|
|
94
|
+
StellarLendSupply,
|
|
95
|
+
StellarLendSupplyProps,
|
|
96
|
+
} from './components/Lend/stellarSupply'
|
|
93
97
|
import {
|
|
94
98
|
SolanaEnableAutoRedemption,
|
|
95
99
|
SolanaEnableAutoRedemptionProps,
|
|
@@ -554,13 +558,13 @@ export function ReceivableBackedCreditLinePaymentWidgetV2(
|
|
|
554
558
|
|
|
555
559
|
/**
|
|
556
560
|
* Object representing the props passed to Solana widgets
|
|
557
|
-
* @typedef {Object}
|
|
561
|
+
* @typedef {Object} GenericWidgetProps
|
|
558
562
|
*/
|
|
559
|
-
type
|
|
563
|
+
type GenericWidgetProps = {
|
|
560
564
|
handleClose?: () => void
|
|
561
565
|
}
|
|
562
566
|
|
|
563
|
-
function
|
|
567
|
+
function GenericWidget(props: WCProps<GenericWidgetProps>) {
|
|
564
568
|
const { children } = props
|
|
565
569
|
|
|
566
570
|
return (
|
|
@@ -574,7 +578,7 @@ function SolanaWidget(props: WCProps<SolanaWidgetProps>) {
|
|
|
574
578
|
* Lend pool supply widget props for Solana pools
|
|
575
579
|
* @typedef {Object} SolanaLendSupplyWidgetProps
|
|
576
580
|
*/
|
|
577
|
-
type SolanaLendSupplyWidgetProps = SolanaLendSupplyProps &
|
|
581
|
+
type SolanaLendSupplyWidgetProps = SolanaLendSupplyProps & GenericWidgetProps
|
|
578
582
|
|
|
579
583
|
/**
|
|
580
584
|
* Lend pool supply widget for Solana pools
|
|
@@ -583,9 +587,9 @@ type SolanaLendSupplyWidgetProps = SolanaLendSupplyProps & SolanaWidgetProps
|
|
|
583
587
|
*/
|
|
584
588
|
export function SolanaLendSupplyWidget(props: SolanaLendSupplyWidgetProps) {
|
|
585
589
|
return (
|
|
586
|
-
<
|
|
590
|
+
<GenericWidget {...props}>
|
|
587
591
|
<SolanaLendSupply {...props} />
|
|
588
|
-
</
|
|
592
|
+
</GenericWidget>
|
|
589
593
|
)
|
|
590
594
|
}
|
|
591
595
|
|
|
@@ -594,7 +598,7 @@ export function SolanaLendSupplyWidget(props: SolanaLendSupplyWidgetProps) {
|
|
|
594
598
|
* @typedef {Object} SolanaLendAddRedemptionWidgetProps
|
|
595
599
|
*/
|
|
596
600
|
type SolanaLendAddRedemptionWidgetProps = SolanaLendAddRedemptionProps &
|
|
597
|
-
|
|
601
|
+
GenericWidgetProps
|
|
598
602
|
|
|
599
603
|
/**
|
|
600
604
|
* Lend pool supply widget for Solana pools
|
|
@@ -605,9 +609,9 @@ export function SolanaLendAddRedemptionWidget(
|
|
|
605
609
|
props: SolanaLendAddRedemptionWidgetProps,
|
|
606
610
|
) {
|
|
607
611
|
return (
|
|
608
|
-
<
|
|
612
|
+
<GenericWidget {...props}>
|
|
609
613
|
<SolanaLendAddRedemption {...props} />
|
|
610
|
-
</
|
|
614
|
+
</GenericWidget>
|
|
611
615
|
)
|
|
612
616
|
}
|
|
613
617
|
|
|
@@ -616,7 +620,7 @@ export function SolanaLendAddRedemptionWidget(
|
|
|
616
620
|
* @typedef {Object} SolanaLendCancelRedemptionWidgetProps
|
|
617
621
|
*/
|
|
618
622
|
type SolanaLendCancelRedemptionWidgetProps = SolanaLendCancelRedemptionProps &
|
|
619
|
-
|
|
623
|
+
GenericWidgetProps
|
|
620
624
|
|
|
621
625
|
/**
|
|
622
626
|
* Lend pool supply widget for Solana pools
|
|
@@ -627,9 +631,9 @@ export function SolanaLendCancelRedemptionWidget(
|
|
|
627
631
|
props: SolanaLendCancelRedemptionWidgetProps,
|
|
628
632
|
) {
|
|
629
633
|
return (
|
|
630
|
-
<
|
|
634
|
+
<GenericWidget {...props}>
|
|
631
635
|
<SolanaLendCancelRedemption {...props} />
|
|
632
|
-
</
|
|
636
|
+
</GenericWidget>
|
|
633
637
|
)
|
|
634
638
|
}
|
|
635
639
|
|
|
@@ -637,7 +641,7 @@ export function SolanaLendCancelRedemptionWidget(
|
|
|
637
641
|
* Lend pool supply widget props for Solana pools
|
|
638
642
|
* @typedef {Object} SolanaBorrowWidgetProps
|
|
639
643
|
*/
|
|
640
|
-
type SolanaBorrowWidgetProps = SolanaBorrowProps &
|
|
644
|
+
type SolanaBorrowWidgetProps = SolanaBorrowProps & GenericWidgetProps
|
|
641
645
|
|
|
642
646
|
/**
|
|
643
647
|
* Lend pool supply widget for Solana pools
|
|
@@ -646,9 +650,9 @@ type SolanaBorrowWidgetProps = SolanaBorrowProps & SolanaWidgetProps
|
|
|
646
650
|
*/
|
|
647
651
|
export function SolanaBorrowWidget(props: SolanaBorrowWidgetProps) {
|
|
648
652
|
return (
|
|
649
|
-
<
|
|
653
|
+
<GenericWidget {...props}>
|
|
650
654
|
<SolanaBorrow {...props} />
|
|
651
|
-
</
|
|
655
|
+
</GenericWidget>
|
|
652
656
|
)
|
|
653
657
|
}
|
|
654
658
|
|
|
@@ -656,7 +660,7 @@ export function SolanaBorrowWidget(props: SolanaBorrowWidgetProps) {
|
|
|
656
660
|
* Lend pool supply widget props for Solana pools
|
|
657
661
|
* @typedef {Object} SolanaPaymentWidgetProps
|
|
658
662
|
*/
|
|
659
|
-
type SolanaPaymentWidgetProps = SolanaPaymentProps &
|
|
663
|
+
type SolanaPaymentWidgetProps = SolanaPaymentProps & GenericWidgetProps
|
|
660
664
|
|
|
661
665
|
/**
|
|
662
666
|
* Lend pool supply widget for Solana pools
|
|
@@ -665,9 +669,28 @@ type SolanaPaymentWidgetProps = SolanaPaymentProps & SolanaWidgetProps
|
|
|
665
669
|
*/
|
|
666
670
|
export function SolanaPaymentWidget(props: SolanaPaymentWidgetProps) {
|
|
667
671
|
return (
|
|
668
|
-
<
|
|
672
|
+
<GenericWidget {...props}>
|
|
669
673
|
<SolanaPayment {...props} />
|
|
670
|
-
</
|
|
674
|
+
</GenericWidget>
|
|
675
|
+
)
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Lend pool supply widget props for Stellar pools
|
|
680
|
+
* @typedef {Object} StellarLendSupplyWidgetProps
|
|
681
|
+
*/
|
|
682
|
+
type StellarLendSupplyWidgetProps = StellarLendSupplyProps & GenericWidgetProps
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Lend pool supply widget for Stellar pools
|
|
686
|
+
*
|
|
687
|
+
* @param {StellarLendSupplyWidgetProps} props - Widget props
|
|
688
|
+
*/
|
|
689
|
+
export function StellarLendSupplyWidget(props: StellarLendSupplyWidgetProps) {
|
|
690
|
+
return (
|
|
691
|
+
<GenericWidget {...props}>
|
|
692
|
+
<StellarLendSupply {...props} />
|
|
693
|
+
</GenericWidget>
|
|
671
694
|
)
|
|
672
695
|
}
|
|
673
696
|
|
|
@@ -676,7 +699,7 @@ export function SolanaPaymentWidget(props: SolanaPaymentWidgetProps) {
|
|
|
676
699
|
* @typedef {Object} SolanaEnableAutoRedemptionWidgetProps
|
|
677
700
|
*/
|
|
678
701
|
type SolanaEnableAutoRedemptionWidgetProps = SolanaEnableAutoRedemptionProps &
|
|
679
|
-
|
|
702
|
+
GenericWidgetProps
|
|
680
703
|
|
|
681
704
|
/**
|
|
682
705
|
* Lend pool supply widget for Solana pools
|
|
@@ -687,9 +710,9 @@ export function SolanaEnableAutoRedemptionWidget(
|
|
|
687
710
|
props: SolanaEnableAutoRedemptionWidgetProps,
|
|
688
711
|
) {
|
|
689
712
|
return (
|
|
690
|
-
<
|
|
713
|
+
<GenericWidget {...props}>
|
|
691
714
|
<SolanaEnableAutoRedemption {...props} />
|
|
692
|
-
</
|
|
715
|
+
</GenericWidget>
|
|
693
716
|
)
|
|
694
717
|
}
|
|
695
718
|
|
|
@@ -33,6 +33,7 @@ export const widgetSlice = createSlice({
|
|
|
33
33
|
state.redeemAmount = undefined
|
|
34
34
|
state.redeemShares = undefined
|
|
35
35
|
state.solanaSignature = undefined
|
|
36
|
+
state.txHash = undefined
|
|
36
37
|
},
|
|
37
38
|
setStep: (state, { payload }: PayloadAction<WIDGET_STEP>) => {
|
|
38
39
|
state.step = payload
|
|
@@ -106,6 +107,9 @@ export const widgetSlice = createSlice({
|
|
|
106
107
|
setSolanaSignature: (state, { payload }: PayloadAction<string>) => {
|
|
107
108
|
state.solanaSignature = payload
|
|
108
109
|
},
|
|
110
|
+
setTxHash: (state, { payload }: PayloadAction<string>) => {
|
|
111
|
+
state.txHash = payload
|
|
112
|
+
},
|
|
109
113
|
setPointsAccumulated: (
|
|
110
114
|
state,
|
|
111
115
|
{ payload }: PayloadAction<number | undefined>,
|
|
@@ -141,6 +145,7 @@ export const {
|
|
|
141
145
|
setRedeemAmount,
|
|
142
146
|
setRedeemShares,
|
|
143
147
|
setSolanaSignature,
|
|
148
|
+
setTxHash,
|
|
144
149
|
setPointsAccumulated,
|
|
145
150
|
} = widgetSlice.actions
|
|
146
151
|
|