Skip to content
Permalink
Browse files

Merge branch 'chore/ddw-871-delete-wallet-v2-api-integration' into ch…

…ore/ddw-738-refactor-test-setup
  • Loading branch information...
tomothespian committed Sep 11, 2019
2 parents 13aafc5 + 1b15d2d commit 809cd1641ee189f5c1da672ad4bf038de83a85be
@@ -32,6 +32,7 @@ Changelog

### Chores

- Use improved `NumericInput` component of `React-Polymorph` v0.9.0 ([1511](https://github.com/input-output-hk/daedalus/pull/1511))
- Added minimum heights of main app window for different environments (Windows, Linux, MacOS) ([1485](https://github.com/input-output-hk/daedalus/pull/1485))
- Removed "Ada Redemption" feature ([PR 1510](https://github.com/input-output-hk/daedalus/pull/1510))
- Changed `themes:check` to `themes:check:createTheme` and added a 4 part "Theme Management in Daedalus" tutorial series to a README document in the themes directory ([PR 1525](https://github.com/input-output-hk/daedalus/pull/1525))
@@ -61,10 +61,10 @@ Feature: Send Money to Receiver
| title | amount |
| my transaction | <WRONG_AMOUNT> |
Then I should see the following error messages on the wallet send form:
| message |
| wallet.send.form.errors.invalidAmount |
| message |
| <ERROR> |

Examples:
| WRONG_AMOUNT |
| 45000000001 |
| 0 |
| WRONG_AMOUNT | ERROR |
| 99999999 | api.errors.NotEnoughFundsForTransactionError |
| 0 | wallet.send.form.errors.invalidAmount |
@@ -28,7 +28,7 @@ When(/^I open language selection dropdown$/, function() {

When(/^I select Japanese language$/, function() {
return this.waitAndClick(
'//*[@class="SimpleOptions_label"][contains(text(), "Japanese")]'
'//*[@class="SimpleOptions_option"]//*[contains(text(), "Japanese")]'
);
});

@@ -103,7 +103,7 @@ When(

When(/^I select "Strict" assurance level$/, function() {
return this.waitAndClick(
'//*[@class="SimpleOptions_label"][contains(text(), "Strict")]'
'//*[@class="SimpleOptions_option"]//*[contains(text(), "Strict")]'
);
});

@@ -178,7 +178,7 @@
"react-lottie": "1.2.3",
"react-markdown": "3.1.0",
"react-number-format": "3.0.3",
"react-polymorph": "0.8.7",
"react-polymorph": "0.9.0-rc.15",
"react-router": "3.2.1",
"react-svg-inline": "2.1.0",
"react-virtualized": "9.21.0",
@@ -17,16 +17,17 @@ export type RequestOptions = {
},
};

const ALLOWED_ERROR_EXCEPTION_PATHS = [
'/api/internal/next-update', // when nextAdaUpdate receives a 404, it isn't an error
];

function typedRequest<Response>(
httpOptions: RequestOptions,
queryParams?: {},
rawBodyParams?: any
// requestOptions?: { returnMeta: boolean }
): Promise<Response> {
return new Promise((resolve, reject) => {
const allowedErrorExceptionPaths = [
'/api/internal/next-update', // when nextAdaUpdate receives a 404, it isn't an error
];
const options: RequestOptions = Object.assign({}, httpOptions);
// const { returnMeta } = Object.assign({}, requestOptions);
let hasRequestBody = false;
@@ -69,13 +70,7 @@ function typedRequest<Response>(
}

// @API TODO: Delete once HTTPS is supported by the new API
const httpOnlyOptions = {
...options,
hostname: options.hostname,
method: options.method,
path: options.path,
port: options.port,
};
const httpOnlyOptions = omit(options, ['ca', 'cert', 'key']);

// @API TODO: Uncomment / switch once HTTPS is supported by the new API
// const httpsRequest = global.https.request(options);
@@ -96,12 +91,12 @@ function typedRequest<Response>(
response.on('end', () => {
try {
const { statusCode, statusMessage } = response;
const successResponse =
const isSuccessResponse =
(statusCode >= 200 && statusCode <= 206) ||
(statusCode === 404 &&
includes(allowedErrorExceptionPaths, options.path));
includes(ALLOWED_ERROR_EXCEPTION_PATHS, options.path));

if (successResponse) {
if (isSuccessResponse) {
const data =
statusCode === 404
? 'null'
@@ -116,16 +111,16 @@ function typedRequest<Response>(
}
resolve(JSON.parse(body));
} else if (body) {
// Error response with a body
const parsedBody = JSON.parse(body);
if (parsedBody.code && parsedBody.message) {
reject(parsedBody);
} else {
// TODO: find a way to record this case and report to the backend team
reject(new Error('Unknown response from backend.'));
reject(new Error('Unknown API response'));
}
} else {
// TODO: find a way to record this case and report to the backend team
reject(new Error('Unknown response from backend.'));
// Error response without a body
reject(new Error('Unknown API response'));
}
} catch (error) {
// Handle internal server errors (e.g. HTTP 500 - 'Something went wrong')
@@ -20,7 +20,6 @@ import globalMessages from '../../i18n/global-messages';
import WalletSendConfirmationDialog from './WalletSendConfirmationDialog';
import WalletSendConfirmationDialogContainer from '../../containers/wallet/dialogs/WalletSendConfirmationDialogContainer';
import {
formattedAmountToBigNumber,
formattedAmountToNaturalUnits,
formattedAmountToLovelace,
} from '../../utils/formatters';
@@ -207,17 +206,17 @@ export default class WalletSendForm extends Component<Props, State> {
placeholder: `0.${'0'.repeat(
this.props.currencyMaxFractionalDigits
)}`,
value: '',
value: null,
validators: [
async ({ field, form }) => {
const amountValue = field.value;
if (amountValue === '') {
if (field.value === null) {
this._resetTransactionFee();
return [
false,
this.context.intl.formatMessage(messages.fieldIsRequired),
];
}
const amountValue = field.value.toString();
const isValid = await this.props.validateAmount(
formattedAmountToNaturalUnits(amountValue)
);
@@ -252,7 +251,6 @@ export default class WalletSendForm extends Component<Props, State> {
const { intl } = this.context;
const {
currencyUnit,
currencyMaxIntegerDigits,
currencyMaxFractionalDigits,
isDialogOpen,
isRestoreActive,
@@ -267,7 +265,8 @@ export default class WalletSendForm extends Component<Props, State> {
const receiverField = form.$('receiver');
const receiverFieldProps = receiverField.bind();
const amountFieldProps = amountField.bind();
const amount = formattedAmountToBigNumber(amountFieldProps.value);

const amount = new BigNumber(amountFieldProps.value || 0);

let fees = null;
let total = null;
@@ -310,19 +309,21 @@ export default class WalletSendForm extends Component<Props, State> {
{...amountFieldProps}
className="amount"
label={intl.formatMessage(messages.amountLabel)}
maxBeforeDot={currencyMaxIntegerDigits}
maxAfterDot={currencyMaxFractionalDigits}
numberLocaleOptions={{
minimumFractionDigits: currencyMaxFractionalDigits,
}}
error={transactionFeeError || amountField.error}
onChange={value => {
this._isCalculatingFee = true;
amountField.onChange(value || '');
amountField.onChange(value);
}}
// AmountInputSkin props
currency={currencyUnit}
fees={fees}
total={total}
skin={AmountInputSkin}
onKeyPress={this.handleSubmitOnEnter}
allowSigns={false}
/>
</div>

@@ -339,7 +340,7 @@ export default class WalletSendForm extends Component<Props, State> {

{isDialogOpen(WalletSendConfirmationDialog) ? (
<WalletSendConfirmationDialogContainer
amount={amountFieldProps.value}
amount={amount.toFormat(currencyMaxFractionalDigits)}
receiver={receiverFieldProps.value}
totalAmount={total}
transactionFee={fees}
@@ -579,4 +579,4 @@
"wallet.transaction.type.exchange": "!!!Währungsumtausch",
"wallet.transactions.no.transactions": "!!!Keine Transaktionen vorhanden",
"wallet.transactions.no.transactions.found": "!!!Keine Transaktionen gefunden"
}
}

0 comments on commit 809cd16

Please sign in to comment.
You can’t perform that action at this time.