Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDW-595] Warn user when pasting an address of the same wallet #2506

Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
6febb18
DDW-595 - Warn user when pasting an address of the same wallet
DeeJayElly Apr 5, 2021
ff47b5e
DDW-595 - Warn user when pasting an address of the same wallet - pret…
DeeJayElly Apr 5, 2021
e5bbe15
DDW-595 - Warn user when pasting an address of the same wallet - chan…
DeeJayElly Apr 5, 2021
06d83ef
DDW-595 - Warn user when pasting an address of the same wallet - fixi…
DeeJayElly Apr 5, 2021
ce73b9d
DDW-595 - Warn user when pasting an address of the same wallet - lint…
DeeJayElly Apr 6, 2021
0008d25
DDW-595 - Warn user when pasting an address of the same wallet - fixe…
DeeJayElly Apr 6, 2021
a2fbf11
DDW-595 - Warn user when pasting an address of the same wallet - fixe…
DeeJayElly Apr 6, 2021
7c49f7b
DDW-595 - Warn user when pasting an address of the same wallet - fixe…
DeeJayElly Apr 7, 2021
6e456a4
Merge branch 'develop' into feature/ddw-595-warn-user-when-pasting-an…
DeeJayElly Apr 7, 2021
736bf7b
DDW-595 - Warn user when pasting an address of the same wallet - fixe…
DeeJayElly Apr 7, 2021
203dee0
Merge remote-tracking branch 'origin/feature/ddw-595-warn-user-when-p…
DeeJayElly Apr 7, 2021
95bc036
DDW-595 - Warn user when pasting an address of the same wallet - pret…
DeeJayElly Apr 7, 2021
389d911
Merge branch 'develop' into feature/ddw-595-warn-user-when-pasting-an…
DeeJayElly Apr 8, 2021
105ac97
Merge branch 'develop' into feature/ddw-595-warn-user-when-pasting-an…
DeeJayElly Apr 9, 2021
92efe16
DDW-595 - Warn user when pasting an address of the same wallet - fixe…
DeeJayElly Apr 12, 2021
cab4782
Merge branch 'develop' into feature/ddw-595-warn-user-when-pasting-an…
DeeJayElly Apr 14, 2021
f87b26d
Merge branch 'develop' into feature/ddw-595-warn-user-when-pasting-an…
DeeJayElly Apr 14, 2021
e11b68f
Merge branch 'feature/ddw-595-warn-user-when-pasting-an-address-of-th…
DeeJayElly Apr 14, 2021
09da13e
DDW-595 - Warn user when pasting an address of the same wallet - fixes
DeeJayElly Apr 14, 2021
e0de680
DDW-595 - Warn user when pasting an address of the same wallet - fixes
DeeJayElly Apr 14, 2021
f17f860
Merge branch 'develop' into feature/ddw-595-warn-user-when-pasting-an…
DeeJayElly Apr 15, 2021
1d86032
DDW-595 - Warn user when pasting an address of the same wallet - chan…
DeeJayElly Apr 15, 2021
2dc6131
DDW-595 - Warn user when pasting an address of the same wallet - disa…
DeeJayElly Apr 15, 2021
90c937e
DDW-595 - Warn user when pasting an address of the same wallet - disa…
DeeJayElly Apr 15, 2021
71d0f1e
DDW-595 - Warn user when pasting an address of the same wallet - pret…
DeeJayElly Apr 15, 2021
9087dc7
DDW-595 - Warn user when pasting an address of the same wallet - rena…
DeeJayElly Apr 16, 2021
7ac0d62
DDW-595 - Warn user when pasting an address of the same wallet - addi…
DeeJayElly Apr 16, 2021
23e9ffd
DDW-595 - Warn user when pasting an address of the same wallet - flow…
DeeJayElly Apr 16, 2021
b7164d2
[DDW-595] Refactor wallet send form receiver field
DominikGuzei Apr 16, 2021
e1e7c8f
Merge branch 'develop' into feature/ddw-595-warn-user-when-pasting-an…
nikolaglumac Apr 17, 2021
57dc3ef
DDW-595 - Warn user when pasting an address of the same wallet - fixi…
DeeJayElly Apr 19, 2021
4fc762a
DDW-595 - Warn user when pasting an address of the same wallet - fixi…
DeeJayElly Apr 20, 2021
6c031cf
DDW-595 - Warn user when pasting an address of the same wallet - fixi…
DeeJayElly Apr 20, 2021
7990fd4
DDW-595 - Warn user when pasting an address of the same wallet - fixi…
DeeJayElly Apr 20, 2021
998129f
DDW-595 - Warn user when pasting an address of the same wallet - fixi…
DeeJayElly Apr 20, 2021
1b83e2f
Merge branch 'develop' into feature/ddw-595-warn-user-when-pasting-an…
DeeJayElly Apr 20, 2021
289b50a
DDW-595 - Warn user when pasting an address of the same wallet - temp…
DeeJayElly Apr 20, 2021
c786bab
DDW-595 - Warn user when pasting an address of the same wallet - temp…
DeeJayElly Apr 20, 2021
937822f
DDW-595 - Warn user when pasting an address of the same wallet - temp…
DeeJayElly Apr 20, 2021
0e999e3
DDW-595 - Warn user when pasting an address of the same wallet - temp…
DeeJayElly Apr 20, 2021
0964d5b
DDW-595 - Warn user when pasting an address of the same wallet - disa…
DeeJayElly Apr 21, 2021
8d9166c
DDW-595 - Warn user when pasting an address of the same wallet - disa…
DeeJayElly Apr 21, 2021
3b4a32f
DDW-595 - Warn user when pasting an address of the same wallet - copy…
DeeJayElly Apr 22, 2021
455e536
Merge branch 'develop' into feature/ddw-595-warn-user-when-pasting-an…
DeeJayElly Apr 22, 2021
d1a2ee6
DDW-595 - Warn user when pasting an address of the same wallet - lint…
DeeJayElly Apr 22, 2021
9cce89c
[DDW-595] Runs translation manager
nikolaglumac Apr 23, 2021
80363de
DDW-595 - Warn user when pasting an address of the same wallet - pack…
DeeJayElly Apr 26, 2021
b0c79d5
DDW-595 - Warn user when pasting an address of the same wallet - pack…
DeeJayElly Apr 26, 2021
ac55e5f
DDW-595 - Warn user when pasting an address of the same wallet - prev…
DeeJayElly Apr 26, 2021
4f4dcc1
DDW-595 - Warn user when pasting an address of the same wallet - focu…
DeeJayElly Apr 27, 2021
d1affd9
[DDW-595] Merges develop
nikolaglumac Apr 27, 2021
b0505d0
DDW-595 - Warn user when pasting an address of the same wallet - upda…
DeeJayElly Apr 27, 2021
0983556
Merge remote-tracking branch 'origin/feature/ddw-595-warn-user-when-p…
DeeJayElly Apr 27, 2021
2f3c5c8
DDW-595 - Warn user when pasting an address of the same wallet - refa…
DeeJayElly Apr 27, 2021
6c32639
DDW-595 - Warn user when pasting an address of the same wallet - new …
DeeJayElly Apr 28, 2021
177374a
DDW-595 - Warn user when pasting an address of the same wallet - pret…
DeeJayElly Apr 28, 2021
9e6487b
[DDW-595] Code cleanup
nikolaglumac Apr 28, 2021
9e4e94c
DDW-595 - Warn user when pasting an address of the same wallet - updates
DeeJayElly Apr 28, 2021
d4c8d1d
Merge remote-tracking branch 'origin/feature/ddw-595-warn-user-when-p…
DeeJayElly Apr 28, 2021
94c6d2b
[DDW-595] Update to react-polymorph release candidate
DominikGuzei Apr 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog

