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

Commit

Permalink
fixes token selection when sending via the zebra-token-list (#361)
Browse files Browse the repository at this point in the history
* fix

* update deployContract
  • Loading branch information
luclu authored and alexvansande committed Apr 12, 2017
1 parent 4cb9dc0 commit 42d5aba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 deletions.
4 changes: 1 addition & 3 deletions app/client/templates/views/send.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<template name="views_send">

{{reactiveData}}


<!-- we use a form, which posts into the "dapp-form-helper-iframe" iframe, so that the browser stores inout fields for native autocpmplete -->
<form class="account-send-form" action="about:blank" target="dapp-form-helper-iframe" autocomplete="on">

Expand Down
43 changes: 18 additions & 25 deletions app/client/templates/views/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,38 +101,49 @@ Template['views_send'].onCreated(function(){
TemplateVar.set('amount', '0');
TemplateVar.set('estimatedGas', 300000);
TemplateVar.set('sendAll', false);

// Deploy contract
if(FlowRouter.getRouteName() === 'deployContract') {
TemplateVar.set('selectedAction', 'deploy-contract');
TemplateVar.set('selectedToken', 'ether');

// Send funds
} else {
TemplateVar.set('selectedAction', 'send-funds');
TemplateVar.set('selectedToken', FlowRouter.getParam('token') || 'ether');
}

// check if we are still on the correct chain
Helpers.checkChain(function(error) {
if(error && (EthAccounts.find().count() > 0)) {
checkForOriginalWallet();
}
});

// change the token type when the account is changed
template.autorun(function(c){
var address = TemplateVar.getFrom('.dapp-select-account.send-from', 'value');

if(!c.firstRun) {
if(!c.firstRun && FlowRouter.getParam('from') !== address) {
TemplateVar.set('selectedToken', 'ether');
}
});


// check daily limit again, when the account was switched
template.autorun(function(c){
var address = TemplateVar.getFrom('.dapp-select-account.send-from', 'value'),
amount = TemplateVar.get('amount') || '0';

if(!c.firstRun) {
checkOverDailyLimit(address, amount, template);
}
});

// change the amount when the currency unit is changed
template.autorun(function(c){
var unit = EthTools.getUnit();

if(!c.firstRun && TemplateVar.get('selectedToken') === 'ether') {
TemplateVar.set('amount', EthTools.toWei(template.find('input[name="amount"]').value.replace(',','.'), unit));
}
Expand Down Expand Up @@ -207,24 +218,6 @@ Template['views_send'].onRendered(function(){


Template['views_send'].helpers({
/**
React on the template data context
@method (reactiveData)
*/
'reactiveData': function(deployContract){

// Deploy contract
if(this && this.deployContract) {
TemplateVar.set('selectedAction', 'deploy-contract');
TemplateVar.set('selectedToken', 'ether');

// Send funds
} else {
TemplateVar.set('selectedAction', 'send-funds');
TemplateVar.set('selectedToken', FlowRouter.getParam('token') || 'ether');
}
},
/**
Get the current selected account
Expand Down

0 comments on commit 42d5aba

Please sign in to comment.