Skip to content

Commit

Permalink
Purchased Event added
Browse files Browse the repository at this point in the history
  • Loading branch information
stanacton committed Jan 24, 2018
1 parent e0018b7 commit 61ea2e0
Show file tree
Hide file tree
Showing 12 changed files with 1,136 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/dapp/GruntFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = function(grunt) {
},
watch: {
files: ['<%= jshint.files %>','tests/**/*Spec.js','app/**/*','public/stylesheets/*.less'],
tasks: ['jshint','concat' ,'less','copy']
tasks: ['concat' ,'less','copy']
}
});

Expand Down
42 changes: 42 additions & 0 deletions src/dapp/app/controllers/CoinAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,48 @@ app.controller("CoinAdminCtrl", ['$scope', 'web3', 'ico', '$rootScope', function
});
};

$scope.claimOwnership = function() {
ico.claimOwnership(function(err, response) {
if (err) {
alert(err);
return;
}
alert("Transaction Sent");

$scope.$apply();
});
};

$scope.transferOwnership = function(newAddress) {
if (!newAddress) {
return alert("newAddress is required.");
}

ico.transferOwnership(newAddress, function(err, response) {
if (err) {
alert(err);
return;
}
alert("Transaction Sent");
$scope.$apply();
});
};

$scope.getUserTransactions = function(userAddress) {
userAddress = "dummy";
if (!userAddress) {
return alert("userAddress is required");
}

ico.getUserTransactions(userAddress, function (err, response) {
if (err) {
return alert(err);
}

console.log(JSON.stringify(response, null, 4));
});
};

$rootScope.$on("new-block", function (event) {
updateDetails();
});
Expand Down
38 changes: 35 additions & 3 deletions src/dapp/app/partials/coin-admin.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<div id="page-coin-admin">
<h2>Coin Settings / admin</h2>
<div>
Expand Down Expand Up @@ -135,7 +136,7 @@ <h3>Withdraw Ether from ICO</h3>
<button ng-click="withdrawEth()" class="btn btn-danger btn-lg">Withdraw ETH from ICO</button>
</p>
</div>

<div class="row admin-action">
<h3>Refund User</h3>
<p>This will refund the user the specified number of tokens and ETH. This will not refund the users whole allocation unless you specify their whole amount.</p>
Expand Down Expand Up @@ -178,7 +179,7 @@ <h3>Whitelist
<div class="form-group col-lg-9">
<label for="whitelistAddress">User Address</label>
<input class="form-control" type="text" id="whitelistAddress" ng-model="whitelistAddress" placeholder="User Address e.g. 0xac89b7s..."
ng-change="checkWhitelistStatus(whitelistAddress)"
ng-change="checkWhitelistStatus(whitelistAddress)"
/>
</div>
<div class="col-lg-3">
Expand All @@ -201,7 +202,7 @@ <h3>Custom Price</h3>
<div class="form-group col-lg-9">
<label for="customerPriceAddress">User Address</label>
<input class="form-control" type="text" id="customerPriceAddress" ng-model="customerPriceAddress" placeholder="User Address e.g. 0xac89b7s..."
ng-change="checkPriceForCustomer(customerPriceAddress)"
ng-change="checkPriceForCustomer(customerPriceAddress)"
/>
</div>
<div class="form-group col-lg-9">
Expand All @@ -216,4 +217,35 @@ <h3>Custom Price</h3>
<button class="btn btn-default" ng-click="checkPriceForCustomer(customerPriceAddress)">Check Current Price</button>
<button class="btn btn-primary" ng-click="setPriceForCustomer(customerPriceAddress, newCustomerPrice)">Set Custom Price</button>
</div>

<div class="row admin-action">
<h3>Transfer Ownership</h3>
<p>
As the owner, you can transfer ownership to someone else by providing their address below. They must then call 'claimOwnership' to
actually become the owner. Or they can come here and press "Claim Ownership".
</p>
<div class="row">
<div class="form-group col-lg-9">
<label for="newOwnerAddress">User Address</label>
<input class="form-control" type="text" id="newOwnerAddress" ng-model="newOwnerAddress" placeholder="User Address e.g. 0xac89b7s..."
ng-change=""
/>
</div>
</div>

<button class="btn btn-danger" ng-click="transferOwnership(newOwnerAddress)">Transfer Ownership</button>
</div>

<div class="row admin-action">
<h3>Claim Ownership</h3>
<p>
If someone has called transfer ownership for you. Then you can claim this contract here.
</p>

<button class="btn btn-primary " ng-click="claimOwnership(newOwnerAddress)">Transfer Ownership</button>



<button class="btn btn-primary " ng-click="getUserTransactions(newOwnerAddress)">List Transaction</button>
</div>
</div>
46 changes: 45 additions & 1 deletion src/dapp/app/services/ico.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,47 @@
});
}

function transferOwnership(newOwner, next) {
if (!newOwner) {
return next({message: "newOwner is required."});
}

getICO().then(function (ico) {
ico.transferOwnership.sendTransaction(newOwner, next);
});
}

function claimOwnership(next) {
getICO().then(function (ico) {
ico.claimOwnership.sendTransaction(next);
});
}

function getUserTransactions(userAddress, next) {
getICO().then(function (ico) {
ico.Transfer({to: "0x2175f98baf93c4ed810c71a1e0e9dfbc080fe994"}, {fromBlock: '0', toBlock: 'latest' })
.get(function(err, results) {
if (err) {
return next(err);
} else {
if (!Array.isArray(results)) return next("unexpected results format");

var mapped = results.map(function (value) {
return {
from: value.args.from,
to: value.args.to,
value: web3.fromWei(value.args.value).valueOf(),
blockHash: value.blockHash,
blockNumber: value.blockNumber,
transactionHash: value.transactionHash
};
});

next(null, mapped);
}
});
});
}

return {
balance: balance,
Expand Down Expand Up @@ -399,7 +440,10 @@
takeOwnership: takeOwnership,
setPriceForCustomer: setPriceForCustomer,
checkPriceForCustomer: checkPriceForCustomer,
unpauseICO: unpauseICO
unpauseICO: unpauseICO,
claimOwnership: claimOwnership,
transferOwnership: transferOwnership,
getUserTransactions: getUserTransactions
};
}]);
})();
2 changes: 1 addition & 1 deletion src/dapp/bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var http = require('http');
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
var port = normalizePort(process.env.PORT || '3030');
app.set('port', port);

/**
Expand Down
Loading

0 comments on commit 61ea2e0

Please sign in to comment.