### Features

- Added warning message when pasting an address of the same wallet in the send form ([PR 2506](https://github.com/input-output-hk/daedalus/pull/2506))
- Implemented select search style variables ([PR 2512](https://github.com/input-output-hk/daedalus/pull/2512))
- Enabled pasting of wallet recovery phrase ([PR 2459](https://github.com/input-output-hk/daedalus/pull/2459))

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
"react-intl": "2.7.2",
"react-lottie": "1.2.3",
"react-markdown": "4.3.1",
"react-polymorph": "0.9.8-rc.21",
"react-polymorph": "0.9.7-next.1",
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
"react-router": "5.2.0",
"react-router-dom": "5.2.0",
"react-svg-inline": "2.1.1",
Expand Down
67 changes: 57 additions & 10 deletions source/renderer/app/components/wallet/WalletSendForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type Props = {
onOpenDialogAction: Function,
onUnsetActiveAssetFingerprint: Function,
onExternalLinkClick: Function,
isAddressFromSameWallet: boolean,
};

type State = {
Expand Down Expand Up @@ -199,8 +200,6 @@ export default class WalletSendForm extends Component<Props, State> {
}
};

handleSubmitOnEnter = submitOnEnter.bind(this, this.handleOnSubmit);

handleOnSubmit = () => {
if (this.isDisabled()) {
return false;
Expand All @@ -210,6 +209,8 @@ export default class WalletSendForm extends Component<Props, State> {
});
};

handleSubmitOnEnter = submitOnEnter.bind(this, this.handleOnSubmit);

handleOnReset = () => {
// Cancel all debounced field validations
this.form.each((field) => {
Expand Down Expand Up @@ -299,8 +300,14 @@ export default class WalletSendForm extends Component<Props, State> {
return receiverField.value.length > 0;
};

hasAssetValue = (asset: Field) => {
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
return get(asset, 'value', false);
isAddressFromSameWallet = () => {
const { isAddressFromSameWallet } = this.props;
const receiverField = this.form.$('receiver');
return (
this.hasReceiverValue() &&
DeeJayElly marked this conversation as resolved.
Show resolved Hide resolved
isAddressFromSameWallet &&
receiverField.isValid
);
};

isDisabled = () =>
Expand Down Expand Up @@ -330,6 +337,17 @@ export default class WalletSendForm extends Component<Props, State> {
this.setReceiverValidity(isValid);
const adaAmountField = form.$('adaAmount');
const isAdaAmountValid = adaAmountField.isValid;
const { selectedAsset } = this.props;
const shouldFocus = !this.isAddressFromSameWallet();
if (selectedAsset && !shouldFocus) {
const newAsset = `asset_${selectedAsset.fingerprint}`;
const newAssetField = this.form.$(newAsset);
const { name: fieldName } = newAssetField;
const focusableField = this.focusableFields[fieldName];
if (focusableField && focusableField.inputElement) {
focusableField.inputElement.current.blur();
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
}
}
if (isValid && isAdaAmountValid) {
this.calculateTransactionFee();
} else {
Expand Down Expand Up @@ -504,7 +522,6 @@ export default class WalletSendForm extends Component<Props, State> {
<FormattedHTMLMessage {...localizableError} values={values} />
);
}

this._isCalculatingTransactionFee = false;
this.setState({
isTransactionFeeCalculated: false,
Expand Down Expand Up @@ -676,11 +693,16 @@ export default class WalletSendForm extends Component<Props, State> {
selectedAssetFingerprints,
isReceiverAddressValid,
} = this.state;
const { currencyMaxFractionalDigits, walletAmount } = this.props;
const {
currencyMaxFractionalDigits,
walletAmount,
isAddressFromSameWallet,
selectedAsset,
} = this.props;

const {
receiver: receiverField,
adaAmount: adaAmountField,
receiver: receiverField,
assetFields,
assetsDropdown,
} = formFields.receiver;
Expand All @@ -700,27 +722,51 @@ export default class WalletSendForm extends Component<Props, State> {
!this.hasAvailableAssets ? styles.disabled : null,
'primary',
]);

const receiverFieldClasses = classNames([
styles.receiverInput,
this.hasReceiverValue() &&
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
isAddressFromSameWallet &&
receiverField.isValid
? styles.sameRecieverInput
: null,
]);

const minAdaRequiredTooltip = selectedAssetFingerprints.length
? messages.minAdaRequiredWithAssetTooltip
: messages.minAdaRequiredWithNoAssetTooltip;

const sameWalletError = intl.formatMessage(messages.sameWalletLabel);
let receiverFieldError = receiverField.error;
let receiverFieldThemeVars = {};
if (this.isAddressFromSameWallet()) {
receiverFieldError = sameWalletError;
receiverFieldThemeVars = {
'--rp-input-border-color-errored':
'var(--rp-password-input-warning-score-color)',
'--rp-pop-over-bg-color':
'var(--rp-password-input-warning-score-color)',
};
}

return (
<div className={styles.fieldsContainer}>
<div className={styles.receiverInput}>
<div className={receiverFieldClasses}>
<Input
{...receiverField.bind()}
ref={(field) => {
this.addFocusableField(field);
}}
className="receiver"
error={receiverField.error}
error={receiverFieldError}
onChange={(value) => {
receiverField.onChange(value || '');
this.setState({
isResetButtonDisabled: false,
});
}}
onKeyPress={this.handleSubmitOnEnter}
themeVariables={receiverFieldThemeVars}
/>
{this.hasReceiverValue() && (
<div className={styles.clearReceiverContainer}>
Expand All @@ -731,6 +777,7 @@ export default class WalletSendForm extends Component<Props, State> {
<button
onClick={() => this.handleOnReset()}
className={styles.clearReceiverButton}
tabIndex={-1}
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
>
<SVGInline
svg={closeIcon}
Expand Down Expand Up @@ -781,7 +828,7 @@ export default class WalletSendForm extends Component<Props, State> {
error={adaAmountField.error || transactionFeeError}
onKeyPress={this.handleSubmitOnEnter}
allowSigns={false}
autoFocus
autoFocus={!this.isAddressFromSameWallet() && !selectedAsset}
/>
<div className={styles.minAdaRequired}>
<span>
Expand Down
6 changes: 6 additions & 0 deletions source/renderer/app/components/wallet/WalletSendForm.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@
}
}
}

&.sameRecieverInput {
input {
border-color: var(--rp-password-input-warning-score-color) !important;
}
}
}

.estimatedFeeInput,
Expand Down
6 changes: 6 additions & 0 deletions source/renderer/app/components/wallet/send-form/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export default defineMessages({
defaultMessage: '!!!Clear',
description: 'Label for the "Clear" button in the wallet send form.',
},
sameWalletLabel: {
id: 'wallet.send.form.sameWalletLabel',
defaultMessage:
'!!!This receiver address belongs to the same wallet from which you are sending funds. If you proceed with this transaction, the transferred funds will remain in this wallet, and you will incur transaction fees, as outlined in Estimated fees.',
description: 'Label for the same wallet tooltip in the wallet send form.',
},
addAssetButtonLabel: {
id: 'wallet.send.form.button.addAssetButtonLabel',
defaultMessage: '!!!+ Add a token',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,9 @@ export default class InlineEditingInput extends Component<Props, State> {
type="text"
maxLength={maxLength}
label={label}
onFocus={this.onFocus}
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
onBlur={this.onBlur}
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
onChange={this.onChange}
onKeyDown={(event) => this.handleInputKeyDown(event)}
error={isActive ? error : !!error}
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
error={error}
disabled={disabled}
readOnly={readOnly}
ref={(input) => {
Expand Down
3 changes: 2 additions & 1 deletion source/renderer/app/containers/wallet/WalletSendPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class WalletSendPage extends Component<Props> {
hardwareWallets,
assets: assetsStore,
} = this.props.stores;
const { isValidAddress } = wallets;
const { isValidAddress, isAddressFromSameWallet } = wallets;
const { validateAmount } = transactions;
const { hwDeviceStatus } = hardwareWallets;
const hasAssetsEnabled = WALLET_ASSETS_ENABLED;
Expand Down Expand Up @@ -182,6 +182,7 @@ export default class WalletSendPage extends Component<Props> {
}
onUnsetActiveAssetFingerprint={this.handleUnsetActiveAssetFingerprint}
onExternalLinkClick={app.openExternalLink}
isAddressFromSameWallet={isAddressFromSameWallet}
/>
);
}
Expand Down