Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit c4819c5

Browse files
alexvansandeevertonfraga
authored andcommitted
add ens support to input fields (#398)
* add ens support * make regex case insensitive
1 parent 5e107db commit c4819c5

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

app/.meteor/versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ [email protected]
3434
3535
3636
37-
ethereum:[email protected].12
37+
ethereum:[email protected].14
3838
3939
4040

app/client/lib/helpers/helperFunctions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ Helpers.addInputValue = function (inputs, currentInput, formField){
387387
} else if(!_.isEmpty(formField.value) &&
388388
(input.typeShort === 'bytes' ||
389389
input.typeShort === 'address')) {
390-
value = '0x'+ formField.value.replace('0x','');
390+
// If it looks like hex, then add 0x before
391+
value = /^[0-9a-f]+$/i.test(formField.value.replace('0x','')) ? '0x'+ formField.value.replace('0x','') : null;
391392

392393
// bool
393394
} else if(input.typeShort === 'bool') {
@@ -432,3 +433,4 @@ Returns true if Main is the current network.
432433
Helpers.isOnMainNetwork = function () {
433434
return Session.get('network') == 'main';
434435
};
436+

app/client/templates/elements/executeContract.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Template['elements_executeContract_constant'].events({
202202
203203
@event change .abi-input, input .abi-input
204204
*/
205-
'change .abi-input, input .abi-input': function(e, template) {
205+
'change .abi-input, input .abi-input, blur .abi-input': function(e, template) {
206206
var inputs = Helpers.addInputValue(template.data.inputs, this, e.currentTarget);
207207
TemplateVar.set('inputs', inputs);
208208
}
@@ -262,7 +262,7 @@ Template['elements_executeContract_function'].events({
262262
263263
@event change .abi-input, input .abi-input
264264
*/
265-
'change .abi-input, input .abi-input': function(e, template) {
265+
'change .abi-input, input .abi-input, blur .abi-input': function(e, template) {
266266
var inputs = Helpers.addInputValue(template.data.inputs, this, e.currentTarget);
267267

268268
TemplateVar.set('executeData', template.data.contractInstance[template.data.name].getData.apply(null, inputs));

app/client/templates/layout/header.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ Template['layout_header'].helpers({
2525
*/
2626
'goToSend': function() {
2727
FlowRouter.watchPathChange();
28-
var address = web3.toChecksumAddress(FlowRouter.getParam('address'));
29-
28+
var address = web3.toChecksumAddress(FlowRouter.getParam('address'));
29+
var accounts = EthAccounts.find({}).fetch();
30+
31+
// For some reason the path /send/ doesn't show tokens anymore
3032
return (address)
3133
? FlowRouter.path('sendFrom', {from: address})
32-
: FlowRouter.path('send');
34+
: FlowRouter.path('sendFrom', {from: accounts[0] ? accounts[0].address : null });
3335
},
3436
/**
3537
Calculates the total balance of all accounts + wallets.

app/client/templates/views/modals/addToken.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ Template['views_modals_addToken'].events({
6666
*/
6767
'change input[name="address"], input input[name="address"]': function(e, template) {
6868
var tokenAddress = TemplateVar.getFrom('.token-address', 'value');
69+
70+
var l = e.currentTarget.value.length;
71+
if (!tokenAddress && l > 2 && l < 6) {
72+
e.currentTarget.value += '.thetoken.eth';
73+
e.currentTarget.setSelectionRange(l,l+13);
74+
}
75+
6976

7077
if(!tokenAddress || (template.data && template.data.address && template.data.address == tokenAddress))
7178
return;

0 commit comments

Comments
 (0)