-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into feat/adjust-points-page-to…
…-mobile
- Loading branch information
Showing
59 changed files
with
1,549 additions
and
1,237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
...mint/components/attestor-approvement-pending-stack/attestor-approvement-pending-stack.tsx
This file was deleted.
Oops, something went wrong.
110 changes: 110 additions & 0 deletions
110
...app/components/mint-unmint/components/burn-transaction-screen/burn-transaction-screen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import { useContext } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import { VStack, useToast } from '@chakra-ui/react'; | ||
import { VaultTransactionForm } from '@components/transaction-screen/transaction-screen.transaction-form/components/transaction-screen.transaction-form/transaction-screen.transaction-form'; | ||
import { Vault } from '@components/vault/vault'; | ||
import { useEthersSigner } from '@functions/configuration.functions'; | ||
import { getAndFormatVault } from '@functions/vault.functions'; | ||
import { BitcoinWalletContext } from '@providers/bitcoin-wallet-context-provider'; | ||
import { EthereumNetworkConfigurationContext } from '@providers/ethereum-network-configuration.provider'; | ||
import { ProofOfReserveContext } from '@providers/proof-of-reserve-context-provider'; | ||
import { VaultContext } from '@providers/vault-context-provider'; | ||
import { RootState } from '@store/index'; | ||
import { mintUnmintActions } from '@store/slices/mintunmint/mintunmint.actions'; | ||
import { vaultActions } from '@store/slices/vault/vault.actions'; | ||
import { withdraw } from 'dlc-btc-lib/ethereum-functions'; | ||
import { EthereumNetworkID } from 'dlc-btc-lib/models'; | ||
import { shiftValue } from 'dlc-btc-lib/utilities'; | ||
import { useAccount } from 'wagmi'; | ||
|
||
interface BurnTokenTransactionFormProps { | ||
isBitcoinWalletLoading: [boolean, string]; | ||
userEthereumAddressRiskLevel: string; | ||
fetchUserEthereumAddressRiskLevel: () => Promise<string>; | ||
isUserEthereumAddressRiskLevelLoading: boolean; | ||
} | ||
|
||
export function BurnTokenTransactionForm({ | ||
isBitcoinWalletLoading, | ||
userEthereumAddressRiskLevel, | ||
fetchUserEthereumAddressRiskLevel, | ||
isUserEthereumAddressRiskLevelLoading, | ||
}: BurnTokenTransactionFormProps): React.JSX.Element { | ||
const toast = useToast(); | ||
const dispatch = useDispatch(); | ||
|
||
const { bitcoinWalletContextState } = useContext(BitcoinWalletContext); | ||
|
||
const { ethereumNetworkConfiguration } = useContext(EthereumNetworkConfigurationContext); | ||
const { bitcoinPrice, depositLimit } = useContext(ProofOfReserveContext); | ||
const { allVaults } = useContext(VaultContext); | ||
|
||
const { chainId } = useAccount(); | ||
|
||
const signer = useEthersSigner(); | ||
|
||
const { unmintStep } = useSelector((state: RootState) => state.mintunmint); | ||
|
||
const currentVault = allVaults.find(vault => vault.uuid === unmintStep[1]); | ||
|
||
async function handleButtonClick(withdrawAmount: number): Promise<void> { | ||
if (!currentVault) return; | ||
|
||
try { | ||
const currentRisk = await fetchUserEthereumAddressRiskLevel(); | ||
if (currentRisk === 'High') throw new Error('Risk Level is too high'); | ||
const formattedWithdrawAmount = BigInt(shiftValue(withdrawAmount)); | ||
|
||
await withdraw( | ||
ethereumNetworkConfiguration.dlcManagerContract.connect(signer!), | ||
currentVault.uuid, | ||
formattedWithdrawAmount | ||
); | ||
|
||
await getAndFormatVault(currentVault.uuid, ethereumNetworkConfiguration.dlcManagerContract) | ||
.then(vault => { | ||
dispatch( | ||
vaultActions.swapVault({ | ||
vaultUUID: currentVault.uuid, | ||
updatedVault: vault, | ||
networkID: chainId?.toString() as EthereumNetworkID, | ||
}) | ||
); | ||
}) | ||
.then(() => { | ||
dispatch(mintUnmintActions.setUnmintStep([1, currentVault.uuid])); | ||
}); | ||
} catch (error) { | ||
toast({ | ||
title: 'Failed to sign Transaction', | ||
description: error instanceof Error ? error.message : '', | ||
status: 'error', | ||
duration: 9000, | ||
isClosable: true, | ||
}); | ||
} | ||
} | ||
|
||
function handleCancel() { | ||
dispatch(mintUnmintActions.setUnmintStep([0, ''])); | ||
} | ||
|
||
return ( | ||
<VStack w={'45%'}> | ||
<Vault vault={currentVault!} /> | ||
<VaultTransactionForm | ||
vault={currentVault!} | ||
type={'burn'} | ||
currentBitcoinPrice={bitcoinPrice} | ||
handleButtonClick={handleButtonClick} | ||
depositLimit={depositLimit} | ||
bitcoinWalletContextState={bitcoinWalletContextState} | ||
isBitcoinWalletLoading={isBitcoinWalletLoading} | ||
userEthereumAddressRiskLevel={userEthereumAddressRiskLevel} | ||
isUserEthereumAddressRiskLevelLoading={isUserEthereumAddressRiskLevelLoading} | ||
handleCancelButtonClick={handleCancel} | ||
/> | ||
</VStack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,32 +7,38 @@ interface RiskBoxProps { | |
isRiskLoading: boolean; | ||
} | ||
|
||
export function RiskBox({ risk }: RiskBoxProps): React.JSX.Element { | ||
export function RiskBox({ risk }: RiskBoxProps): React.JSX.Element | false { | ||
if (!['High', 'Severe'].includes(risk)) return false; | ||
|
||
return ( | ||
<RiskBoxLayout> | ||
<HStack spacing={'5px'}> | ||
<Text color={'accent.lightBlue.01'} fontSize={'md'} fontWeight={200}> | ||
<HStack w={'100%'}> | ||
<Text color={'accent.lightBlue.01'} fontSize={'sm'} fontWeight={200}> | ||
Address Risk Level: | ||
</Text> | ||
<Text color={'error.01'} fontSize={'md'} fontWeight={800}> | ||
{risk} | ||
</Text> | ||
</HStack> | ||
<VStack gap={'0px'}> | ||
<Text color={'white.01'} fontWeight={200}> | ||
Potential suspicious activity detected, redemptions are temporarily suspended. | ||
</Text> | ||
<Text color={'white.01'}> | ||
<Link | ||
color={'accent.lightBlue.01'} | ||
href="mailto:[email protected]" | ||
isExternal | ||
textDecoration={'underline'} | ||
> | ||
Get in touch | ||
</Link>{' '} | ||
with your DLC.Link representative to resolve this issue. | ||
</Text> | ||
<VStack> | ||
<HStack w={'100%'}> | ||
<Text color={'white.01'} fontSize={'small'} fontWeight={'bold'}> | ||
Potential suspicious activity detected, redemptions are temporarily suspended. | ||
</Text> | ||
</HStack> | ||
<HStack w={'100%'}> | ||
<Text color={'white.01'} fontSize={'sm'}> | ||
<Link | ||
color={'accent.lightBlue.01'} | ||
href="mailto:[email protected]" | ||
isExternal | ||
textDecoration={'underline'} | ||
> | ||
Get in touch | ||
</Link>{' '} | ||
with your DLC.Link representative to resolve this issue. | ||
</Text> | ||
</HStack> | ||
</VStack> | ||
</RiskBoxLayout> | ||
); | ||
|
Oops, something went wrong.