diff --git a/js/src/modals/SMSVerification/SendRequest/sendRequest.js b/js/src/modals/SMSVerification/SendRequest/sendRequest.js index f66ef4de5..dd1212e0d 100644 --- a/js/src/modals/SMSVerification/SendRequest/sendRequest.js +++ b/js/src/modals/SMSVerification/SendRequest/sendRequest.js @@ -19,24 +19,10 @@ import qs from 'querystring'; import TxHash from '../../../ui/TxHash'; import waitForConfirmations from '../wait-for-confirmations'; +import postToVerificationServer from '../post-to-verification-server'; import styles from './sendRequest.css'; -const postToVerificationServer = (query) => { - query = qs.stringify(query); - return fetch('https://sms-verification.parity.io/?' + query, { - method: 'POST', mode: 'cors', cache: 'no-store' - }) - .then((res) => { - return res.json().then((data) => { - if (res.ok) { - return data.message; - } - throw new Error(data.message || 'unknown error'); - }); - }); -}; - export default class SendRequest extends Component { static contextTypes = { api: PropTypes.object.isRequired diff --git a/js/src/modals/SMSVerification/post-to-verification-server.js b/js/src/modals/SMSVerification/post-to-verification-server.js new file mode 100644 index 000000000..c989e84e9 --- /dev/null +++ b/js/src/modals/SMSVerification/post-to-verification-server.js @@ -0,0 +1,38 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +import { stringify } from 'querystring'; + +const postToVerificationServer = (query) => { + query = stringify(query); + return fetch('https://sms-verification.parity.io/?' + query, { + method: 'POST', mode: 'cors', cache: 'no-store' + }) + .then((res) => { + return res.json().then((data) => { + if (res.ok) { + return data.message; + } + throw new Error(data.message || 'unknown error'); + }); + }) + .catch((err) => { + console.error('foooo', err.stack); + throw err + }); +}; + +export default postToVerificationServer;