@@ -99,7 +109,7 @@ class Swap extends Component {
{partOneComplete &&
-
+
}
@@ -110,6 +120,7 @@ class Swap extends Component {
function mapStateToProps(state) {
return {
+ receivingAddress: state.swap.receivingAddress,
partOneComplete: state.swap.partOneComplete,
originAmount: state.swap.originAmount,
destinationAmount: state.swap.destinationAmount,
diff --git a/common/libs/validator.js b/common/libs/validator.js
new file mode 100644
index 00000000..c930f47a
--- /dev/null
+++ b/common/libs/validator.js
@@ -0,0 +1,16 @@
+import WalletAddressValidator from 'wallet-address-validator';
+import ethUtil from 'ethereumjs-util';
+
+export default class Validator {
+ isValidETHAddress = function(address) {
+ if (address && address === '0x0000000000000000000000000000000000000000')
+ return false;
+ if (address) {
+ return ethUtil.isValidAddress(address);
+ }
+ return false;
+ };
+ isValidBTCAddress = function(address) {
+ return WalletAddressValidator.validate(address, 'BTC');
+ };
+}
diff --git a/common/reducers/swap.js b/common/reducers/swap.js
index 06fbb2b9..3de1b101 100644
--- a/common/reducers/swap.js
+++ b/common/reducers/swap.js
@@ -4,7 +4,8 @@ import {
SWAP_ORIGIN_AMOUNT,
SWAP_ORIGIN_KIND,
SWAP_UPDATE_BITY_RATES,
- SWAP_PART_ONE_COMPLETE
+ SWAP_PART_ONE_COMPLETE,
+ SWAP_RECEIVING_ADDRESS
} from 'actions/swapConstants';
import { combineAndUpper } from 'api/bity';
@@ -22,7 +23,8 @@ const initialState = {
element => element !== 'REP'
),
partOneComplete: false,
- bityRates: {}
+ bityRates: {},
+ receivingAddress: ''
};
const buildDestinationAmount = (
@@ -101,6 +103,11 @@ export function swap(state = initialState, action) {
...state,
partOneComplete: action.value
};
+ case SWAP_RECEIVING_ADDRESS:
+ return {
+ ...state,
+ receivingAddress: action.value
+ };
default:
return state;
}
diff --git a/package.json b/package.json
index ee4c86d0..c18c6355 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,7 @@
"description": "MyEtherWallet v4",
"dependencies": {
"axios": "^0.16.2",
+ "ethereumjs-util": "^5.1.2",
"lodash": "^4.17.4",
"prop-types": "^15.5.8",
"react": "^15.4.2",
@@ -17,6 +18,7 @@
"redux-logger": "^3.0.1",
"redux-saga": "^0.15.3",
"store2": "^2.5.0",
+ "wallet-address-validator": "^0.1.0",
"whatwg-fetch": "^2.0.2"
},
"devDependencies": {