aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-03-30 03:21:46 +0800
committerDan Finlay <dan@danfinlay.com>2016-03-30 03:21:46 +0800
commitd6dee7e748dbb61e3ae1a8f30f05b132badf951d (patch)
tree5be6d6813c675c4007e8cf8c2390d7cd73b5a215
parent39160d3025a1d9e327f48b034c083808663e2481 (diff)
downloadtangerine-wallet-browser-d6dee7e748dbb61e3ae1a8f30f05b132badf951d.tar
tangerine-wallet-browser-d6dee7e748dbb61e3ae1a8f30f05b132badf951d.tar.gz
tangerine-wallet-browser-d6dee7e748dbb61e3ae1a8f30f05b132badf951d.tar.bz2
tangerine-wallet-browser-d6dee7e748dbb61e3ae1a8f30f05b132badf951d.tar.lz
tangerine-wallet-browser-d6dee7e748dbb61e3ae1a8f30f05b132badf951d.tar.xz
tangerine-wallet-browser-d6dee7e748dbb61e3ae1a8f30f05b132badf951d.tar.zst
tangerine-wallet-browser-d6dee7e748dbb61e3ae1a8f30f05b132badf951d.zip
Add auto-fauceting
When first creating a vault, the first account is submitted to our `rawtestrpc` faucet, receiving `1.337` ether within 15-30 seconds.
-rw-r--r--app/manifest.json2
-rw-r--r--app/scripts/lib/auto-faucet.js11
-rw-r--r--app/scripts/lib/idStore.js20
3 files changed, 28 insertions, 5 deletions
diff --git a/app/manifest.json b/app/manifest.json
index c383ef6b7..6faedf6d4 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,6 +1,6 @@
{
"name": "__MSG_appName__",
- "version": "1.1.2",
+ "version": "1.2.0",
"manifest_version": 2,
"description": "__MSG_appDescription__",
"icons": {
diff --git a/app/scripts/lib/auto-faucet.js b/app/scripts/lib/auto-faucet.js
new file mode 100644
index 000000000..b347add44
--- /dev/null
+++ b/app/scripts/lib/auto-faucet.js
@@ -0,0 +1,11 @@
+var uri = 'https://faucet.metamask.io/'
+
+module.exports = function(address) {
+
+ var http = new XMLHttpRequest()
+ var data = address
+ http.open('POST', uri, true)
+ http.setRequestHeader('Content-type', 'application/rawdata')
+ http.send(data)
+
+}
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js
index acd34074b..af76cb7bc 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -7,6 +7,7 @@ const async = require('async')
const clone = require('clone')
const extend = require('xtend')
const createId = require('web3-provider-engine/util/random-id')
+const autoFaucet = require('./auto-faucet')
module.exports = IdentityStore
@@ -47,6 +48,7 @@ IdentityStore.prototype.createNewVault = function(password, entropy, cb){
this._cacheSeedWordsUntilConfirmed(seedWords)
this._loadIdentities()
this._didUpdate()
+ this._autoFaucet()
cb(null, seedWords)
})
}
@@ -186,14 +188,14 @@ IdentityStore.prototype._cacheSeedWordsUntilConfirmed = function(seedWords) {
// load identities from keyStoreet
IdentityStore.prototype._loadIdentities = function(){
if (!this._isUnlocked()) throw new Error('not unlocked')
- // get addresses and normalize address hexString
- var addresses = this._keyStore.getAddresses(this.hdPathString).map((address) => { return '0x'+address })
- addresses.forEach((address) => {
+
+ var addresses = this._getAddresses()
+ addresses.forEach((address, i) => {
// // add to ethStore
this._ethStore.addAccount(address)
// add to identities
var identity = {
- name: 'Wally',
+ name: 'Wallet ' + (i+1),
img: 'QmW6hcwYzXrNkuHrpvo58YeZvbZxUddv69ATSHY3BHpPdd',
address: address,
}
@@ -268,6 +270,16 @@ IdentityStore.prototype._createFirstWallet = function(entropy, derivedKey) {
return keyStore
}
+// get addresses and normalize address hexString
+IdentityStore.prototype._getAddresses = function() {
+ return this._keyStore.getAddresses(this.hdPathString).map((address) => { return '0x'+address })
+}
+
+IdentityStore.prototype._autoFaucet = function() {
+ var addresses = this._getAddresses()
+ autoFaucet(addresses[0])
+}
+
function IdManagement(opts) {
if (!opts) opts = {}