Skip to content

Commit

Permalink
First steps to allow users to input addresses without 1W prefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
beregovoy68 committed Jun 20, 2016
1 parent b9e8d84 commit 2b6f378
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions js/waves.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* @depends {util/converters.js}
* @depends {util/extensions.js}
* @depends {waves.js}
* @depends {waves.api.address.js}
*/
var Waves = (function(Waves, $, undefined) {
"use strict";
Expand Down Expand Up @@ -546,8 +547,9 @@ var Waves = (function(Waves, $, undefined) {
}
});
$.validator.addMethod('address', function(value, element){
return this.optional(element) || /^1W[a-zA-Z0-9]{35}$/.test(value);
}, "Account number must be a sequence of 35 alphanumeric characters with no spaces starting with '1W'");
return this.optional(element) || Waves.Addressing.validateDisplayAddress(value) ||
Waves.Addressing.validateRawAddress(value);
}, "Account number must be a sequence of 35 alphanumeric characters with no spaces, optionally starting with '1W'");
$.validator.addMethod('decimal', function(value, element) {
return this.optional(element) || /^(?:-?\d+)?(?:\.\d+)?$/.test(value);
}, "Amount is expected with a dot (.) as a decimal separator");
Expand Down
12 changes: 11 additions & 1 deletion js/waves.ui.wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,17 @@ var Waves = (function(Waves, $, undefined) {
var senderPassphrase = converters.stringToByteArray(Waves.passphrase);
var senderPublic = Base58.decode(Waves.publicKey);
var senderPrivate = Base58.decode(Waves.privateKey);
var recipient = Waves.Addressing.fromDisplayAddress($("#wavesrecipient").val().replace(/\s+/g, ''));
var addressText = $("#wavesrecipient").val().replace(/\s+/g, '');
var recipient = undefined;
if (Waves.Addressing.validateDisplayAddress(addressText))
recipient = Waves.Addressing.fromDisplayAddress(addressText);
else if (Waves.Addressing.validateRawAddress(addressText))
recipient = Waves.Addressing.fromRawAddress(addressText);
else {
// we shouldn't see this message, because form is validated
$.growl.error({ message: 'Unknown address format' });
return;
}

var wavesTime = Number(Waves.getTime());

Expand Down

0 comments on commit 2b6f378

Please sign in to comment.