Skip to content

Commit

Permalink
Merge branch 'main' into mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
iscander01 committed Oct 27, 2022
2 parents 8f1a649 + bd90096 commit fed08d1
Show file tree
Hide file tree
Showing 62 changed files with 814 additions and 501 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@linaria/core": "^3.0.0-beta.4",
"@linaria/react": "^3.0.0-beta.7",
"@types/readable-stream": "^2.3.11",
"@unstoppabledomains/resolution": "^8.3.3",
"babel-polyfill": "^6.26.0",
"beam-wasm-client": "7.1.13104",
"browser-passworder": "^2.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ const AssetBalance = ({ currentAsset }: AssetBalanceProps) => (
<div className="title">Available:</div>
<div className="value">
<div>
{fromGroths(currentAsset.available)}
{' '}
{currentAsset.metadata_pairs.UN}
{fromGroths(currentAsset.available)} {currentAsset.metadata_pairs.UN}
</div>
<br />
</div>
Expand All @@ -43,9 +41,7 @@ const AssetBalance = ({ currentAsset }: AssetBalanceProps) => (
<div className="title">Locked:</div>
<div className="value">
<div>
{fromGroths(currentAsset.sending)}
{' '}
{currentAsset.metadata_pairs.UN}
{fromGroths(currentAsset.sending)} {currentAsset.metadata_pairs.UN}
</div>
<br />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { styled } from '@linaria/react';

import { Window, Button, Footer } from '@app/shared/components';

import {
EyeIcon, PassIcon, CopyIcon, DoneIcon,
} from '@app/shared/icons';
import { EyeIcon, PassIcon, CopyIcon, DoneIcon } from '@app/shared/icons';

const WarningListStyled = styled.ul`
> li {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,7 @@ const PasswordStrength: React.FC<PasswordStrengthProps> = ({ value }) => {
<ListItemStyled key={index} points={p} />
))}
</ListStyled>
{title && (
<StrengthTitleStyled>
{title}
{' '}
password
</StrengthTitleStyled>
)}
{title && <StrengthTitleStyled>{title} password</StrengthTitleStyled>}
</ContainerStyled>
);
};
Expand Down
4 changes: 1 addition & 3 deletions src/app/containers/Auth/components/shared/SeedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ function fillFromSeed(seed: string, safe: boolean = false): void {
});
}

const SeedList: React.FC<SeedListProps> = ({
data, errors, initial, indexByValue, onInput,
}) => {
const SeedList: React.FC<SeedListProps> = ({ data, errors, initial, indexByValue, onInput }) => {
useEffect(() => {
if (initial) {
fillFromSeed(initial.replace(/\s/g, ';'), true);
Expand Down
4 changes: 2 additions & 2 deletions src/app/containers/Auth/containers/AuthBase/AuthBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const AuthBase: React.FC = () => {
<Popup
visible={warningVisible}
title="Restore wallet"
confirmButton={(
confirmButton={
<Button icon={DoneIcon} onClick={() => navigate(ROUTES.AUTH.RESTORE)}>
I agree
</Button>
)}
}
onCancel={() => toggleWarning(false)}
>
You are trying to restore an existing Beam Wallet.
Expand Down
8 changes: 3 additions & 5 deletions src/app/containers/Auth/containers/Login/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useState, useRef, useCallback } from 'react';

import {
Popup, Button, Input, Splash,
} from '@app/shared/components';
import { Popup, Button, Input, Splash } from '@app/shared/components';

import { WalletSmallIcon, DoneIcon } from '@app/shared/icons';

Expand Down Expand Up @@ -66,11 +64,11 @@ const Login: React.FC = () => {
<Popup
visible={warningVisible}
title="Restore wallet or create a new one"
confirmButton={(
confirmButton={
<Button icon={DoneIcon} onClick={() => navigate(ROUTES.AUTH.BASE)}>
I agree
</Button>
)}
}
onCancel={() => {
toggleWarning(false);
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, { useEffect, useState } from 'react';
import { styled } from '@linaria/react';

import {
Window, Popup, Button, Footer,
} from '@app/shared/components';
import { Window, Popup, Button, Footer } from '@app/shared/components';

import { ROUTES } from '@app/shared/constants';

Expand Down Expand Up @@ -99,11 +97,11 @@ const Registration: React.FC = () => {
<Popup
visible={warningVisible}
title="Save seed phrase"
confirmButton={(
confirmButton={
<Button icon={DoneIcon} onClick={handleNextClick}>
done
</Button>
)}
}
onCancel={handleCancel}
>
Please write the seed phrase down. Storing it in a file makes it prone to cyber attacks and, therefore, less
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useState } from 'react';

import {
Button, Footer, Popup, Window,
} from '@app/shared/components';
import { Button, Footer, Popup, Window } from '@app/shared/components';
import { ArrowRightIcon } from '@app/shared/icons';

import { ROUTES } from '@app/shared/constants';
Expand Down Expand Up @@ -73,11 +71,11 @@ const RegistrationConfirm: React.FC = () => {
visible={warningVisible}
title="Back to seed phrase"
footerClass="justify-right"
confirmButton={(
confirmButton={
<Button type="button" onClick={handlePrevious}>
generate
</Button>
)}
}
onCancel={() => toggleWarning(false)}
>
Your current seed will become obsolete and the new seed will be generated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, { useState } from 'react';
import { styled } from '@linaria/react';

import {
Window, Button, Input, Footer, Popup,
} from '@app/shared/components';
import { Window, Button, Input, Footer, Popup } from '@app/shared/components';

import { ArrowLeftIcon, ArrowRightIcon } from '@app/shared/icons';

Expand Down Expand Up @@ -141,11 +139,11 @@ const SetPassword = () => {
<Popup
visible={warningVisible}
title="Return to seed phrase"
confirmButton={(
confirmButton={
<Button icon={ArrowLeftIcon} onClick={handleReturnClick}>
return
</Button>
)}
}
onCancel={() => toggleWarning(false)}
>
If you return to seed phrase, it would be changed and your local password won’t be saved.
Expand Down
132 changes: 77 additions & 55 deletions src/app/containers/Auth/store/reducer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,60 +34,82 @@ const initialState: AuthStateType = {
};

const reducer = createReducer<AuthStateType, Action>(initialState)
.handleAction(actions.setSyncedWalletState, (state, action) => produce(state, (nexState) => {
nexState.is_wallet_synced = action.payload;
}))
.handleAction(actions.updateWalletSyncProgress, (state, action) => produce(state, (nexState) => {
nexState.sync_progress = action.payload;
}))
.handleAction(actions.setSyncStep, (state, action) => produce(state, (nexState) => {
nexState.sync_step = action.payload;
}))
.handleAction(actions.downloadDatabaseFile, (state, action) => produce(state, (nexState) => {
nexState.download_db_progress = action.payload;
}))
.handleAction(actions.restoreWallet, (state, action) => produce(state, (nexState) => {
nexState.database_sync_progress = action.payload;
}))
.handleAction(actions.updateSeedList.success, (state, action) => produce(state, (nexState) => {
const { seed_errors, seed_values } = state;
const new_values = [...seed_values];
const new_seed_errors = [...seed_errors];
new_values[action.payload.index] = action.payload.value;
new_seed_errors[action.payload.index] = action.payload.value ? action.payload.valid : null;
nexState.seed_errors = new_seed_errors;
nexState.seed_values = new_values;
}))
.handleAction(actions.resetRestoreState, (state) => produce(state, (nexState) => {
nexState.seed_errors = [...INITIAL];
nexState.seed_values = [...INITIAL];
}))
.handleAction(actions.checkIsAllowedSeed.success, (state, action) => produce(state, (nexState) => {
nexState.seed_errors = action.payload.valid;
nexState.seed_values = action.payload.values;
}))
.handleAction(actions.generateRegistrationSeed.success, (state, action) => produce(state, (nexState) => {
nexState.registration_seed = action.payload.registration_seed;
nexState.seed_ids = action.payload.seed_ids;
}))
.handleAction(actions.setRegistrationSeed, (state, action) => produce(state, (nexState) => {
nexState.registration_seed = action.payload.registration_seed;
nexState.is_restore = action.payload.is_restore;
}))
.handleAction(actions.setDefaultSyncState, (state) => produce(state, (nexState) => {
nexState.sync_step = SyncStep.SYNC;
nexState.sync_progress = {
sync_requests_done: 0,
sync_requests_total: 0,
};
nexState.download_db_progress = {
done: 0,
total: 0,
};
nexState.database_sync_progress = {
done: 0,
total: 0,
};
}));
.handleAction(actions.setSyncedWalletState, (state, action) =>
produce(state, (nexState) => {
nexState.is_wallet_synced = action.payload;
}),
)
.handleAction(actions.updateWalletSyncProgress, (state, action) =>
produce(state, (nexState) => {
nexState.sync_progress = action.payload;
}),
)
.handleAction(actions.setSyncStep, (state, action) =>
produce(state, (nexState) => {
nexState.sync_step = action.payload;
}),
)
.handleAction(actions.downloadDatabaseFile, (state, action) =>
produce(state, (nexState) => {
nexState.download_db_progress = action.payload;
}),
)
.handleAction(actions.restoreWallet, (state, action) =>
produce(state, (nexState) => {
nexState.database_sync_progress = action.payload;
}),
)
.handleAction(actions.updateSeedList.success, (state, action) =>
produce(state, (nexState) => {
const { seed_errors, seed_values } = state;
const new_values = [...seed_values];
const new_seed_errors = [...seed_errors];
new_values[action.payload.index] = action.payload.value;
new_seed_errors[action.payload.index] = action.payload.value ? action.payload.valid : null;
nexState.seed_errors = new_seed_errors;
nexState.seed_values = new_values;
}),
)
.handleAction(actions.resetRestoreState, (state) =>
produce(state, (nexState) => {
nexState.seed_errors = [...INITIAL];
nexState.seed_values = [...INITIAL];
}),
)
.handleAction(actions.checkIsAllowedSeed.success, (state, action) =>
produce(state, (nexState) => {
nexState.seed_errors = action.payload.valid;
nexState.seed_values = action.payload.values;
}),
)
.handleAction(actions.generateRegistrationSeed.success, (state, action) =>
produce(state, (nexState) => {
nexState.registration_seed = action.payload.registration_seed;
nexState.seed_ids = action.payload.seed_ids;
}),
)
.handleAction(actions.setRegistrationSeed, (state, action) =>
produce(state, (nexState) => {
nexState.registration_seed = action.payload.registration_seed;
nexState.is_restore = action.payload.is_restore;
}),
)
.handleAction(actions.setDefaultSyncState, (state) =>
produce(state, (nexState) => {
nexState.sync_step = SyncStep.SYNC;
nexState.sync_progress = {
sync_requests_done: 0,
sync_requests_total: 0,
};
nexState.download_db_progress = {
done: 0,
total: 0,
};
nexState.database_sync_progress = {
done: 0,
total: 0,
};
}),
);

export { reducer as AuthReducer };
4 changes: 1 addition & 3 deletions src/app/containers/Auth/store/saga.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import {
} from '@core/api';
import { navigate, setError, unlockWallet } from '@app/shared/store/actions';
import { ROUTES } from '@app/shared/constants';
import {
ConnectedData, Environment, NotificationType, SyncProgress,
} from '@core/types';
import { ConnectedData, Environment, NotificationType, SyncProgress } from '@core/types';
import NotificationController from '@core/NotificationController';
import { DatabaseSyncProgress, SyncStep } from '@app/containers/Auth/interfaces';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import NotificationController from '@core/NotificationController';
import { styled } from '@linaria/react';
import { approveContractInfoRequest, rejectContractInfoRequest } from '@core/api';
import { Button, AssetIcon } from '@app/shared/components';
import {
CancelIcon, ArrowDownIcon, ArrowUpIcon, ArrowsTowards,
} from '@app/shared/icons';
import { CancelIcon, ArrowDownIcon, ArrowUpIcon, ArrowsTowards } from '@app/shared/icons';
import { useSelector } from 'react-redux';
import { selectAssets } from '@app/containers/Wallet/store/selectors';

Expand Down Expand Up @@ -164,33 +162,24 @@ const ApproveInvoke = () => {
<Amounts>
{amounts.length > 0
? amounts.map((data) => {
const assetItem = assets.find((asset) => asset.asset_id === data.assetID);
return assetItem ? (
<AssetItem key={data.assetID}>
<AssetIcon asset_id={data.assetID} />
<LabelStyled is_spend={data.spend}>
{data.spend ? '-' : '+'}
{' '}
{data.amount}
{' '}
{assetItem.metadata_pairs.UN}
</LabelStyled>
</AssetItem>
) : null;
})
const assetItem = assets.find((asset) => asset.asset_id === data.assetID);
return assetItem ? (
<AssetItem key={data.assetID}>
<AssetIcon asset_id={data.assetID} />
<LabelStyled is_spend={data.spend}>
{data.spend ? '-' : '+'} {data.amount} {assetItem.metadata_pairs.UN}
</LabelStyled>
</AssetItem>
) : null;
})
: '-'}
</Amounts>
</Amount>
<Fee>
<FeeSubtitle>Fee: </FeeSubtitle>
<FeeValue>
<AssetIcon asset_id={0} />
<FeeLabelStyled>
{info.fee}
{' '}
BEAM
{' '}
</FeeLabelStyled>
<FeeLabelStyled>{info.fee} BEAM </FeeLabelStyled>
</FeeValue>
</Fee>
<TextStyled>{text}</TextStyled>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,7 @@ const ApproveSend = () => {
<Subtitle>Fee: </Subtitle>
<FeeValue>
<AssetIcon asset_id={0} />
<FeeLabelStyled>
{info.fee}
{' '}
BEAM
{' '}
</FeeLabelStyled>
<FeeLabelStyled>{info.fee} BEAM </FeeLabelStyled>
</FeeValue>
</Section>
<ControlsStyled>
Expand Down
Loading

0 comments on commit fed08d1

Please sign in to comment.