Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

minor typo fix and added extra security checks #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
build
build_webpack
npm-debug.log
.env
.DS_Store
.truffle-solidity-loader
16 changes: 13 additions & 3 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ App = {
// Set the provider for our contract.
App.contracts.TutorialToken.setProvider(App.web3Provider);

// Use our contract to retieve and mark the adopted pets.
// Get My Balance
return App.getBalances();
});

Expand All @@ -46,7 +46,7 @@ App = {
var amount = parseInt($('#TTTransferAmount').val());
var toAddress = $('#TTTransferAddress').val();

console.log('Transfer ' + amount + ' TT to ' + toAddress);
console.log('Transferring ' + amount + ' TT to ' + toAddress);

var tutorialTokenInstance;

Expand All @@ -57,20 +57,30 @@ App = {

var account = accounts[0];

// cannot transfer tokens to ownself
if (toAddress.toLowerCase() == account.toLowerCase()) {
alert('Sorry, you cannot transfer tokens nto yourself');
Copy link

Choose a reason for hiding this comment

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

typo: nto should be to

throw new Error('Sorry, you cannot transfer tokens to yourself');
}

App.contracts.TutorialToken.deployed().then(function(instance) {
tutorialTokenInstance = instance;

return tutorialTokenInstance.transfer(toAddress, amount, {from: account});
}).then(function(result) {
alert('Transfer Successful!');
// clean up input boxes
$('#TTTransferAmount').val('');
$('#TTTransferAddress').val('');

return App.getBalances();
}).catch(function(err) {
console.log(err.message);
});
});
},

getBalances: function(adopters, account) {
getBalances: function() {
console.log('Getting balances...');

var tutorialTokenInstance;
Expand Down