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

fixes token selection when sending via the zebra-token-list #361

Merged
merged 2 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should fix regression

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