Skip to content

Commit

Permalink
Merge pull request #277 from Outblock/move-and-register-page-refactor
Browse files Browse the repository at this point in the history
Move and register page refactor
  • Loading branch information
zzggo authored Dec 20, 2024
2 parents d7847bc + dff5dda commit 6be4f8d
Show file tree
Hide file tree
Showing 114 changed files with 2,641 additions and 15,865 deletions.
1 change: 0 additions & 1 deletion src/background/controller/provider/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@ class ProviderController extends BaseController {

const hash = TypedDataUtils.eip712Hash(message, SignTypedDataVersion.V4);

console.log('SignTypedDataVersion.V4 ', hash);
const result = await signTypeData(hash);
signTextHistoryService.createHistory({
address: address,
Expand Down
27 changes: 26 additions & 1 deletion src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export class WalletController extends BaseController {
await passwordService.clear();
sessionService.broadcastEvent('accountsChanged', []);
sessionService.broadcastEvent('lock');
openIndexPage('addwelcome');
openIndexPage('welcome');
await this.switchNetwork(switchingTo);
};

Expand Down Expand Up @@ -4125,6 +4125,31 @@ export class WalletController extends BaseController {
decodeEvmCall = async (callData: string, address = '') => {
return await openapiService.decodeEvmCall(callData, address);
};

saveIndex = async (username = '', userId = null) => {
const loggedInAccounts = (await storage.get('loggedInAccounts')) || [];
let currentindex = 0;

if (!loggedInAccounts || loggedInAccounts.length === 0) {
currentindex = 0;
} else {
const index = loggedInAccounts.findIndex((account) => account.username === username);
currentindex = index !== -1 ? index : loggedInAccounts.length;
}

const path = (await storage.get('temp_path')) || "m/44'/539'/0'/0/0";
const passphrase = (await storage.get('temp_phrase')) || '';
await storage.set(`user${currentindex}_path`, path);
await storage.set(`user${currentindex}_phrase`, passphrase);
await storage.set(`user${userId}_path`, path);
await storage.set(`user${userId}_phrase`, passphrase);
await storage.remove(`temp_path`);
await storage.remove(`temp_phrase`);
await storage.set('currentAccountIndex', currentindex);
if (userId) {
await storage.set('currentId', userId);
}
};
}

export default new WalletController();
301 changes: 301 additions & 0 deletions src/ui/FRWComponent/GeneralPages/NFTDrawer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
// src/ui/views/MoveBoard/components/NFTMoveDrawer.tsx
import CloseIcon from '@mui/icons-material/Close';
import { Box, Button, Typography, Drawer, IconButton, CardMedia, Skeleton } from '@mui/material';
import React from 'react';

import moveSelectDrop from 'ui/FRWAssets/svg/moveSelectDrop.svg';
import selected from 'ui/FRWAssets/svg/selected.svg';
import { LLSpinner } from 'ui/FRWComponent';

interface NFTMoveDrawerProps {
showMoveBoard: boolean;
handleCancelBtnClicked: () => void;
isLoading: boolean;
currentCollection: any;
collectionDetail: any;
nftIdArray: number[];
onCollectionSelect: () => void;
onNFTSelect: (nftId: number) => void;
sending: boolean;
failed: boolean;
onMove: () => void;
moveType: 'toChild' | 'fromChild' | 'evm';
AccountComponent: React.ReactNode;
nfts: any[];
replaceIPFS?: (url: string) => string;
}

export const NFTMoveDrawer: React.FC<NFTMoveDrawerProps> = ({
showMoveBoard,
handleCancelBtnClicked,
isLoading,
currentCollection,
collectionDetail,
nftIdArray,
onCollectionSelect,
onNFTSelect,
sending,
failed,
onMove,
moveType,
AccountComponent,
nfts,
replaceIPFS = (url) => url,
}) => {
return (
<Drawer
anchor="bottom"
sx={{ zIndex: '1100 !important' }}
transitionDuration={300}
open={showMoveBoard}
PaperProps={{
sx: { width: '100%', height: 'calc(100% - 56px)', background: '#222' },
}}
>
{/* Header */}
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '10px', px: '20px' }}>
<Box
sx={{
display: 'flex',
justifyContent: 'space-between',
width: '100%',
height: '24px',
margin: '20px 0',
alignItems: 'center',
}}
>
<Box sx={{ width: '40px' }}></Box>
<Typography
variant="body1"
component="div"
display="inline"
color="text"
sx={{
fontSize: '20px',
textAlign: 'center',
fontFamily: 'e-Ukraine',
lineHeight: '24px',
fontWeight: '700',
}}
>
{chrome.i18n.getMessage('select')} NFTs
</Typography>
<IconButton onClick={handleCancelBtnClicked}>
<CloseIcon fontSize="medium" sx={{ color: 'icon.navi', cursor: 'pointer' }} />
</IconButton>
</Box>
</Box>

{AccountComponent}

<Box
sx={{
display: 'flex',
justifyContent: 'space-between',
mb: '0',
mt: '10px',
padding: '0 18px',
}}
>
<Box sx={{ height: '24px', padding: '6px 0' }}>
<Typography
variant="body1"
component="div"
display="inline"
color="text"
sx={{ fontSize: '14px', textAlign: 'center', lineHeight: '24px', fontWeight: '600' }}
>
{chrome.i18n.getMessage('collection')}
</Typography>
</Box>

{currentCollection && collectionDetail && (
<Button onClick={onCollectionSelect}>
{currentCollection.logo && (
<CardMedia
component="img"
sx={{
width: '24px',
height: '24px',
display: 'inline',
borderRadius: '8px',
marginRight: '8px',
objectFit: 'cover',
objectPosition: 'left !important',
}}
image={currentCollection.logo}
/>
)}
<Typography
variant="body1"
component="div"
display="inline"
color="text"
sx={{ fontSize: '14px', textAlign: 'center', lineHeight: '24px', fontWeight: '600' }}
>
{currentCollection.CollectionName}
</Typography>
<CardMedia
component="img"
sx={{ width: '12px', height: '12px', marginLeft: '4px' }}
image={'https://raw.githubusercontent.com/Outblock/Assets/main/ft/flow/logo.png'}
/>
<CardMedia
component="img"
sx={{ width: '16px', height: '16px', marginLeft: '4px' }}
image={moveSelectDrop}
/>
</Button>
)}
</Box>

{!isLoading ? (
<Box
sx={{
display: 'flex',
mb: '18px',
padding: '16px',
gap: '4px',
flexWrap: 'wrap',
justifyContent: 'flex-start',
height: '150px',
overflowY: 'scroll',
}}
>
{nfts && nfts.length > 0 ? (
nfts.map((nft) => (
<Box
key={nft.id}
sx={{
display: 'flex',
position: 'relative',
width: '84px',
height: '84px',
borderRadius: '16px',
marginBottom: '3px',
border: nftIdArray.includes(nft.id) && '1px solid #41CC5D',
}}
>
<Button
onClick={() => onNFTSelect(nft.id)}
sx={{ padding: 0, borderRadius: '16px', backgroundColor: '#333' }}
>
{nftIdArray.includes(nft.id) && (
<Box
sx={{
backgroundColor: '#00000099',
borderRadius: '16px',
position: 'absolute',
width: '100%',
height: '100%',
}}
>
<CardMedia
component="img"
sx={{
width: '16px',
borderRadius: '16px',
height: '16px',
top: '8px',
right: '8px',
zIndex: '2000',
position: 'absolute',
}}
image={selected}
/>
</Box>
)}
<CardMedia
component="img"
alt={nft.name}
height="84px"
width="84px"
sx={{ borderRadius: '16px' }}
image={moveType === 'evm' ? nft.thumbnail : replaceIPFS(nft.thumbnail)}
title={nft.name}
/>
</Button>
</Box>
))
) : (
<Box sx={{ width: '100%', textAlign: 'center' }}>
<Typography sx={{ color: '#FFFFFF66', fontSize: '14px', fontWeight: '700' }}>
0 NFTs
</Typography>
</Box>
)}
</Box>
) : (
<LoadingGrid />
)}

<Box sx={{ flex: '1' }}></Box>
<Box sx={{ px: '16px' }}>
<Button
onClick={onMove}
variant="contained"
color="success"
size="large"
disabled={!collectionDetail || nfts.length === 0}
sx={{
height: '50px',
width: '100%',
borderRadius: '12px',
textTransform: 'capitalize',
display: 'flex',
gap: '12px',
marginBottom: '33px',
}}
>
{sending ? (
<>
<LLSpinner size={28} />
<Typography variant="subtitle1" sx={{ fontWeight: 'bold' }} color="text.primary">
{chrome.i18n.getMessage('Sending')}
</Typography>
</>
) : (
<>
{failed ? (
<Typography variant="subtitle1" sx={{ fontWeight: 'bold' }} color="text.primary">
{chrome.i18n.getMessage('Transaction__failed')}
</Typography>
) : (
<Typography variant="subtitle1" sx={{ fontWeight: 'bold' }} color="text.primary">
{chrome.i18n.getMessage('Move')} {nftIdArray.length > 0 && nftIdArray.length} NFT
{nftIdArray.length > 1 && 's'}
</Typography>
)}
</>
)}
</Button>
</Box>
</Drawer>
);
};

const LoadingGrid = () => (
<Box sx={{ display: 'flex', mb: '18px', padding: '18px', gap: '4px' }}>
{[...Array(4)].map((_, index) => (
<Box
key={index}
sx={{
display: 'flex',
width: '84px',
height: '84px',
borderRadius: '16px',
backgroundColor: '#333',
}}
>
<Skeleton
variant="rectangular"
width={84}
height={84}
sx={{ margin: '0 auto', borderRadius: '16px' }}
/>
</Box>
))}
</Box>
);

export default NFTMoveDrawer;
1 change: 1 addition & 0 deletions src/ui/FRWComponent/GeneralPages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as NFTDrawer } from './NFTDrawer';
2 changes: 1 addition & 1 deletion src/ui/FRWComponent/LLNotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const LLNotFound = ({ setShowDialog }) => {
<Button
variant="contained"
color="primary"
onClick={() => history.push('/recover')}
onClick={() => history.push('/welcome')}
disableElevation
fullWidth
sx={{
Expand Down
Loading

0 comments on commit 6be4f8d

Please sign in to comment.