Skip to content

Commit

Permalink
[DDW-341] Fixed shutdown messages priority, Enabled wallet creation a…
Browse files Browse the repository at this point in the history
…nd restoration during syncing
  • Loading branch information
nikolaglumac committed Aug 12, 2020
1 parent 71a2262 commit 412e576
Show file tree
Hide file tree
Showing 21 changed files with 148 additions and 279 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,12 +5,15 @@ Changelog

### Features

- Enabled wallet creation regardless of the sync progress ([PR 2150](https://github.com/input-output-hk/daedalus/pull/2150))
- Enabled restoration of "Shelley" wallets regardless of the sync progress ([PR 2150](https://github.com/input-output-hk/daedalus/pull/2150))
- Enabled restoration of Yoroi "Shelley" wallets ([PR 2144](https://github.com/input-output-hk/daedalus/pull/2144))
- Enabled "Send" screen for "Byron" wallets ([PR 2147](https://github.com/input-output-hk/daedalus/pull/2147))
- Added SMASH support ([PR 2143](https://github.com/input-output-hk/daedalus/pull/2143))

### Fixes

- Fixed display priority of Daedalus shutdown messages on the "Loading" screen ([PR 2150](https://github.com/input-output-hk/daedalus/pull/2150))
- Fixed double loading spinner issue on stake pools list page ([PR 2144](https://github.com/input-output-hk/daedalus/pull/2144))
- Fixed the Japanese translation for "Byron" wallet label ([PR 2147](https://github.com/input-output-hk/daedalus/pull/2147))
- Fixed validation of spending passwords which include spaces ([PR 2147](https://github.com/input-output-hk/daedalus/pull/2147))
Expand Down
120 changes: 56 additions & 64 deletions source/renderer/app/api/api.js
Expand Up @@ -102,7 +102,6 @@ import { REDEEM_ITN_REWARDS_AMOUNT } from '../config/stakingConfig';
import {
ADA_CERTIFICATE_MNEMONIC_LENGTH,
WALLET_RECOVERY_PHRASE_WORD_COUNT,
LEGACY_WALLET_RECOVERY_PHRASE_WORD_COUNT,
} from '../config/cryptoConfig';

// Addresses Types
Expand Down Expand Up @@ -213,16 +212,10 @@ export default class AdaApi {
this.config = config;
}

getWallets = async (request: {
isShelleyActivated: boolean,
}): Promise<Array<Wallet>> => {
getWallets = async (): Promise<Array<Wallet>> => {
logger.debug('AdaApi::getWallets called');
const { isShelleyActivated } = request;
try {
const wallets: AdaWallets =
isIncentivizedTestnet || isShelleyActivated
? await getWallets(this.config)
: [];
const wallets: AdaWallets = await getWallets(this.config);
const legacyWallets: LegacyAdaWallets = await getLegacyWallets(
this.config
);
Expand Down Expand Up @@ -535,61 +528,70 @@ export default class AdaApi {
}
};

createWallet = async (request: {
walletDetails: CreateWalletRequest,
isShelleyActivated: boolean,
}): Promise<Wallet> => {
createWallet = async (request: CreateWalletRequest): Promise<Wallet> => {
logger.debug('AdaApi::createWallet called', {
parameters: filterLogData(request),
});
const { walletDetails, isShelleyActivated } = request;
const { name, mnemonic, spendingPassword } = walletDetails;
const { name, mnemonic, spendingPassword } = request;
try {
let wallet: AdaWallet;
const walletInitData = {
name,
mnemonic_sentence: split(mnemonic, ' '),
passphrase: spendingPassword,
};
const wallet: AdaWallet = await createWallet(this.config, {
walletInitData,
});
logger.debug('AdaApi::createWallet success', { wallet });
return _createWalletFromServerData(wallet);
} catch (error) {
logger.error('AdaApi::createWallet error', { error });
throw new ApiError(error);
}
};

if (isIncentivizedTestnet || isShelleyActivated) {
wallet = await createWallet(this.config, {
walletInitData,
});
logger.debug('AdaApi::createWallet (Shelley) success', { wallet });
} else {
const legacyWallet: LegacyAdaWallet = await restoreByronWallet(
this.config,
{ walletInitData },
'random'
);

// Generate address for the newly created Byron wallet
const { id: walletId } = legacyWallet;
const address: Address = await createByronWalletAddress(this.config, {
passphrase: spendingPassword,
walletId,
});
logger.debug('AdaApi::createAddress (Byron) success', { address });

const extraLegacyWalletProps = {
address_pool_gap: 0, // Not needed for legacy wallets
delegation: {
active: {
status: WalletDelegationStatuses.NOT_DELEGATING,
},
createLegacyWallet = async (
request: CreateWalletRequest
): Promise<Wallet> => {
logger.debug('AdaApi::createLegacyWallet called', {
parameters: filterLogData(request),
});
const { name, mnemonic, spendingPassword } = request;
try {
const walletInitData = {
name,
mnemonic_sentence: split(mnemonic, ' '),
passphrase: spendingPassword,
};
const legacyWallet: LegacyAdaWallet = await restoreByronWallet(
this.config,
{ walletInitData },
'random'
);
// Generate address for the newly created Byron wallet
const { id: walletId } = legacyWallet;
const address: Address = await createByronWalletAddress(this.config, {
passphrase: spendingPassword,
walletId,
});
logger.debug('AdaApi::createByronWalletAddress success', { address });
const extraLegacyWalletProps = {
address_pool_gap: 0, // Not needed for legacy wallets
delegation: {
active: {
status: WalletDelegationStatuses.NOT_DELEGATING,
},
isLegacy: true,
};
wallet = {
...legacyWallet,
...extraLegacyWalletProps,
};
logger.debug('AdaApi::createWallet (Byron) success', { wallet });
}
},
isLegacy: true,
};
const wallet: AdaWallet = {
...legacyWallet,
...extraLegacyWalletProps,
};
logger.debug('AdaApi::createLegacyWallet success', { wallet });
return _createWalletFromServerData(wallet);
} catch (error) {
logger.error('AdaApi::createWallet error', { error });
logger.error('AdaApi::createLegacyWallet error', { error });
throw new ApiError(error);
}
};
Expand Down Expand Up @@ -815,20 +817,11 @@ export default class AdaApi {
isValidCertificateMnemonic = (mnemonic: string): boolean =>
mnemonic.split(' ').length === ADA_CERTIFICATE_MNEMONIC_LENGTH;

getWalletRecoveryPhrase(request: {
isShelleyActivated: string,
}): Promise<Array<string>> {
const { isShelleyActivated } = request;
getWalletRecoveryPhrase(): Promise<Array<string>> {
logger.debug('AdaApi::getWalletRecoveryPhrase called');
try {
const response: Promise<Array<string>> = new Promise(resolve =>
resolve(
generateAccountMnemonics(
isIncentivizedTestnet || isShelleyActivated
? WALLET_RECOVERY_PHRASE_WORD_COUNT
: LEGACY_WALLET_RECOVERY_PHRASE_WORD_COUNT
)
)
resolve(generateAccountMnemonics(WALLET_RECOVERY_PHRASE_WORD_COUNT))
);
logger.debug('AdaApi::getWalletRecoveryPhrase success');
return response;
Expand Down Expand Up @@ -1603,8 +1596,7 @@ export default class AdaApi {
testReset = async (): Promise<void> => {
logger.debug('AdaApi::testReset called');
try {
// @TODO - pass isShelleyActivated parameter from E2E tests
const wallets = await this.getWallets({ isShelleyActivated: false });
const wallets = await this.getWallets();
await Promise.all(
wallets.map(wallet =>
this.deleteWallet({
Expand Down
7 changes: 2 additions & 5 deletions source/renderer/app/api/utils/patchAdaApi.js
Expand Up @@ -216,11 +216,8 @@ export default (api: AdaApi) => {
});
});

api.getWallets = async (request: {
isShelleyActivated: boolean,
}): Promise<Array<Wallet>> => {
const { isShelleyActivated } = request;
const originalWallets = await originalGetWallets({ isShelleyActivated });
api.getWallets = async (): Promise<Array<Wallet>> => {
const originalWallets = await originalGetWallets();
const modifiedWallets = originalWallets.map(
(originalWallet: Wallet, index: number) => {
const testingWallet = TESTING_WALLETS_DATA[index] || {};
Expand Down
Expand Up @@ -95,6 +95,7 @@ export default class SyncingConnectingStatus extends Component<Props> {
const {
cardanoNodeState,
hasBeenConnected,
isVerifyingBlockchain,
isTlsCertInvalid,
isConnected,
} = this.props;
Expand Down Expand Up @@ -137,6 +138,9 @@ export default class SyncingConnectingStatus extends Component<Props> {
if (isTlsCertInvalid && isConnectingMessage) {
return messages.tlsCertificateNotValidError;
}
if (isVerifyingBlockchain && isConnectingMessage) {
return messages.verifyingBlockchain;
}
return connectingMessage;
};

Expand All @@ -148,7 +152,6 @@ export default class SyncingConnectingStatus extends Component<Props> {
isNodeStopped,
isTlsCertInvalid,
hasLoadedCurrentLocale,
isVerifyingBlockchain,
verificationProgress,
} = this.props;

Expand All @@ -170,11 +173,9 @@ export default class SyncingConnectingStatus extends Component<Props> {
return (
<div className={componentStyles}>
<h1 className={headlineStyles}>
{isVerifyingBlockchain
? intl.formatMessage(messages.verifyingBlockchain, {
verificationProgress,
})
: intl.formatMessage(this._getConnectingMessage())}
{intl.formatMessage(this._getConnectingMessage(), {
verificationProgress,
})}
</h1>
</div>
);
Expand Down
7 changes: 1 addition & 6 deletions source/renderer/app/components/wallet/WalletAdd.js
Expand Up @@ -100,7 +100,6 @@ type Props = {
isMainnet: boolean,
isTestnet: boolean,
isProduction: boolean,
isShelleyActivated: boolean,
};

@observer
Expand All @@ -124,7 +123,6 @@ export default class WalletAdd extends Component<Props> {
isMainnet,
isTestnet,
isProduction,
isShelleyActivated,
} = this.props;

const componentClasses = classnames([styles.component, 'WalletAdd']);
Expand All @@ -148,10 +146,7 @@ export default class WalletAdd extends Component<Props> {
? intl.formatMessage(messages.createDescriptionItn)
: intl.formatMessage(messages.createDescription)
}
isDisabled={
isMaxNumberOfWalletsReached ||
(!isIncentivizedTestnet && !isShelleyActivated)
}
isDisabled={isMaxNumberOfWalletsReached}
/>
<BigButtonForDialogs
className="joinWalletButton"
Expand Down
5 changes: 0 additions & 5 deletions source/renderer/app/components/wallet/WalletBackupDialog.js
Expand Up @@ -18,7 +18,6 @@ type Props = {
isTermRewardsAccepted: boolean,
isValid: boolean,
isSubmitting: boolean,
isShelleyActivated: boolean,
recoveryPhrase: string,
enteredPhrase: Array<string>,
onCancelBackup: Function,
Expand Down Expand Up @@ -59,7 +58,6 @@ export default class WalletBackupDialog extends Component<Props> {
onUpdateVerificationPhrase,
onFinishBackup,
onRestartBackup,
isShelleyActivated,
} = this.props;

if (currentStep === WALLET_BACKUP_STEPS.PRIVACY_WARNING) {
Expand All @@ -68,7 +66,6 @@ export default class WalletBackupDialog extends Component<Props> {
canPhraseBeShown={canPhraseBeShown}
isPrivacyNoticeAccepted={isPrivacyNoticeAccepted}
countdownRemaining={countdownRemaining}
isShelleyActivated={isShelleyActivated}
onAcceptPrivacyNotice={onAcceptPrivacyNotice}
onCancelBackup={onCancelBackup}
onContinue={onContinue}
Expand All @@ -81,7 +78,6 @@ export default class WalletBackupDialog extends Component<Props> {
recoveryPhrase={recoveryPhrase}
onStartWalletBackup={onStartWalletBackup}
onCancelBackup={onCancelBackup}
isShelleyActivated={isShelleyActivated}
/>
);
}
Expand All @@ -94,7 +90,6 @@ export default class WalletBackupDialog extends Component<Props> {
isTermRecoveryAccepted={isTermRecoveryAccepted}
isTermRewardsAccepted={isTermRewardsAccepted}
isValid={isValid}
isShelleyActivated={isShelleyActivated}
isSubmitting={isSubmitting}
onAcceptTermOffline={onAcceptTermOffline}
onAcceptTermRecovery={onAcceptTermRecovery}
Expand Down
36 changes: 7 additions & 29 deletions source/renderer/app/components/wallet/WalletCreateDialog.js
Expand Up @@ -24,15 +24,10 @@ import { FORM_VALIDATION_DEBOUNCE_WAIT } from '../../config/timingConfig';
import { submitOnEnter } from '../../utils/form';

const messages = defineMessages({
dialogTitleItn: {
id: 'wallet.create.dialog.title.itn',
defaultMessage: '!!!Create a new wallet',
description: 'Title "Create a new wallet" in the wallet create form.',
},
dialogTitle: {
id: 'wallet.create.dialog.title',
defaultMessage: '!!!Create a wallet',
description: 'Title "Create a wallet" in the wallet create form.',
defaultMessage: '!!!Create a new wallet',
description: 'Title "Create a new wallet" in the wallet create form.',
},
walletName: {
id: 'wallet.create.dialog.name.label',
Expand All @@ -46,17 +41,11 @@ const messages = defineMessages({
description:
'Hint for the "Wallet Name" text input in the wallet create form.',
},
createPersonalWalletItn: {
id: 'wallet.create.dialog.create.personal.wallet.button.label.itn',
defaultMessage: '!!!Create Shelley wallet',
description:
'Label for the "Create Shelley wallet" button on create wallet dialog.',
},
createPersonalWallet: {
id: 'wallet.create.dialog.create.personal.wallet.button.label',
defaultMessage: '!!!Create wallet',
defaultMessage: '!!!Create Shelley wallet',
description:
'Label for the "Create wallet" button on create wallet dialog.',
'Label for the "Create Shelley wallet" button on create wallet dialog.',
},
passwordSectionLabel: {
id: 'wallet.create.dialog.passwordSectionLabel',
Expand Down Expand Up @@ -88,10 +77,7 @@ const messages = defineMessages({
},
});

const { isIncentivizedTestnet } = global;

type Props = {
isShelleyActivated: boolean,
onSubmit: Function,
onCancel: Function,
};
Expand Down Expand Up @@ -211,7 +197,7 @@ export default class WalletCreateDialog extends Component<Props, State> {
render() {
const { form } = this;
const { intl } = this.context;
const { onCancel, isShelleyActivated } = this.props;
const { onCancel } = this.props;
const { isSubmitting } = this.state;
const dialogClasses = classnames([styles.component, 'WalletCreateDialog']);

Expand All @@ -225,11 +211,7 @@ export default class WalletCreateDialog extends Component<Props, State> {
{
className: isSubmitting ? styles.isSubmitting : null,
disabled: !canSubmit,
label: this.context.intl.formatMessage(
isIncentivizedTestnet || isShelleyActivated
? messages.createPersonalWalletItn
: messages.createPersonalWallet
),
label: this.context.intl.formatMessage(messages.createPersonalWallet),
primary: true,
onClick: this.submit,
},
Expand All @@ -238,11 +220,7 @@ export default class WalletCreateDialog extends Component<Props, State> {
return (
<Dialog
className={dialogClasses}
title={intl.formatMessage(
isIncentivizedTestnet || isShelleyActivated
? messages.dialogTitleItn
: messages.dialogTitle
)}
title={intl.formatMessage(messages.dialogTitle)}
actions={actions}
closeOnOverlayClick
onClose={!isSubmitting ? onCancel : () => {}}
Expand Down

0 comments on commit 412e576

Please sign in to comment.