@huma-finance/widgets 0.0.62-beta.599 → 0.0.62-beta.611
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 +185 -0
- package/dist/cjs/index.cjs +1490 -268
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +117 -2
- package/dist/index.js +1489 -271
- package/dist/index.js.map +1 -1
- package/package.json +11 -6
- package/src/components/CreditLine/solanaBorrow/1-ChooseAmount.tsx +86 -0
- package/src/components/CreditLine/solanaBorrow/2-ApproveAllowance.tsx +87 -0
- package/src/components/CreditLine/solanaBorrow/index.tsx +96 -0
- package/src/components/InputAmountModal.tsx +12 -2
- package/src/components/Lend/solanaAddRedemption/1-ChooseTranche.tsx +114 -0
- package/src/components/Lend/solanaAddRedemption/2-ChooseAmount.tsx +183 -0
- package/src/components/Lend/solanaAddRedemption/3-Transfer.tsx +102 -0
- package/src/components/Lend/solanaAddRedemption/4-Done.tsx +29 -0
- package/src/components/Lend/solanaAddRedemption/index.tsx +140 -0
- package/src/components/Lend/solanaCancelRedemption/1-ChooseTranche.tsx +114 -0
- package/src/components/Lend/solanaCancelRedemption/2-Transfer.tsx +99 -0
- package/src/components/Lend/solanaCancelRedemption/3-Done.tsx +55 -0
- package/src/components/Lend/solanaCancelRedemption/index.tsx +152 -0
- package/src/components/Lend/solanaSupply/1-ChooseTranche.tsx +116 -0
- package/src/components/Lend/solanaSupply/2-Evaluation.tsx +0 -0
- package/src/components/Lend/solanaSupply/3-ChooseAmount.tsx +130 -0
- package/src/components/Lend/solanaSupply/4-Transfer.tsx +89 -0
- package/src/components/Lend/solanaSupply/5-Success.tsx +50 -0
- package/src/components/Lend/solanaSupply/index.tsx +143 -0
- package/src/components/SolanaTxDoneModal.tsx +115 -0
- package/src/components/SolanaTxSendModal.tsx +61 -0
- package/src/components/SolanaViewOnExplorer.tsx +29 -0
- package/src/components/WidgetWrapper.tsx +6 -4
- package/src/index.tsx +124 -0
- package/src/store/widgets.reducers.ts +5 -0
- package/src/store/widgets.store.ts +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Box, Button } from '@mui/material'
|
|
2
|
+
import {
|
|
3
|
+
getSolanaExplorerUrl,
|
|
4
|
+
openInNewTab,
|
|
5
|
+
SolanaChainEnum,
|
|
6
|
+
} from '@huma-finance/shared'
|
|
7
|
+
import React from 'react'
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
chainId: SolanaChainEnum
|
|
11
|
+
signature: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function SolanaViewOnExplorer({
|
|
15
|
+
chainId,
|
|
16
|
+
signature,
|
|
17
|
+
}: Props): React.ReactElement | null {
|
|
18
|
+
const link = getSolanaExplorerUrl(chainId, signature, 'tx')
|
|
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
|
+
}
|
|
@@ -31,7 +31,7 @@ export function WidgetWrapper({
|
|
|
31
31
|
}: WCProps<Props>): React.ReactElement | null {
|
|
32
32
|
const theme = useTheme()
|
|
33
33
|
const dispatch = useAppDispatch()
|
|
34
|
-
const { step } = useAppSelector(selectWidgetState)
|
|
34
|
+
const { step, solanaSignature } = useAppSelector(selectWidgetState)
|
|
35
35
|
const [{ state, failReason, txReceipt }] = useAtom(sendTxAtom)
|
|
36
36
|
const reset = useResetAtom(txAtom)
|
|
37
37
|
|
|
@@ -42,12 +42,14 @@ export function WidgetWrapper({
|
|
|
42
42
|
}, [dispatch, failReason, state])
|
|
43
43
|
|
|
44
44
|
useEffect(() => {
|
|
45
|
-
if (step === WIDGET_STEP.Done && txReceipt) {
|
|
46
|
-
if (handleSuccess) {
|
|
45
|
+
if (step === WIDGET_STEP.Done && (txReceipt || solanaSignature)) {
|
|
46
|
+
if (handleSuccess && txReceipt) {
|
|
47
47
|
handleSuccess(txReceipt.blockNumber)
|
|
48
|
+
} else if (handleSuccess && solanaSignature) {
|
|
49
|
+
handleSuccess(0) // solana tx doesn't have block number
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
}, [handleSuccess, step, txReceipt])
|
|
52
|
+
}, [handleSuccess, solanaSignature, step, txReceipt])
|
|
51
53
|
|
|
52
54
|
const handleCloseModal = useCallback(() => {
|
|
53
55
|
reset()
|
package/src/index.tsx
CHANGED
|
@@ -73,6 +73,22 @@ import { SuperfluidFactoring } from './components/SuperfluidFactoring'
|
|
|
73
73
|
import { store } from './store'
|
|
74
74
|
import { themeHuma } from './theme'
|
|
75
75
|
import { WCProps } from './utilTypes'
|
|
76
|
+
import {
|
|
77
|
+
SolanaLendSupply,
|
|
78
|
+
SolanaLendSupplyProps,
|
|
79
|
+
} from './components/Lend/solanaSupply'
|
|
80
|
+
import {
|
|
81
|
+
SolanaLendAddRedemption,
|
|
82
|
+
SolanaLendAddRedemptionProps,
|
|
83
|
+
} from './components/Lend/solanaAddRedemption'
|
|
84
|
+
import {
|
|
85
|
+
SolanaLendCancelRedemption,
|
|
86
|
+
SolanaLendCancelRedemptionProps,
|
|
87
|
+
} from './components/Lend/solanaCancelRedemption'
|
|
88
|
+
import {
|
|
89
|
+
SolanaBorrow,
|
|
90
|
+
SolanaBorrowProps,
|
|
91
|
+
} from './components/CreditLine/solanaBorrow'
|
|
76
92
|
|
|
77
93
|
/**
|
|
78
94
|
* Mapping of your JSON-RPC connections indexed by chainId
|
|
@@ -528,3 +544,111 @@ export function ReceivableBackedCreditLinePaymentWidgetV2(
|
|
|
528
544
|
</Widget>
|
|
529
545
|
)
|
|
530
546
|
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Object representing the props passed to Solana widgets
|
|
550
|
+
* @typedef {Object} SolanaWidgetProps
|
|
551
|
+
*/
|
|
552
|
+
type SolanaWidgetProps = {
|
|
553
|
+
handleClose?: () => void
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function SolanaWidget(props: WCProps<SolanaWidgetProps>) {
|
|
557
|
+
const { children } = props
|
|
558
|
+
|
|
559
|
+
return (
|
|
560
|
+
<ThemeProvider theme={themeHuma}>
|
|
561
|
+
<ReduxProvider store={store}>{children}</ReduxProvider>
|
|
562
|
+
</ThemeProvider>
|
|
563
|
+
)
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Lend pool supply widget props for Solana pools
|
|
568
|
+
* @typedef {Object} SolanaLendSupplyWidgetProps
|
|
569
|
+
* @property {SolanaLendSupplyProps} SolanaLendSupplyProps - Specific widget props
|
|
570
|
+
* @property {SolanaWidgetProps} SolanaWidgetProps - Widget general props.
|
|
571
|
+
*/
|
|
572
|
+
type SolanaLendSupplyWidgetProps = SolanaLendSupplyProps & SolanaWidgetProps
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Lend pool supply widget for Solana pools
|
|
576
|
+
*
|
|
577
|
+
* @param {SolanaLendSupplyWidgetProps} props - Widget props
|
|
578
|
+
*/
|
|
579
|
+
export function SolanaLendSupplyWidget(props: SolanaLendSupplyWidgetProps) {
|
|
580
|
+
return (
|
|
581
|
+
<SolanaWidget {...props}>
|
|
582
|
+
<SolanaLendSupply {...props} />
|
|
583
|
+
</SolanaWidget>
|
|
584
|
+
)
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Lend pool supply widget props for Solana pools
|
|
589
|
+
* @typedef {Object} SolanaLendAddRedemptionWidgetProps
|
|
590
|
+
* @property {SolanaLendSupplyProps} SolanaLendSupplyProps - Specific widget props
|
|
591
|
+
* @property {SolanaWidgetProps} SolanaWidgetProps - Widget general props.
|
|
592
|
+
*/
|
|
593
|
+
type SolanaLendAddRedemptionWidgetProps = SolanaLendAddRedemptionProps &
|
|
594
|
+
SolanaWidgetProps
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Lend pool supply widget for Solana pools
|
|
598
|
+
*
|
|
599
|
+
* @param {SolanaLendAddRedemptionWidgetProps} props - Widget props
|
|
600
|
+
*/
|
|
601
|
+
export function SolanaLendAddRedemptionWidget(
|
|
602
|
+
props: SolanaLendAddRedemptionWidgetProps,
|
|
603
|
+
) {
|
|
604
|
+
return (
|
|
605
|
+
<SolanaWidget {...props}>
|
|
606
|
+
<SolanaLendAddRedemption {...props} />
|
|
607
|
+
</SolanaWidget>
|
|
608
|
+
)
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Lend pool supply widget props for Solana pools
|
|
613
|
+
* @typedef {Object} SolanaLendCancelRedemptionWidgetProps
|
|
614
|
+
* @property {SolanaLendSupplyProps} SolanaLendSupplyProps - Specific widget props
|
|
615
|
+
* @property {SolanaWidgetProps} SolanaWidgetProps - Widget general props.
|
|
616
|
+
*/
|
|
617
|
+
type SolanaLendCancelRedemptionWidgetProps = SolanaLendCancelRedemptionProps &
|
|
618
|
+
SolanaWidgetProps
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Lend pool supply widget for Solana pools
|
|
622
|
+
*
|
|
623
|
+
* @param {SolanaLendCancelRedemptionWidgetProps} props - Widget props
|
|
624
|
+
*/
|
|
625
|
+
export function SolanaLendCancelRedemptionWidget(
|
|
626
|
+
props: SolanaLendCancelRedemptionWidgetProps,
|
|
627
|
+
) {
|
|
628
|
+
return (
|
|
629
|
+
<SolanaWidget {...props}>
|
|
630
|
+
<SolanaLendCancelRedemption {...props} />
|
|
631
|
+
</SolanaWidget>
|
|
632
|
+
)
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Lend pool supply widget props for Solana pools
|
|
637
|
+
* @typedef {Object} SolanaBorrowWidgetProps
|
|
638
|
+
* @property {SolanaLendSupplyProps} SolanaLendSupplyProps - Specific widget props
|
|
639
|
+
* @property {SolanaWidgetProps} SolanaWidgetProps - Widget general props.
|
|
640
|
+
*/
|
|
641
|
+
type SolanaBorrowWidgetProps = SolanaBorrowProps & SolanaWidgetProps
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Lend pool supply widget for Solana pools
|
|
645
|
+
*
|
|
646
|
+
* @param {SolanaBorrowWidgetProps} props - Widget props
|
|
647
|
+
*/
|
|
648
|
+
export function SolanaBorrowWidget(props: SolanaBorrowWidgetProps) {
|
|
649
|
+
return (
|
|
650
|
+
<SolanaWidget {...props}>
|
|
651
|
+
<SolanaBorrow {...props} />
|
|
652
|
+
</SolanaWidget>
|
|
653
|
+
)
|
|
654
|
+
}
|
|
@@ -32,6 +32,7 @@ export const widgetSlice = createSlice({
|
|
|
32
32
|
state.withdrawShares = undefined
|
|
33
33
|
state.redeemAmount = undefined
|
|
34
34
|
state.redeemShares = undefined
|
|
35
|
+
state.solanaSignature = undefined
|
|
35
36
|
},
|
|
36
37
|
setStep: (state, { payload }: PayloadAction<WIDGET_STEP>) => {
|
|
37
38
|
state.step = payload
|
|
@@ -102,6 +103,9 @@ export const widgetSlice = createSlice({
|
|
|
102
103
|
setMultisend: (state, { payload }: PayloadAction<MultisendPayload>) => {
|
|
103
104
|
state.multisend = payload
|
|
104
105
|
},
|
|
106
|
+
setSolanaSignature: (state, { payload }: PayloadAction<string>) => {
|
|
107
|
+
state.solanaSignature = payload
|
|
108
|
+
},
|
|
105
109
|
setError: (
|
|
106
110
|
state,
|
|
107
111
|
{
|
|
@@ -130,6 +134,7 @@ export const {
|
|
|
130
134
|
setWithdrawShares,
|
|
131
135
|
setRedeemAmount,
|
|
132
136
|
setRedeemShares,
|
|
137
|
+
setSolanaSignature,
|
|
133
138
|
} = widgetSlice.actions
|
|
134
139
|
|
|
135
140
|
export default widgetSlice.reducer
|