Skip to content

Commit

Permalink
feat: cross and multi-sign
Browse files Browse the repository at this point in the history
  • Loading branch information
heisenberg-2077 committed May 22, 2024
1 parent 5536e4a commit 8ae7772
Show file tree
Hide file tree
Showing 3 changed files with 344 additions and 294 deletions.
291 changes: 156 additions & 135 deletions src/ui/views/Approval/components/Actions/CrossSwapToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useRabbyDispatch, useRabbySelector } from '@/ui/store';
import { SecurityListItem } from './components/SecurityListItem';
import { ProtocolListItem } from './components/ProtocolListItem';
import { isSameAddress } from '@/ui/utils';
import { SubCol, SubRow, SubTable } from './components/SubTable';

const Wrapper = styled.div`
.header {
Expand Down Expand Up @@ -106,6 +107,7 @@ const CrossSwapToken = ({
<Row isTitle>{t('page.signTx.swap.payToken')}</Row>
<Row>
<LogoWithText
id="cross-swap-token-pay"
logo={payToken.logo_url}
text={
<>
Expand All @@ -115,164 +117,183 @@ const CrossSwapToken = ({
}
logoRadius="100%"
/>
<ul className="desc-list">
<li>
{formatUsdValue(
new BigNumber(payToken.amount).times(payToken.price).toFixed()
)}
</li>
<li>
<Values.DisplayChain chainServerId={payToken.chain} />
</li>
</ul>
</Row>
</Col>
<SubTable target="cross-swap-token-pay">
<SubCol>
<SubRow isTitle>{t('page.signTx.chain')}</SubRow>
<SubRow>
<Values.DisplayChain chainServerId={payToken.chain} />
</SubRow>
</SubCol>
</SubTable>

<Col>
<Row isTitle>{t('page.signTx.swap.minReceive')}</Row>
<Row>
<div className="flex relative pr-10">
<LogoWithText
logo={receiveToken.logo_url}
logoRadius="100%"
text={
<>
{formatAmount(receiveToken.min_amount)}{' '}
<Values.TokenSymbol token={receiveToken} />
</>
}
icon={
<Values.TokenLabel
isFake={receiveToken.is_verified === false}
isScam={
receiveToken.is_verified !== false &&
!!receiveToken.is_suspicious
}
/>
}
/>
{engineResultMap['1107'] && (
<SecurityLevelTagNoText
enable={engineResultMap['1107'].enable}
level={
processedRules.includes('1107')
? 'proceed'
: engineResultMap['1107'].level
}
onClick={() => handleClickRule('1107')}
/>
)}
{engineResultMap['1108'] && (
<SecurityLevelTagNoText
enable={engineResultMap['1108'].enable}
level={
processedRules.includes('1108')
? 'proceed'
: engineResultMap['1108'].level
<LogoWithText
id="cross-swap-token-receive"
logo={receiveToken.logo_url}
logoRadius="100%"
text={
<>
{formatAmount(receiveToken.min_amount)}{' '}
<Values.TokenSymbol token={receiveToken} />
</>
}
icon={
<Values.TokenLabel
isFake={receiveToken.is_verified === false}
isScam={
receiveToken.is_verified !== false &&
!!receiveToken.is_suspicious
}
onClick={() => handleClickRule('1108')}
/>
)}
</div>
<ul className="desc-list">
<li>
{formatUsdValue(
new BigNumber(receiveToken.min_amount)
.times(receiveToken.price)
.toFixed()
)}
</li>
<li>
<Values.DisplayChain chainServerId={receiveToken.chain} />
</li>
<SecurityListItem
engineResult={engineResultMap['1104']}
id="1104"
dangerText={
<>
{t('page.signTx.swap.valueDiff')}{' '}
<Values.Percentage value={usdValuePercentage!} /> (
{formatUsdValue(usdValueDiff || '')})
</>
}
/>
{engineResultMap['1107'] && (
<SecurityLevelTagNoText
enable={engineResultMap['1107'].enable}
level={
processedRules.includes('1107')
? 'proceed'
: engineResultMap['1107'].level
}
warningText={
<>
{t('page.signTx.swap.valueDiff')}{' '}
<Values.Percentage value={usdValuePercentage!} /> (
{formatUsdValue(usdValueDiff || '')})
</>
onClick={() => handleClickRule('1107')}
/>
)}
{engineResultMap['1108'] && (
<SecurityLevelTagNoText
enable={engineResultMap['1108'].enable}
level={
processedRules.includes('1108')
? 'proceed'
: engineResultMap['1108'].level
}
onClick={() => handleClickRule('1108')}
/>
</ul>
)}
</Row>
</Col>
<SubTable target="cross-swap-token-receive">
<SubCol>
<SubRow isTitle>{t('page.signTx.chain')}</SubRow>
<SubRow>
<Values.DisplayChain chainServerId={receiveToken.chain} />
</SubRow>
</SubCol>
<SecurityListItem
engineResult={engineResultMap['1104']}
id="1104"
dangerText={
<>
<Values.Percentage value={usdValuePercentage!} /> (
{formatUsdValue(usdValueDiff || '')})
</>
}
warningText={
<>
<Values.Percentage value={usdValuePercentage!} /> (
{formatUsdValue(usdValueDiff || '')})
</>
}
title={t('page.signTx.swap.valueDiff')}
/>
</SubTable>
{hasReceiver && (
<Col>
<Row isTitle>{t('page.signTx.swap.receiver')}</Row>
<Row>
<Values.Address address={receiver} chain={chain} />
<ul className="desc-list">
<SecurityListItem
engineResult={engineResultMap['1096']}
id="1096"
warningText={t('page.signTx.swap.unknownAddress')}
<>
<Col>
<Row isTitle>{t('page.signTx.swap.receiver')}</Row>
<Row>
<Values.Address
id="cross-swap-token-receiver"
address={receiver}
chain={chain}
/>
{!engineResultMap['1096'] && (
<>
<li>
</Row>
</Col>
<SubTable target="cross-swap-token-receiver">
<SecurityListItem
engineResult={engineResultMap['1096']}
id="1096"
warningText={t('page.signTx.swap.unknownAddress')}
/>
{!engineResultMap['1096'] && (
<>
<SubCol>
<SubRow isTitle>{t('page.signTx.address')}</SubRow>
<SubRow>
<Values.AccountAlias address={receiver} />
</li>
<li>
</SubRow>
</SubCol>
<SubCol>
<SubRow isTitle>{t('page.addressDetail.source')}</SubRow>
<SubRow>
<Values.KnownAddress address={receiver} />
</li>
</>
)}
</ul>
</Row>
</Col>
</SubRow>
</SubCol>
</>
)}
</SubTable>
</>
)}
<Col>
<Row isTitle>{t('page.signTx.interactContract')}</Row>
<Row>
<div>
<Values.Address address={requireData.id} chain={chain} />
</div>
<ul className="desc-list">
<ProtocolListItem protocol={requireData.protocol} />
<li>
<Values.Interacted value={requireData.hasInteraction} />
</li>

{isInWhitelist && <li>{t('page.signTx.markAsTrust')}</li>}

<SecurityListItem
id="1135"
engineResult={engineResultMap['1135']}
forbiddenText={t('page.signTx.markAsBlock')}
/>

<SecurityListItem
id="1137"
engineResult={engineResultMap['1137']}
warningText={t('page.signTx.markAsBlock')}
<ViewMore
type="contract"
data={{
hasInteraction: requireData.hasInteraction,
bornAt: requireData.bornAt,
protocol: requireData.protocol,
rank: requireData.rank,
address: requireData.id,
chain,
}}
>
<Values.Address
id="cross-swap-token-address"
hasHover
address={requireData.id}
chain={chain}
/>
<li>
<ViewMore
type="contract"
data={{
hasInteraction: requireData.hasInteraction,
bornAt: requireData.bornAt,
protocol: requireData.protocol,
rank: requireData.rank,
address: requireData.id,
chain,
}}
/>
</li>
</ul>
</ViewMore>
</Row>
</Col>
<SubTable target="cross-swap-token-address">
<SubCol>
<SubRow isTitle>{t('page.signTx.protocol')}</SubRow>
<SubRow>
<ProtocolListItem protocol={requireData.protocol} />
</SubRow>
</SubCol>
<SubCol>
<SubRow isTitle>{t('page.signTx.hasInteraction')}</SubRow>
<SubRow>
<Values.Interacted value={requireData.hasInteraction} />
</SubRow>
</SubCol>
{isInWhitelist && (
<SubCol>
<SubRow isTitle>{t('page.signTx.myMark')}</SubRow>
<SubRow>{t('page.signTx.trusted')}</SubRow>
</SubCol>
)}

<SecurityListItem
id="1135"
engineResult={engineResultMap['1135']}
forbiddenText={t('page.signTx.markAsBlock')}
title={t('page.signTx.myMark')}
/>

<SecurityListItem
id="1137"
engineResult={engineResultMap['1137']}
warningText={t('page.signTx.markAsBlock')}
title={t('page.signTx.myMark')}
/>
</SubTable>
</Table>
</Wrapper>
);
Expand Down
Loading

0 comments on commit 8ae7772

Please sign in to comment.