-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: approval screens for the new Etna tx types (#87)
- Loading branch information
Showing
8 changed files
with
330 additions
and
0 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
108 changes: 108 additions & 0 deletions
108
src/pages/ApproveAction/components/ApproveConvertSubnetToL1.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,108 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
import { Divider, Stack, Typography } from '@avalabs/core-k2-components'; | ||
|
||
import { | ||
ApprovalSection, | ||
ApprovalSectionBody, | ||
ApprovalSectionHeader, | ||
} from '@src/components/common/approval/ApprovalSection'; | ||
import { TxDetailsRow } from '@src/components/common/approval/TxDetailsRow'; | ||
|
||
import { TruncatedIdentifier } from './TruncatedIdentifier'; | ||
import { AvaxAmount } from './AvaxAmount'; | ||
import { Avalanche } from '@avalabs/core-wallets-sdk'; | ||
|
||
export function ApproveConvertSubnetToL1({ | ||
tx, | ||
avaxPrice, | ||
}: { | ||
tx: Avalanche.ConvertSubnetToL1Tx; | ||
avaxPrice: number; | ||
}) { | ||
const { t } = useTranslation(); | ||
const { txFee, chainID, managerAddress, subnetID, validators } = tx; | ||
|
||
return ( | ||
<> | ||
<ApprovalSection sx={{ gap: 1 }}> | ||
<ApprovalSectionHeader label={t('Subnet Details')} /> | ||
<ApprovalSectionBody sx={{ justifyContent: 'start', py: 2.25 }}> | ||
<TxDetailsRow label={t('Subnet ID')}> | ||
<TruncatedIdentifier identifier={subnetID} size={14} /> | ||
</TxDetailsRow> | ||
<TxDetailsRow label={t('Chain ID')}> | ||
<TruncatedIdentifier identifier={chainID} size={14} /> | ||
</TxDetailsRow> | ||
<TxDetailsRow label={t('Manager Address')}> | ||
<TruncatedIdentifier identifier={managerAddress} size={14} /> | ||
</TxDetailsRow> | ||
</ApprovalSectionBody> | ||
</ApprovalSection> | ||
<ApprovalSection sx={{ gap: 1 }}> | ||
<ApprovalSectionHeader label={t('Validators')} /> | ||
<ApprovalSectionBody | ||
sx={{ justifyContent: 'start', py: 2.25 }} | ||
divider={<Divider sx={{ my: 1.5 }} />} | ||
> | ||
{validators.map( | ||
({ | ||
balance, | ||
stake, | ||
nodeId, | ||
remainingBalanceOwners, | ||
deactivationOwners, | ||
}) => ( | ||
<Stack key={nodeId} sx={{ gap: 0.5 }}> | ||
<TxDetailsRow label={t('Node ID')}> | ||
<TruncatedIdentifier identifier={nodeId} size={14} /> | ||
</TxDetailsRow> | ||
<TxDetailsRow label={t('Balance')}> | ||
<AvaxAmount amount={balance} avaxPrice={avaxPrice} /> | ||
</TxDetailsRow> | ||
<TxDetailsRow label={t('Stake')}> | ||
<AvaxAmount amount={stake} avaxPrice={avaxPrice} /> | ||
</TxDetailsRow> | ||
<Stack sx={{ gap: 1, mb: 2 }}> | ||
<Typography variant="caption" color="text.secondary"> | ||
{t('Owners Able to Deactivate')} | ||
</Typography> | ||
<Stack sx={{ pl: 2, gap: 0.5 }}> | ||
{deactivationOwners.map((address) => ( | ||
<TruncatedIdentifier | ||
key={address} | ||
identifier={address} | ||
size={14} | ||
/> | ||
))} | ||
</Stack> | ||
</Stack> | ||
<Stack sx={{ gap: 1 }}> | ||
<Typography variant="caption" color="text.secondary"> | ||
{t('Owners of the Remaining Balance')} | ||
</Typography> | ||
<Stack sx={{ pl: 2, gap: 0.5 }}> | ||
{remainingBalanceOwners.map((address) => ( | ||
<TruncatedIdentifier | ||
key={address} | ||
identifier={address} | ||
size={14} | ||
/> | ||
))} | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
) | ||
)} | ||
</ApprovalSectionBody> | ||
</ApprovalSection> | ||
<ApprovalSection> | ||
<ApprovalSectionHeader label={t('Network Fee')} /> | ||
<ApprovalSectionBody> | ||
<TxDetailsRow label={t('Fee Amount')}> | ||
<AvaxAmount amount={txFee} avaxPrice={avaxPrice} /> | ||
</TxDetailsRow> | ||
</ApprovalSectionBody> | ||
</ApprovalSection> | ||
</> | ||
); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/pages/ApproveAction/components/ApproveDisableL1Validator.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,45 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
ApprovalSection, | ||
ApprovalSectionBody, | ||
ApprovalSectionHeader, | ||
} from '@src/components/common/approval/ApprovalSection'; | ||
import { TxDetailsRow } from '@src/components/common/approval/TxDetailsRow'; | ||
|
||
import { AvaxAmount } from './AvaxAmount'; | ||
import { Avalanche } from '@avalabs/core-wallets-sdk'; | ||
import { TruncatedIdentifier } from './TruncatedIdentifier'; | ||
|
||
export function ApproveDisableL1Validator({ | ||
tx, | ||
avaxPrice, | ||
}: { | ||
tx: Avalanche.DisableL1ValidatorTx; | ||
avaxPrice: number; | ||
}) { | ||
const { t } = useTranslation(); | ||
|
||
const { txFee, validationId } = tx; | ||
|
||
return ( | ||
<> | ||
<ApprovalSection sx={{ gap: 1 }}> | ||
<ApprovalSectionHeader label={t('Details')} /> | ||
<ApprovalSectionBody sx={{ justifyContent: 'start', py: 2.25 }}> | ||
<TxDetailsRow label={t('Validation ID')}> | ||
<TruncatedIdentifier identifier={validationId} /> | ||
</TxDetailsRow> | ||
</ApprovalSectionBody> | ||
</ApprovalSection> | ||
<ApprovalSection> | ||
<ApprovalSectionHeader label={t('Network Fee')} /> | ||
<ApprovalSectionBody> | ||
<TxDetailsRow label={t('Fee Amount')}> | ||
<AvaxAmount amount={txFee} avaxPrice={avaxPrice} /> | ||
</TxDetailsRow> | ||
</ApprovalSectionBody> | ||
</ApprovalSection> | ||
</> | ||
); | ||
} |
48 changes: 48 additions & 0 deletions
48
src/pages/ApproveAction/components/ApproveIncreaseL1ValidatorBalance.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,48 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
ApprovalSection, | ||
ApprovalSectionBody, | ||
ApprovalSectionHeader, | ||
} from '@src/components/common/approval/ApprovalSection'; | ||
import { TxDetailsRow } from '@src/components/common/approval/TxDetailsRow'; | ||
|
||
import { AvaxAmount } from './AvaxAmount'; | ||
import { Avalanche } from '@avalabs/core-wallets-sdk'; | ||
import { TruncatedIdentifier } from './TruncatedIdentifier'; | ||
|
||
export function ApproveIncreaseL1ValidatorBalance({ | ||
tx, | ||
avaxPrice, | ||
}: { | ||
tx: Avalanche.IncreaseL1ValidatorBalanceTx; | ||
avaxPrice: number; | ||
}) { | ||
const { t } = useTranslation(); | ||
|
||
const { txFee, balance, validationId } = tx; | ||
|
||
return ( | ||
<> | ||
<ApprovalSection sx={{ gap: 1 }}> | ||
<ApprovalSectionHeader label={t('Details')} /> | ||
<ApprovalSectionBody sx={{ justifyContent: 'start', py: 2.25 }}> | ||
<TxDetailsRow label={t('Validation ID')}> | ||
<TruncatedIdentifier identifier={validationId} /> | ||
</TxDetailsRow> | ||
<TxDetailsRow label={t('Increase by amount')}> | ||
<AvaxAmount amount={balance} avaxPrice={avaxPrice} /> | ||
</TxDetailsRow> | ||
</ApprovalSectionBody> | ||
</ApprovalSection> | ||
<ApprovalSection> | ||
<ApprovalSectionHeader label={t('Network Fee')} /> | ||
<ApprovalSectionBody> | ||
<TxDetailsRow label={t('Fee Amount')}> | ||
<AvaxAmount amount={txFee} avaxPrice={avaxPrice} /> | ||
</TxDetailsRow> | ||
</ApprovalSectionBody> | ||
</ApprovalSection> | ||
</> | ||
); | ||
} |
43 changes: 43 additions & 0 deletions
43
src/pages/ApproveAction/components/ApproveRegisterL1Validator.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,43 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
ApprovalSection, | ||
ApprovalSectionBody, | ||
ApprovalSectionHeader, | ||
} from '@src/components/common/approval/ApprovalSection'; | ||
import { TxDetailsRow } from '@src/components/common/approval/TxDetailsRow'; | ||
|
||
import { AvaxAmount } from './AvaxAmount'; | ||
import { Avalanche } from '@avalabs/core-wallets-sdk'; | ||
|
||
export function ApproveRegisterL1Validator({ | ||
tx, | ||
avaxPrice, | ||
}: { | ||
tx: Avalanche.RegisterL1ValidatorTx; | ||
avaxPrice: number; | ||
}) { | ||
const { t } = useTranslation(); | ||
const { txFee, balance } = tx; | ||
|
||
return ( | ||
<> | ||
<ApprovalSection sx={{ gap: 1 }}> | ||
<ApprovalSectionHeader label={t('Details')} /> | ||
<ApprovalSectionBody sx={{ justifyContent: 'start', py: 2.25 }}> | ||
<TxDetailsRow label={t('Initial balance')}> | ||
<AvaxAmount amount={balance} avaxPrice={avaxPrice} /> | ||
</TxDetailsRow> | ||
</ApprovalSectionBody> | ||
</ApprovalSection> | ||
<ApprovalSection> | ||
<ApprovalSectionHeader label={t('Network Fee')} /> | ||
<ApprovalSectionBody> | ||
<TxDetailsRow label={t('Fee Amount')}> | ||
<AvaxAmount amount={txFee} avaxPrice={avaxPrice} /> | ||
</TxDetailsRow> | ||
</ApprovalSectionBody> | ||
</ApprovalSection> | ||
</> | ||
); | ||
} |
35 changes: 35 additions & 0 deletions
35
src/pages/ApproveAction/components/ApproveSetL1ValidatorWeight.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,35 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
ApprovalSection, | ||
ApprovalSectionBody, | ||
ApprovalSectionHeader, | ||
} from '@src/components/common/approval/ApprovalSection'; | ||
import { TxDetailsRow } from '@src/components/common/approval/TxDetailsRow'; | ||
|
||
import { AvaxAmount } from './AvaxAmount'; | ||
import { Avalanche } from '@avalabs/core-wallets-sdk'; | ||
|
||
export function ApproveSetL1ValidatorWeight({ | ||
tx, | ||
avaxPrice, | ||
}: { | ||
tx: Avalanche.SetL1ValidatorWeightTx; | ||
avaxPrice: number; | ||
}) { | ||
const { t } = useTranslation(); | ||
const { txFee } = tx; | ||
|
||
return ( | ||
<> | ||
<ApprovalSection> | ||
<ApprovalSectionHeader label={t('Network Fee')} /> | ||
<ApprovalSectionBody> | ||
<TxDetailsRow label={t('Fee Amount')}> | ||
<AvaxAmount amount={txFee} avaxPrice={avaxPrice} /> | ||
</TxDetailsRow> | ||
</ApprovalSectionBody> | ||
</ApprovalSection> | ||
</> | ||
); | ||
} |
Oops, something went wrong.