Skip to content

Commit

Permalink
Deal token transfer modal (#1052)
Browse files Browse the repository at this point in the history
* Deal token transfer modal was introduced

* Add transfer logic (only for 0 id for now)

* Add multi tokens transfer logic

* Contracts updated

* Multicall

* Contracts updated

* Update ABI

* Fix decimal issue

* Format

* math fix (#1054)

* Fix nothing to claim

* Fix nothing to claim v2

* Clear modal input values after tx is confirmed (#1056)

* Add refresh on successful transfer (#1055)

* Add refresh on successful transfer

* Fix updates

---------

Co-authored-by: saeta.eth <saeta@aelindao.xyz>
Co-authored-by: 0xcdb <90234851+0xcdb@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 30, 2023
1 parent 6b2dea5 commit 029872b
Show file tree
Hide file tree
Showing 14 changed files with 928 additions and 180 deletions.
25 changes: 22 additions & 3 deletions src/abis/AelinDeal_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes[]",
"name": "data",
"type": "bytes[]"
}
],
"name": "multicall",
"outputs": [
{
"internalType": "bytes[]",
"name": "results",
"type": "bytes[]"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
Expand Down Expand Up @@ -968,7 +987,7 @@
},
{
"inputs": [],
"name": "totalProtocolFee",
"name": "totalDealTokenAccepted",
"outputs": [
{
"internalType": "uint256",
Expand All @@ -981,7 +1000,7 @@
},
{
"inputs": [],
"name": "totalUnderlyingAccepted",
"name": "totalProtocolFee",
"outputs": [
{
"internalType": "uint256",
Expand Down Expand Up @@ -1216,4 +1235,4 @@
"stateMutability": "nonpayable",
"type": "function"
}
]
]
40 changes: 20 additions & 20 deletions src/abis/AelinUpfrontDeal_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,6 @@
"name": "AcceptDeal",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "collection",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nftID",
"type": "uint256"
}
],
"name": "BlacklistNFT",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -1385,6 +1366,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes[]",
"name": "data",
"type": "bytes[]"
}
],
"name": "multicall",
"outputs": [
{
"internalType": "bytes[]",
"name": "results",
"type": "bytes[]"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
Expand Down Expand Up @@ -1813,4 +1813,4 @@
"stateMutability": "nonpayable",
"type": "function"
}
]
]
16 changes: 10 additions & 6 deletions src/components/form/TokenInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ interface Props {
disabled?: boolean
error?: string
maxDisabled?: boolean
maxValue: string
maxValue?: string
withBalance?: boolean
maxValueFormatted: string
withMaxButton?: boolean
maxValueFormatted?: string
setValue: (value: string) => void
value: string
symbol?: string
Expand All @@ -79,12 +80,13 @@ export const TokenInput = ({
error,
maxAllocationFormatted,
maxDisabled,
maxValue,
maxValue = '',
maxValueFormatted,
setValue,
symbol,
value,
withBalance = true,
withMaxButton = true,
...restProps
}: Props) => {
const setMax = () => setValue(maxValue)
Expand All @@ -106,9 +108,11 @@ export const TokenInput = ({
)}
value={value}
/>
<MaxButton disabled={maxDisabled} onClick={setMax}>
Max
</MaxButton>
{withMaxButton && (
<MaxButton disabled={maxDisabled} onClick={setMax}>
Max
</MaxButton>
)}
</InputWrapper>
{withBalance && (
<Balance>
Expand Down
45 changes: 41 additions & 4 deletions src/components/pools/PoolMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import styled from 'styled-components'

import NoActions from './actions/NoActions'
import ClaimUpfrontDealTokens from './actions/Vest/ClaimUpfrontDealTokens'
import TransferVestingShareModal from './actions/Vest/TransferVestingShareModal'
import UpfrontDealTransferVestingShareModal from './actions/Vest/UpfrontDealTransferVestingShareModal'
import VestUpfrontDeal from './actions/Vest/VestUpfrontDeal'
import Vouch from './actions/Vouch/Vouch'
import InvestorsModal from './common/InvestorsModal'
Expand Down Expand Up @@ -108,6 +110,9 @@ export default function PoolMain({ chainId, poolAddress }: Props) {
const { currentThemeName } = useThemeContext()

const [showInvestorsModal, setShowInvestorsModal] = useState<boolean>(false)
const [showTransferVestingShareModal, setShowTransferVestingShareModal] = useState<boolean>(false)
const [showUpfrontDealTransferVestingShareModal, setUpfrontDealShowTransferVestingShareModal] =
useState<boolean>(false)

const { derivedStatus, funding, pool, tabs, timeline } = useAelinPoolStatus(
chainId,
Expand Down Expand Up @@ -192,6 +197,11 @@ export default function PoolMain({ chainId, poolAddress }: Props) {
activeTab={tabs.actionTabs.active}
derivedStatus={derivedStatus}
funding={funding}
handleTransfer={() =>
pool.upfrontDeal
? setUpfrontDealShowTransferVestingShareModal(true)
: setShowTransferVestingShareModal(true)
}
isUpfrontDeal={!!pool.upfrontDeal}
pool={pool}
/>
Expand All @@ -209,6 +219,18 @@ export default function PoolMain({ chainId, poolAddress }: Props) {
</MainGrid>
{showInvestorsModal && <InvestorsModal onClose={handleCloseInvestorsModal} pool={pool} />}
</RightTimelineLayout>
{showTransferVestingShareModal && (
<TransferVestingShareModal
onClose={() => setShowTransferVestingShareModal(false)}
poolAddress={pool.address}
/>
)}
{showUpfrontDealTransferVestingShareModal && (
<UpfrontDealTransferVestingShareModal
onClose={() => setUpfrontDealShowTransferVestingShareModal(false)}
poolAddress={pool.address}
/>
)}
</>
)
}
Expand All @@ -219,6 +241,7 @@ type DealActionTabsProps = {
activeTab: PoolAction | null
derivedStatus: DerivedStatus
funding: Funding
handleTransfer: () => void
}
function DealActionTabs({ ...props }: DealActionTabsProps) {
return props.isUpfrontDeal ? (
Expand All @@ -228,7 +251,13 @@ function DealActionTabs({ ...props }: DealActionTabsProps) {
)
}

function RegularPoolsActionTabs({ activeTab, derivedStatus, funding, pool }: DealActionTabsProps) {
function RegularPoolsActionTabs({
activeTab,
derivedStatus,
funding,
handleTransfer,
pool,
}: DealActionTabsProps) {
return (
<>
{!activeTab && <NoActions pool={pool} status={derivedStatus} />}
Expand All @@ -238,14 +267,20 @@ function RegularPoolsActionTabs({ activeTab, derivedStatus, funding, pool }: Dea
{activeTab === PoolAction.CreateDeal && <CreateDeal pool={pool} />}
{activeTab === PoolAction.AcceptDeal && <AcceptDeal pool={pool} />}
{activeTab === PoolAction.FundDeal && <FundDeal pool={pool} />}
{activeTab === PoolAction.Vest && <Vest pool={pool} />}
{activeTab === PoolAction.Vest && <Vest handleTransfer={handleTransfer} pool={pool} />}
{activeTab === PoolAction.WithdrawUnredeemed && <WithdrawUnredeemed pool={pool} />}
{activeTab === PoolAction.SponsorClaim && <SponsorClaim pool={pool} />}
</>
)
}

function UpfrontDealActionTabs({ activeTab, derivedStatus, funding, pool }: DealActionTabsProps) {
function UpfrontDealActionTabs({
activeTab,
derivedStatus,
funding,
handleTransfer,
pool,
}: DealActionTabsProps) {
return (
<>
{!activeTab && <NoActions pool={pool} status={derivedStatus} />}
Expand All @@ -256,7 +291,9 @@ function UpfrontDealActionTabs({ activeTab, derivedStatus, funding, pool }: Deal
<WaitingForDeal isUpfrontDeal={!!pool.upfrontDeal} />
)}
{activeTab === PoolAction.FundDeal && <FundDeal pool={pool} />}
{activeTab === PoolAction.Vest && <VestUpfrontDeal pool={pool} />}
{activeTab === PoolAction.Vest && (
<VestUpfrontDeal handleTransfer={handleTransfer} pool={pool} />
)}
{activeTab === PoolAction.Settle && (
<ClaimUpfrontDealTokens
pool={pool}
Expand Down
Loading

0 comments on commit 029872b

Please sign in to comment.