1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 17:33:23 +01:00

Fix conflict

This commit is contained in:
Frankie 2016-06-21 15:04:00 -07:00
commit cf663f1104
76 changed files with 2542 additions and 2516 deletions

151
.eslintrc Normal file
View File

@ -0,0 +1,151 @@
{
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"impliedStrict": true,
"modules": true,
"blockBindings": true,
"arrowFunctions": true,
"objectLiteralShorthandMethods": true,
"objectLiteralShorthandProperties": true,
"templateStrings": true
},
},
"env": {
"es6": true,
"node": true,
"browser": true
},
"plugins": [
],
"globals": {
"chrome": true,
"document": false,
"navigator": false,
"web3": true,
"window": false
},
"rules": {
"accessor-pairs": 2,
"arrow-spacing": [2, { "before": true, "after": true }],
"block-spacing": [2, "always"],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"camelcase": [2, { "properties": "never" }],
"comma-dangle": [2, "always-multiline"],
"comma-spacing": [2, { "before": false, "after": true }],
"comma-style": [2, "last"],
"constructor-super": 2,
"curly": [2, "multi-line"],
"dot-location": [2, "property"],
"eol-last": 2,
"eqeqeq": [2, "allow-null"],
"generator-star-spacing": [2, { "before": true, "after": true }],
"handle-callback-err": [2, "^(err|error)$" ],
"indent": [2, 2, { "SwitchCase": 1 }],
"jsx-quotes": [2, "prefer-single"],
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"keyword-spacing": [2, { "before": true, "after": true }],
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-class-assign": 2,
"no-cond-assign": 2,
"no-const-assign": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-duplicate-imports": 2,
"no-empty-character-class": 2,
"no-empty-pattern": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": [2, "functions"],
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": [2, { "allowLoop": false, "allowSwitch": false }],
"no-lone-blocks": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, { "max": 1 }],
"no-native-reassign": 2,
"no-negated-in-lhs": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-symbol": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-path-concat": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-return-assign": [2, "except-parens"],
"no-self-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-unexpected-multiline": 2,
"no-unmodified-loop-condition": 2,
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
"no-unreachable": 2,
"no-unsafe-finally": 2,
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
"no-useless-call": 2,
"no-useless-computed-key": 2,
"no-useless-constructor": 2,
"no-useless-escape": 2,
"no-whitespace-before-property": 2,
"no-with": 2,
"one-var": [2, { "initialized": "never" }],
"operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": [2, "never"],
"quotes": [2, "single", "avoid-escape"],
"semi": [2, "never"],
"semi-spacing": [2, { "before": false, "after": true }],
"space-before-blocks": [1, "always"],
"space-before-function-paren": [1, "always"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
"strict": 0,
"template-curly-spacing": [2, "never"],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": [2, "any"],
"yield-star-spacing": [2, "both"],
"yoda": [2, "never"],
"prefer-const": 1
}
}

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
6.0

View File

@ -1,4 +1,4 @@
# Metamask Plugin [![Build Status](https://travis-ci.com/MetaMask/metamask-plugin.svg?token=3txzDGFpqQqvRCdgwTJp&branch=master)](https://travis-ci.com/MetaMask/metamask-plugin)
# Metamask Plugin [![Build Status](https://circleci.com/gh/MetaMask/metamask-plugin.svg?style=shield&circle-token=a1ddcf3cd38e29267f254c9c59d556d513e3a1fd)](https://circleci.com/gh/MetaMask/metamask-plugin)
## Architecture
@ -54,6 +54,8 @@ Then just run `npm test`.
You can also test with a continuously watching process, via `npm run watch`.
You can run the linter by itself with `gulp lint`.
### Deploying the UI
You must be authorized already on the Metamask plugin.

View File

@ -1,11 +1,9 @@
const urlUtil = require('url')
const Dnode = require('dnode')
const eos = require('end-of-stream')
const combineStreams = require('pumpify')
const extend = require('xtend')
const EthStore = require('eth-store')
const MetaMaskProvider = require('web3-provider-engine/zero.js')
const ObjectMultiplex = require('./lib/obj-multiplex')
const PortStream = require('./lib/port-stream.js')
const IdentityStore = require('./lib/idStore')
const createUnlockRequestNotification = require('./lib/notifications.js').createUnlockRequestNotification
@ -55,7 +53,6 @@ function setupTrustedCommunication(connectionStream, originDomain){
// state and network
//
var providerConfig = configManager.getProvider()
var idStore = new IdentityStore()
var providerOpts = {
@ -141,7 +138,6 @@ function storeSetFromObj(store, obj){
})
}
//
// remote features
//
@ -152,8 +148,10 @@ function setupPublicConfig(stream){
}
function setupProviderConnection (stream, originDomain) {
stream.on('data', function onRpcRequest(payload){
// decorate all payloads with origin domain
stream.on('data', function onRpcRequest (request) {
var payloads = Array.isArray(request) ? request : [request]
payloads.forEach(function (payload) {
// Append origin to rpc payload
payload.origin = originDomain
// Append origin to signature request
@ -162,9 +160,13 @@ function setupProviderConnection(stream, originDomain){
} else if (payload.method === 'eth_sign') {
payload.params.push({ origin: originDomain })
}
})
// handle rpc request
provider.sendAsync(payload, function onPayloadHandled(err, response){
logger(null, payload, response)
provider.sendAsync(request, function onPayloadHandled (err, response) {
if (err) {
return logger(err)
}
logger(null, request, response)
try {
stream.write(response)
} catch (err) {
@ -208,7 +210,6 @@ function setupControllerConnection(stream){
})
stream.pipe(dnode).pipe(stream)
dnode.on('remote', function (remote) {
// push updates to popup
ethStore.on('update', sendUpdate)
idStore.on('update', sendUpdate)
@ -220,7 +221,6 @@ function setupControllerConnection(stream){
var state = getState()
remote.sendUpdate(state)
}
})
}
@ -266,7 +266,6 @@ function newUnsignedMessage(msgParams, cb){
createUnlockRequestNotification({
title: 'Account Unlock Request',
})
var msgId = idStore.addUnconfirmedMessage(msgParams, cb)
} else {
addUnconfirmedMsg(msgParams, cb)
}

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,6 @@ const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
const PortStream = require('./lib/port-stream.js')
const ObjectMultiplex = require('./lib/obj-multiplex')
// inject in-page script
var scriptTag = document.createElement('script')
scriptTag.src = chrome.extension.getURL('scripts/inpage.js')

View File

@ -8,7 +8,6 @@ restoreContextAfterImports()
// remove from window
delete window.Web3
//
// setup plugin communication
//
@ -51,7 +50,7 @@ inpageProvider.publicConfigStore.subscribe(function(state){
// need to make sure we aren't affected by overlapping namespaces
// and that we dont affect the app with our namespace
// mostly a fix for web3's BigNumber if AMD's "define" is defined...
var __define = undefined
var __define
function cleanContextForImports () {
__define = global.define

View File

@ -1,11 +1,9 @@
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)
}

View File

@ -3,9 +3,7 @@ const ensnare = require('./ensnare.js')
module.exports = setupDappAutoReload
function setupDappAutoReload (web3, controlStream) {
// export web3 as a global, checking for usage
var pageIsUsingWeb3 = false
var resetWasRequested = false
@ -33,5 +31,4 @@ function setupDappAutoReload(web3, controlStream){
global.location.reload()
}, 500)
}
}

View File

@ -7,7 +7,6 @@ const STORAGE_KEY = 'metamask-config'
const TESTNET_RPC = MetamaskConfig.network.testnet
const MAINNET_RPC = MetamaskConfig.network.mainnet
/* The config-manager is a convenience object
* wrapping a pojo-migrator.
*
@ -62,7 +61,7 @@ ConfigManager.prototype.getConfig = function() {
return {
provider: {
type: 'testnet',
}
},
}
}
}
@ -234,17 +233,17 @@ ConfigManager.prototype.updateTx = function(tx) {
ConfigManager.prototype.getWalletNicknames = function () {
var data = this.getData()
let nicknames = ('walletNicknames' in data) ? data.walletNicknames : {}
const nicknames = ('walletNicknames' in data) ? data.walletNicknames : {}
return nicknames
}
ConfigManager.prototype.nicknameForWallet = function (account) {
let nicknames = this.getWalletNicknames()
const nicknames = this.getWalletNicknames()
return nicknames[account]
}
ConfigManager.prototype.setNicknameForWallet = function (account, nickname) {
let nicknames = this.getWalletNicknames()
const nicknames = this.getWalletNicknames()
nicknames[account] = nickname
var data = this.getData()
data.walletNicknames = nicknames
@ -281,9 +280,7 @@ ConfigManager.prototype.getConfirmed = function() {
return ('isConfirmed' in data) && data.isConfirmed
}
function loadData () {
var oldData = getOldStyleData()
var newData
try {
@ -298,10 +295,10 @@ function loadData() {
config: {
provider: {
type: 'testnet',
}
}
}
}, oldData ? oldData : null, newData ? newData : null)
},
},
},
}, oldData || null, newData || null)
return data
}

View File

@ -15,7 +15,7 @@ function ensnare(obj, cb){
default:
Object.defineProperty(proxy, key, {
get: function () { cb(); return obj[key] },
set: function(val){ cb(); return obj[key] = val },
set: function (val) { cb(); obj[key] = val; return val },
})
return
}

View File

@ -4,7 +4,6 @@ const configManager = require('./config-manager-singleton')
module.exports = IdManagement
function IdManagement (opts) {
if (!opts) opts = {}
@ -13,7 +12,7 @@ function IdManagement(opts) {
this.hdPathString = "m/44'/60'/0'/0"
this.getAddresses = function () {
return keyStore.getAddresses(this.hdPathString).map(function(address){ return '0x'+address })
return this.keyStore.getAddresses(this.hdPathString).map(function (address) { return '0x' + address })
}
this.signTx = function (txParams) {
@ -44,12 +43,12 @@ function IdManagement(opts) {
this.signMsg = function (address, message) {
// sign message
var privKeyHex = this.exportPrivateKey(address);
var privKey = ethUtil.toBuffer(privKeyHex);
var msgSig = ethUtil.ecsign(new Buffer(message.replace('0x',''), 'hex'), privKey);
var rawMsgSig = ethUtil.bufferToHex(concatSig(msgSig.v, msgSig.r, msgSig.s));
return rawMsgSig;
};
var privKeyHex = this.exportPrivateKey(address)
var privKey = ethUtil.toBuffer(privKeyHex)
var msgSig = ethUtil.ecsign(new Buffer(message.replace('0x', ''), 'hex'), privKey)
var rawMsgSig = ethUtil.bufferToHex(concatSig(msgSig.v, msgSig.r, msgSig.s))
return rawMsgSig
}
this.getSeed = function () {
return this.keyStore.getSeed(this.derivedKey)
@ -61,17 +60,17 @@ function IdManagement(opts) {
}
}
function pad_with_zeroes(number, length){
var my_string = '' + number;
while (my_string.length < length) {
my_string = '0' + my_string;
function padWithZeroes (number, length) {
var myString = '' + number
while (myString.length < length) {
myString = '0' + myString
}
return my_string;
return myString
}
function concatSig (v, r, s) {
r = pad_with_zeroes(ethUtil.fromSigned(r), 64)
s = pad_with_zeroes(ethUtil.fromSigned(s), 64)
r = padWithZeroes(ethUtil.fromSigned(r), 64)
s = padWithZeroes(ethUtil.fromSigned(s), 64)
r = ethUtil.stripHexPrefix(r.toString('hex'))
s = ethUtil.stripHexPrefix(s.toString('hex'))
v = ethUtil.stripHexPrefix(ethUtil.intToHex(v))

View File

@ -1,10 +1,7 @@
const EventEmitter = require('events').EventEmitter
const inherits = require('util').inherits
const Transaction = require('ethereumjs-tx')
const ethUtil = require('ethereumjs-util')
const LightwalletKeyStore = require('eth-lightwallet').keystore
const LightwalletSigner = require('eth-lightwallet').signing
const async = require('async')
const clone = require('clone')
const extend = require('xtend')
const createId = require('web3-provider-engine/util/random-id')
@ -15,10 +12,8 @@ const messageManager = require('./message-manager')
const DEFAULT_RPC = 'https://testrpc.metamask.io/'
const IdManagement = require('./id-management')
module.exports = IdentityStore
inherits(IdentityStore, EventEmitter)
function IdentityStore (opts = {}) {
EventEmitter.call(this)
@ -90,7 +85,6 @@ IdentityStore.prototype.clearSeedWordCache = function(cb) {
IdentityStore.prototype.getState = function () {
var seedWords = this.getSeedIfUnlocked()
var wallet = configManager.getWallet()
return clone(extend(this._currentState, {
isInitialized: !!configManager.getWallet() && !seedWords,
isUnlocked: this._isUnlocked(),
@ -127,7 +121,6 @@ IdentityStore.prototype.setSelectedAddress = function(address, cb){
}
IdentityStore.prototype.revealAccount = function (cb) {
let addresses = this._getAddresses()
const derivedKey = this._idmgmt.derivedKey
const keyStore = this._keyStore
@ -135,14 +128,12 @@ IdentityStore.prototype.revealAccount = function(cb) {
keyStore.generateNewAddress(derivedKey, 1)
configManager.setWallet(keyStore.serialize())
addresses = this._getAddresses()
this._loadIdentities()
this._didUpdate()
cb(null)
}
IdentityStore.prototype.getNetwork = function (err) {
if (err) {
this._currentState.network = 'loading'
this._didUpdate()
@ -232,12 +223,10 @@ IdentityStore.prototype.addUnconfirmedTransaction = function(txParams, onTxDoneC
// signal completion of add tx
cb(null, txData)
}
}
// comes from metamask ui
IdentityStore.prototype.approveTransaction = function (txId, cb) {
var txData = configManager.getTx(txId)
var approvalCb = this._unconfTxCbs[txId] || noop
// accept tx
@ -251,7 +240,6 @@ IdentityStore.prototype.approveTransaction = function(txId, cb){
// comes from metamask ui
IdentityStore.prototype.cancelTransaction = function (txId) {
var txData = configManager.getTx(txId)
var approvalCb = this._unconfTxCbs[txId] || noop
// reject tx
@ -279,7 +267,6 @@ IdentityStore.prototype.signTransaction = function(txParams, cb){
// comes from dapp via zero-client hooked-wallet provider
IdentityStore.prototype.addUnconfirmedMessage = function (msgParams, cb) {
// create txData obj with parameters and meta data
var time = (new Date()).getTime()
var msgId = createId()
@ -304,7 +291,6 @@ IdentityStore.prototype.addUnconfirmedMessage = function(msgParams, cb){
// comes from metamask ui
IdentityStore.prototype.approveMessage = function (msgId, cb) {
var msgData = messageManager.getMsg(msgId)
var approvalCb = this._unconfMsgCbs[msgId] || noop
// accept msg
@ -318,7 +304,6 @@ IdentityStore.prototype.approveMessage = function(msgId, cb){
// comes from metamask ui
IdentityStore.prototype.cancelMessage = function (msgId) {
var txData = messageManager.getMsg(msgId)
var approvalCb = this._unconfMsgCbs[msgId] || noop
// reject tx
@ -448,7 +433,7 @@ IdentityStore.prototype._createIdmgmt = function(password, seed, entropy, cb){
IdentityStore.prototype._restoreFromSeed = function (password, seed, derivedKey) {
var keyStore = new LightwalletKeyStore(seed, derivedKey, this.hdPathString)
keyStore.addHdDerivationPath(this.hdPathString, derivedKey, {curve: 'secp256k1', purpose: 'sign'});
keyStore.addHdDerivationPath(this.hdPathString, derivedKey, {curve: 'secp256k1', purpose: 'sign'})
keyStore.setDefaultHdDerivationPath(this.hdPathString)
keyStore.generateNewAddress(derivedKey, 3)
@ -460,7 +445,7 @@ IdentityStore.prototype._restoreFromSeed = function(password, seed, derivedKey)
IdentityStore.prototype._createFirstWallet = function (entropy, derivedKey) {
var secretSeed = LightwalletKeyStore.generateRandomSeed(entropy)
var keyStore = new LightwalletKeyStore(secretSeed, derivedKey, this.hdPathString)
keyStore.addHdDerivationPath(this.hdPathString, derivedKey, {curve: 'secp256k1', purpose: 'sign'});
keyStore.addHdDerivationPath(this.hdPathString, derivedKey, {curve: 'secp256k1', purpose: 'sign'})
keyStore.setDefaultHdDerivationPath(this.hdPathString)
keyStore.generateNewAddress(derivedKey, 3)

View File

@ -7,7 +7,6 @@ const MetamaskConfig = require('../config.js')
module.exports = MetamaskInpageProvider
function MetamaskInpageProvider (connectionStream) {
const self = this
@ -49,19 +48,20 @@ function MetamaskInpageProvider(connectionStream){
MetamaskInpageProvider.prototype.send = function (payload) {
const self = this
let selectedAddress
var result = null
switch (payload.method) {
case 'eth_accounts':
// read from localStorage
var selectedAddress = self.publicConfigStore.get('selectedAddress')
selectedAddress = self.publicConfigStore.get('selectedAddress')
result = selectedAddress ? [selectedAddress] : []
break
case 'eth_coinbase':
// read from localStorage
var selectedAddress = self.publicConfigStore.get('selectedAddress')
selectedAddress = self.publicConfigStore.get('selectedAddress')
result = selectedAddress || '0x0000000000000000000000000000000000000000'
break
@ -91,7 +91,7 @@ MetamaskInpageProvider.prototype.isConnected = function(){
function createSyncProvider (providerConfig) {
providerConfig = providerConfig || {}
var syncProviderUrl = undefined
let syncProviderUrl
if (providerConfig.rpcTarget) {
syncProviderUrl = providerConfig.rpcTarget

View File

@ -3,7 +3,6 @@ const inherits = require('util').inherits
module.exports = LocalMessageDuplexStream
inherits(LocalMessageDuplexStream, Duplex)
function LocalMessageDuplexStream (opts) {

View File

@ -11,7 +11,6 @@ module.exports = {
setupListeners()
function setupListeners () {
// guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236
if (!chrome.notifications) return console.error('Chrome notifications API missing...')
@ -30,7 +29,6 @@ function setupListeners(){
chrome.notifications.onClosed.addListener(function (notificationId) {
delete notificationHandlers[notificationId]
})
}
// creation helper
@ -46,7 +44,6 @@ function createUnlockRequestNotification(opts){
title: opts.title,
message: message,
})
}
function createTxNotification (opts) {
@ -71,7 +68,7 @@ function createTxNotification(opts){
title: 'confirm',
}, {
title: 'cancel',
}]
}],
})
notificationHandlers[id] = {
confirm: opts.confirm,
@ -99,7 +96,7 @@ function createMsgNotification(opts){
title: 'confirm',
}, {
title: 'cancel',
}]
}],
})
notificationHandlers[id] = {
confirm: opts.confirm,

View File

@ -2,7 +2,6 @@ const through = require('through2')
module.exports = ObjectMultiplex
function ObjectMultiplex (opts) {
opts = opts || {}
// create multiplexer

View File

@ -3,7 +3,6 @@ const inherits = require('util').inherits
module.exports = PortDuplexStream
inherits(PortDuplexStream, Duplex)
function PortDuplexStream (port) {

View File

@ -1,7 +1,6 @@
const Through = require('through2')
const ObjectMultiplex = require('./obj-multiplex')
module.exports = {
jsonParseStream: jsonParseStream,
jsonStringifyStream: jsonStringifyStream,

View File

@ -9,5 +9,5 @@ module.exports = {
}
} catch (e) {}
return data
}
},
}

View File

@ -11,5 +11,5 @@ module.exports = {
}
} catch (e) {}
return data
}
},
}

View File

@ -7,16 +7,16 @@ module.exports = {
switch (data.config.provider.rpcTarget) {
case 'https://testrpc.metamask.io/':
data.config.provider = {
type: 'testnet'
type: 'testnet',
}
break
case 'https://rpc.metamask.io/':
data.config.provider = {
type: 'mainnet'
type: 'mainnet',
}
break
}
} catch (_) {}
return data
}
},
}

View File

@ -69,12 +69,11 @@ function setupApp(err, opts){
if (err) {
alert(err.stack)
throw err
return
}
var container = document.getElementById('app-content')
var app = MetaMaskUi({
MetaMaskUi({
container: container,
accountManager: opts.accountManager,
currentDomain: opts.currentDomain,

3
circle.yml Normal file
View File

@ -0,0 +1,3 @@
machine:
node:
version: 6.0.0

View File

@ -9,6 +9,9 @@ var sourcemaps = require('gulp-sourcemaps')
var assign = require('lodash.assign')
var livereload = require('gulp-livereload')
var del = require('del')
var eslint = require('gulp-eslint')
var fs = require('fs')
var path = require('path')
// browser reload
@ -49,6 +52,25 @@ gulp.task('copy:watch', function(){
gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy'))
})
// lint js
gulp.task('lint', function () {
// Ignoring node_modules, dist, and docs folders:
return gulp.src(['app/**/*.js', 'ui/**/*.js', '!node_modules/**', '!dist/**', '!docs/**', '!app/scripts/chromereload.js'])
.pipe(eslint(fs.readFileSync(path.join(__dirname, '.eslintrc'))))
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError())
});
/*
gulp.task('default', ['lint'], function () {
// This will only run if the lint task is successful...
});
*/
// build js

View File

@ -36,6 +36,7 @@
"eth-store": "^1.1.0",
"ethereumjs-tx": "^1.0.0",
"ethereumjs-util": "^4.4.0",
"gulp-eslint": "^2.0.0",
"hat": "0.0.3",
"identicon.js": "^1.2.1",
"inject-css": "^0.1.1",
@ -68,6 +69,7 @@
"xtend": "^4.0.1"
},
"devDependencies": {
"babel-eslint": "^6.0.5",
"babel-preset-es2015": "^6.6.0",
"babel-register": "^6.7.2",
"babelify": "^7.2.0",
@ -87,6 +89,7 @@
"jshint-stylish": "~0.1.5",
"lodash.assign": "^4.0.6",
"mocha": "^2.4.5",
"mocha-eslint": "^2.1.1",
"mocha-jsdom": "^1.1.0",
"mocha-sinon": "^1.1.5",
"sinon": "^1.17.3",

View File

@ -0,0 +1,9 @@
// LINTING:
const lint = require('mocha-eslint');
const lintPaths = ['app/**/*.js', 'ui/**/*.js', '!node_modules/**', '!dist/**', '!docs/**', '!app/scripts/chromereload.js']
const lintOptions = {
strict: true,
}
lint(lintPaths, lintOptions)

View File

@ -40,8 +40,6 @@ AccountDetailScreen.prototype.render = function() {
var selected = props.address || Object.keys(props.accounts)[0]
var identity = props.identities[selected]
var account = props.accounts[selected]
var accountDetail = props.accountDetail
var transactions = props.transactions
return (
@ -88,7 +86,7 @@ AccountDetailScreen.prototype.render = function() {
style: {
height: '62px',
paddingTop: '8px',
}
},
}, [
h(EditableLabel, {
textValue: identity ? identity.name : '',
@ -216,7 +214,7 @@ AccountDetailScreen.prototype.transactionList = function() {
unconfMsgs,
viewPendingTx: (txId) => {
this.props.dispatch(actions.viewPendingTx(txId))
}
},
})
}

View File

@ -9,7 +9,6 @@ const Identicon = require('../components/identicon')
module.exports = NewComponent
inherits(NewComponent, Component)
function NewComponent () {
Component.call(this)
@ -17,10 +16,8 @@ function NewComponent() {
NewComponent.prototype.render = function () {
const identity = this.props.identity
var mayBeFauceting = identity.mayBeFauceting
var isSelected = this.props.selectedAddress === identity.address
var account = this.props.accounts[identity.address]
var isFauceting = mayBeFauceting && account.balance === '0x0'
const selectedClass = isSelected ? '.selected' : ''
return (
@ -35,7 +32,7 @@ NewComponent.prototype.render = function() {
h('.identicon-wrapper.flex-column.flex-center.select-none', [
this.pendingOrNot(),
h(Identicon, {
address: identity.address
address: identity.address,
}),
]),
@ -70,9 +67,12 @@ NewComponent.prototype.render = function() {
event.preventDefault()
copyToClipboard(ethUtil.toChecksumAddress(identity.address))
},
<<<<<<< HEAD
style:{
margin: '0px 5px',
},
=======
>>>>>>> master
}),
]),
])

View File

@ -2,7 +2,6 @@ const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const extend = require('xtend')
const actions = require('../actions')
const valuesFor = require('../util').valuesFor
const findDOMNode = require('react-dom').findDOMNode
@ -10,7 +9,6 @@ const AccountPanel = require('./account-panel')
module.exports = connect(mapStateToProps)(AccountsScreen)
function mapStateToProps (state) {
const pendingTxs = valuesFor(state.metamask.unconfTxs)
const pendingMsgs = valuesFor(state.metamask.unconfMsgs)
@ -32,7 +30,6 @@ function AccountsScreen() {
Component.call(this)
}
AccountsScreen.prototype.render = function () {
var state = this.props
var identityList = valuesFor(state.identities)
@ -63,7 +60,7 @@ AccountsScreen.prototype.render = function() {
height: '418px',
overflowY: 'auto',
overflowX: 'hidden',
}
},
},
[
identityList.map((identity) => {
@ -100,7 +97,7 @@ AccountsScreen.prototype.render = function() {
paddint: '10px',
justifyContent: 'center',
alignItems: 'center',
}
},
}, [
h('i.fa.fa-plus.fa-lg', {key: ''}),
]),

View File

@ -139,12 +139,6 @@ function closeMenu() {
}
}
function getNetworkStatus(){
return {
type: actions.getNetworkStatus,
}
}
// async actions
function tryUnlockMetamask (password) {
@ -164,6 +158,9 @@ function createNewVault(password, entropy) {
return (dispatch) => {
dispatch(actions.createNewVaultInProgress())
_accountManager.createNewVault(password, entropy, (err, result) => {
if (err) {
return dispatch(actions.showWarning(err.message))
}
dispatch(actions.showNewVaultSeed(result))
})
}
@ -296,7 +293,6 @@ function cancelTx(txData){
// initialize screen
//
function showCreateVault () {
return {
type: actions.SHOW_CREATE_VAULT,
@ -319,6 +315,10 @@ function agreeToDisclaimer() {
return (dispatch) => {
dispatch(this.showLoadingIndication())
_accountManager.agreeToDisclaimer((err) => {
if (err) {
return dispatch(actions.showWarning(err.message))
}
dispatch(this.hideLoadingIndication())
dispatch({
type: this.AGREE_TO_DISCLAIMER,
@ -373,10 +373,14 @@ function updateMetamaskState(newState) {
function lockMetamask () {
return (dispatch) => {
_accountManager.setLocked((err) => {
dispatch(actions.hideLoadingIndication())
if (err) {
return dispatch(actions.showWarning(err.message))
}
dispatch({
type: actions.LOCK_METAMASK,
})
dispatch(actions.hideLoadingIndication())
})
}
}
@ -386,6 +390,10 @@ function showAccountDetail(address) {
dispatch(actions.showLoadingIndication())
_accountManager.setSelectedAddress(address, (err, address) => {
dispatch(actions.hideLoadingIndication())
if (err) {
return dispatch(actions.showWarning(err.message))
}
dispatch({
type: actions.SHOW_ACCOUNT_DETAIL,
value: address,
@ -411,6 +419,11 @@ function confirmSeedWords() {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
_accountManager.clearSeedWordCache((err, account) => {
dispatch(actions.hideLoadingIndication())
if (err) {
return dispatch(actions.showWarning(err.message))
}
console.log('Seed word cache cleared. ' + account)
dispatch(actions.showAccountDetail(account))
})

View File

@ -1,10 +1,7 @@
const inherits = require('util').inherits
const React = require('react')
const Component = require('react').Component
const PropTypes = require('react').PropTypes
const connect = require('react-redux').connect
const h = require('react-hyperscript')
const extend = require('xtend')
const actions = require('./actions')
const ReactCSSTransitionGroup = require('react-addons-css-transition-group')
// init
@ -25,7 +22,6 @@ const ConfigScreen = require('./config')
const RevealSeedConfirmation = require('./recover-seed/confirmation')
const InfoScreen = require('./info')
const LoadingIndicator = require('./loading')
const txHelper = require('../lib/tx-helper')
const SandwichExpando = require('sandwich-expando')
const MenuDroppo = require('menu-droppo')
const DropMenuItem = require('./components/drop-menu-item')
@ -33,7 +29,6 @@ const NetworkIndicator = require('./components/network')
module.exports = connect(mapStateToProps)(App)
inherits(App, Component)
function App () { Component.call(this) }
@ -56,7 +51,6 @@ function mapStateToProps(state) {
App.prototype.render = function () {
var props = this.props
var view = props.currentView.name
var transForward = props.transForward
return (
@ -65,7 +59,7 @@ App.prototype.render = function() {
style: {
// Windows was showing a vertical scroll bar:
overflow: 'hidden',
}
},
}, [
h(LoadingIndicator),
@ -80,7 +74,7 @@ App.prototype.render = function() {
style: {
height: '380px',
width: '360px',
}
},
}, [
h(ReactCSSTransitionGroup, {
className: 'css-transition-group',
@ -121,7 +115,7 @@ App.prototype.renderAppBar = function(){
event.preventDefault()
event.stopPropagation()
this.setState({ isNetworkMenuOpen: !isNetworkMenuOpen })
}
},
}),
// metamask name
@ -149,8 +143,6 @@ App.prototype.renderNetworkDropdown = function() {
const state = this.state || {}
const isOpen = state.isNetworkMenuOpen
const checked = h('i.fa.fa-check.fa-lg', { ariaHidden: true })
return h(MenuDroppo, {
isOpen,
onClickOutside: (event) => {
@ -252,7 +244,6 @@ App.prototype.renderPrimary = function(){
// show initialize screen
if (!props.isInitialized) {
// show current view
switch (props.currentView.name) {

View File

@ -6,14 +6,13 @@ const actions = require('../actions')
module.exports = ExportAccountView
inherits(ExportAccountView, Component)
function ExportAccountView () {
Component.call(this)
}
ExportAccountView.prototype.render = function () {
console.log("EXPORT VIEW")
console.log('EXPORT VIEW')
console.dir(this.props)
var state = this.props
var accountDetail = state.accountDetail
@ -47,13 +46,13 @@ ExportAccountView.prototype.render = function() {
style: {
position: 'relative',
top: '1.5px',
}
},
}),
h('button', {
onClick: () => this.onExportKeyPress({ key: 'Enter', preventDefault: () => {} }),
}, 'Submit'),
h('button', {
onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address))
onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)),
}, 'Cancel'),
])
@ -74,10 +73,10 @@ ExportAccountView.prototype.render = function() {
},
onClick: function (event) {
copyToClipboard(accountDetail.privateKey)
}
},
}, accountDetail.privateKey),
h('button', {
onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address))
onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)),
}, 'Done'),
])
}

View File

@ -1,16 +1,13 @@
const inherits = require('util').inherits
const ethUtil = require('ethereumjs-util')
const Component = require('react').Component
const h = require('react-hyperscript')
const formatBalance = require('../util').formatBalance
const Identicon = require('./identicon')
const addressSummary = require('../util').addressSummary
const Panel = require('./panel')
module.exports = AccountPanel
inherits(AccountPanel, Component)
function AccountPanel () {
Component.call(this)
@ -22,9 +19,6 @@ AccountPanel.prototype.render = function() {
var account = state.account || {}
var isFauceting = state.isFauceting
var identicon = new Identicon(identity.address, 46).toString()
var identiconSrc = `data:image/png;base64,${identicon}`
var panelOpts = {
key: `accountPanel${identity.address}`,
onClick: (event) => {
@ -40,18 +34,16 @@ AccountPanel.prototype.render = function() {
value: addressSummary(identity.address),
},
balanceOrFaucetingIndication(account, isFauceting),
]
],
}
return h(Panel, panelOpts,
!state.onShowDetail ? null : h('.arrow-right.cursor-pointer', [
h('i.fa.fa-chevron-right.fa-lg'),
]))
}
function balanceOrFaucetingIndication (account, isFauceting) {
// Temporarily deactivating isFauceting indication
// because it shows fauceting for empty restored accounts.
if (/* isFauceting*/ false) {
@ -62,7 +54,7 @@ function balanceOrFaucetingIndication(account, isFauceting) {
} else {
return {
key: 'BALANCE',
value: formatBalance(account.balance)
value: formatBalance(account.balance),
}
}
}

View File

@ -4,14 +4,12 @@ const inherits = require('util').inherits
module.exports = DropMenuItem
inherits(DropMenuItem, Component)
function DropMenuItem () {
Component.call(this)
}
DropMenuItem.prototype.render = function () {
return h('li.drop-menu-item', {
onClick: () => {
this.props.closeMenu()

View File

@ -5,7 +5,6 @@ const findDOMNode = require('react-dom').findDOMNode
module.exports = EditableLabel
inherits(EditableLabel, Component)
function EditableLabel () {
Component.call(this)
@ -13,10 +12,9 @@ function EditableLabel() {
EditableLabel.prototype.render = function () {
const props = this.props
let state = this.state
const state = this.state
if (state && state.isEditingLabel) {
return h('div.editable-label', [
h('input.sizing-input', {
defaultValue: props.textValue,
@ -26,9 +24,8 @@ EditableLabel.prototype.render = function() {
}),
h('button.editable-button', {
onClick: () => this.saveText(),
}, 'Save')
}, 'Save'),
])
} else {
return h('div.name-label', {
onClick: (event) => {

View File

@ -1,7 +1,6 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const parseBalance = require('../util').parseBalance
const formatBalance = require('../util').formatBalance
module.exports = EthBalanceComponent

View File

@ -2,12 +2,10 @@ const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
const metamaskLogo = require('metamask-logo')
const getCaretCoordinates = require('textarea-caret')
const debounce = require('debounce')
module.exports = Mascot
inherits(Mascot, Component)
function Mascot () {
Component.call(this)
@ -22,7 +20,6 @@ function Mascot() {
this.unfollowMouse = this.logo.setFollowMouse.bind(this.logo, false)
}
Mascot.prototype.render = function () {
// this is a bit hacky
// the event emitter is on `this.props`

View File

@ -14,26 +14,25 @@ Network.prototype.render = function() {
const state = this.props
const networkNumber = state.network
let iconName, hoverText
const imagePath = "/images/"
if (networkNumber == 'loading') {
if (networkNumber === 'loading') {
return h('img', {
title: 'Attempting to connect to blockchain.',
onClick: (event) => this.props.onClick(event),
style: {
width: '27px',
marginRight: '-27px'
marginRight: '-27px',
},
src: 'images/loading.svg',
})
} else if (parseInt(networkNumber) == 1) {
} else if (parseInt(networkNumber) === 1) {
hoverText = 'Main Ethereum Network'
iconName = 'ethereum-network'
}else if (parseInt(networkNumber) == 2) {
hoverText = "Morden Test Network"
} else if (parseInt(networkNumber) === 2) {
hoverText = 'Morden Test Network'
iconName = 'morden-test-network'
} else {
hoverText = "Unknown Private Network"
hoverText = 'Unknown Private Network'
iconName = 'unknown-private-network'
}
return (
@ -45,7 +44,7 @@ Network.prototype.render = function() {
title: hoverText,
onClick: (event) => this.props.onClick(event),
}, [
function() {
(function () {
switch (iconName) {
case 'ethereum-network':
return h('.menu-icon.ether-icon')
@ -60,7 +59,7 @@ Network.prototype.render = function() {
},
})
}
}()
})(),
])
)
}

View File

@ -1,12 +1,10 @@
const inherits = require('util').inherits
const ethUtil = require('ethereumjs-util')
const Component = require('react').Component
const h = require('react-hyperscript')
const Identicon = require('./identicon')
module.exports = Panel
inherits(Panel, Component)
function Panel () {
Component.call(this)
@ -15,9 +13,6 @@ function Panel() {
Panel.prototype.render = function () {
var state = this.props
var identity = state.identity || {}
var account = state.account || {}
var isFauceting = state.isFauceting
var style = {
flex: '1 0 auto',
}

View File

@ -3,14 +3,10 @@ const h = require('react-hyperscript')
const inherits = require('util').inherits
const AccountPanel = require('./account-panel')
const addressSummary = require('../util').addressSummary
const readableDate = require('../util').readableDate
const formatBalance = require('../util').formatBalance
const dataSize = require('../util').dataSize
module.exports = PendingMsg
inherits(PendingMsg, Component)
function PendingMsg () {
Component.call(this)
@ -34,7 +30,7 @@ PendingMsg.prototype.render = function() {
style: {
fontWeight: 'bold',
textAlign: 'center',
}
},
}, 'Sign Message'),
// account that will sign

View File

@ -6,11 +6,9 @@ const AccountPanel = require('./account-panel')
const addressSummary = require('../util').addressSummary
const readableDate = require('../util').readableDate
const formatBalance = require('../util').formatBalance
const dataSize = require('../util').dataSize
module.exports = PendingTx
inherits(PendingTx, Component)
function PendingTx () {
Component.call(this)
@ -34,7 +32,7 @@ PendingTx.prototype.render = function() {
style: {
fontWeight: 'bold',
textAlign: 'center',
}
},
}, 'Submit Transaction'),
// account that will sign

View File

@ -4,16 +4,15 @@ const inherits = require('util').inherits
module.exports = NewComponent
inherits(NewComponent, Component)
function NewComponent () {
Component.call(this)
}
NewComponent.prototype.render = function () {
var state = this.props
const props = this.props
return (
h('span', 'Placeholder component')
h('span', props.message)
)
}

View File

@ -6,20 +6,19 @@ const Identicon = require('./identicon')
module.exports = TransactionIcon
inherits(TransactionIcon, Component)
function TransactionIcon () {
Component.call(this)
}
TransactionIcon.prototype.render = function () {
const { transaction, txParams, isTx, isMsg } = this.props
const { transaction, txParams, isMsg } = this.props
if (transaction.status === 'rejected') {
return h('i.fa.fa-exclamation-triangle.fa-lg.error', {
style: {
width: '24px',
}
},
})
}
@ -27,7 +26,7 @@ TransactionIcon.prototype.render = function() {
return h('i.fa.fa-certificate.fa-lg', {
style: {
width: '24px',
}
},
})
}
@ -40,7 +39,7 @@ TransactionIcon.prototype.render = function() {
return h('i.fa.fa-file-text-o.fa-lg', {
style: {
width: '24px',
}
},
})
}
}

View File

@ -5,14 +5,12 @@ const inherits = require('util').inherits
const EtherBalance = require('./eth-balance')
const addressSummary = require('../util').addressSummary
const explorerLink = require('../../lib/explorer-link')
const formatBalance = require('../util').formatBalance
const vreme = new (require('vreme'))
const TransactionIcon = require('./transaction-list-item-icon')
module.exports = TransactionListItem
inherits(TransactionListItem, Component)
function TransactionListItem () {
Component.call(this)
@ -59,8 +57,8 @@ TransactionListItem.prototype.render = function() {
// large identicon
h('.identicon-wrapper.flex-column.flex-center.select-none', [
transaction.status === 'unconfirmed' ? h('.red-dot', ' ') :
h(TransactionIcon, { txParams, transaction, isTx, isMsg }),
transaction.status === 'unconfirmed' ? h('.red-dot', ' ')
: h(TransactionIcon, { txParams, transaction, isTx, isMsg }),
]),
h('.flex-column', [
@ -107,12 +105,6 @@ function recipientField(txParams, transaction, isTx, isMsg) {
message,
failIfFailed(transaction),
])
}
TransactionListItem.prototype.renderMessage = function() {
const { transaction, i, network } = this.props
return h('div', 'wowie, thats a message')
}
function formatDate (date) {

View File

@ -13,7 +13,7 @@ function TransactionList() {
}
TransactionList.prototype.render = function () {
const { txsToRender, network, unconfTxs, unconfMsgs } = this.props
const { txsToRender, network, unconfMsgs } = this.props
const transactions = txsToRender.concat(unconfMsgs)
.sort((a, b) => b.time - a.time)
@ -49,8 +49,8 @@ TransactionList.prototype.render = function() {
},
}, (
transactions.length ?
transactions.map((transaction, i) => {
transactions.length
? transactions.map((transaction, i) => {
return h(TransactionListItem, {
transaction, i, network,
showTx: (txId) => {
@ -58,13 +58,12 @@ TransactionList.prototype.render = function() {
},
})
})
:
[h('.flex-center', {
: [h('.flex-center', {
style: {
height: '100%',
},
}, 'No transaction history...')]
))
)),
])
)
}

View File

@ -3,10 +3,7 @@ const Component = require('react').Component
const ReactCSSTransitionGroup = require('react-addons-css-transition-group')
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const copyToClipboard = require('copy-to-clipboard')
const actions = require('./actions')
const AccountPanel = require('./components/account-panel')
const valuesFor = require('./util').valuesFor
const txHelper = require('../lib/tx-helper')
const ConfirmTx = require('./components/pending-tx')
@ -31,7 +28,6 @@ function ConfirmTxScreen() {
Component.call(this)
}
ConfirmTxScreen.prototype.render = function () {
var state = this.props
@ -103,7 +99,6 @@ ConfirmTxScreen.prototype.render = function() {
}
function currentTxView (opts) {
if ('txParams' in opts.txData) {
// This is a pending transaction
return h(ConfirmTx, opts)

View File

@ -8,7 +8,6 @@ module.exports = connect(mapStateToProps)(ConfigScreen)
function mapStateToProps (state) {
return {
rpc: state.metamask.rpcTarget,
metamask: state.metamask,
}
}
@ -18,10 +17,8 @@ function ConfigScreen() {
Component.call(this)
}
ConfigScreen.prototype.render = function () {
var state = this.props
var rpc = state.rpc
var metamaskState = state.metamask
return (
@ -32,7 +29,7 @@ ConfigScreen.prototype.render = function() {
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
onClick: (event) => {
state.dispatch(actions.goHome())
}
},
}),
h('h2.page-subtitle', 'Configuration'),
]),
@ -42,7 +39,7 @@ ConfigScreen.prototype.render = function() {
h('.flex-space-around', {
style: {
padding: '20px',
}
},
}, [
currentProviderDisplay(metamaskState),
@ -62,7 +59,7 @@ ConfigScreen.prototype.render = function() {
var newRpc = element.value
state.dispatch(actions.setRpcTarget(newRpc))
}
}
},
}),
h('button', {
style: {
@ -73,8 +70,8 @@ ConfigScreen.prototype.render = function() {
var element = document.querySelector('input#new_rpc')
var newRpc = element.value
state.dispatch(actions.setRpcTarget(newRpc))
}
}, 'Save')
},
}, 'Save'),
]),
h('div', [
@ -85,7 +82,7 @@ ConfigScreen.prototype.render = function() {
onClick (event) {
event.preventDefault()
state.dispatch(actions.setProviderType('mainnet'))
}
},
}, 'Use Main Network'),
]),
@ -97,7 +94,7 @@ ConfigScreen.prototype.render = function() {
onClick (event) {
event.preventDefault()
state.dispatch(actions.setProviderType('testnet'))
}
},
}, 'Use Morden Test Network'),
]),
@ -109,7 +106,7 @@ ConfigScreen.prototype.render = function() {
onClick (event) {
event.preventDefault()
state.dispatch(actions.setRpcTarget('http://localhost:8545/'))
}
},
}, 'Use http://localhost:8545'),
]),
@ -118,7 +115,7 @@ ConfigScreen.prototype.render = function() {
h('div', {
style: {
marginTop: '20px',
}
},
}, [
h('button', {
style: {
@ -127,8 +124,8 @@ ConfigScreen.prototype.render = function() {
onClick (event) {
event.preventDefault()
state.dispatch(actions.revealSeedConfirmation())
}
}, 'Reveal Seed Words')
},
}, 'Reveal Seed Words'),
]),
]),
@ -160,6 +157,6 @@ function currentProviderDisplay(metamaskState) {
return h('div', [
h('span', {style: { fontWeight: 'bold', paddingRight: '10px'}}, title),
h('span', value)
h('span', value),
])
}

View File

@ -6,7 +6,6 @@ const actions = require('../actions')
module.exports = connect(mapStateToProps)(CreateVaultCompleteScreen)
inherits(CreateVaultCompleteScreen, Component)
function CreateVaultCompleteScreen () {
Component.call(this)
@ -50,7 +49,7 @@ CreateVaultCompleteScreen.prototype.render = function() {
style: {
padding: '12px 20px 0px 20px',
textAlign: 'center',
}
},
}, 'These 12 words can restore all of your MetaMask accounts for this vault.\nSave them somewhere safe and secret.'),
h('textarea.twelve-word-phrase', {

View File

@ -7,7 +7,6 @@ const actions = require('../actions')
module.exports = connect(mapStateToProps)(CreateVaultScreen)
inherits(CreateVaultScreen, Component)
function CreateVaultScreen () {
Component.call(this)

View File

@ -18,7 +18,6 @@ function DisclaimerScreen() {
}
DisclaimerScreen.prototype.render = function () {
return (
h('.flex-column.flex-center.flex-grow', [
@ -43,13 +42,13 @@ DisclaimerScreen.prototype.render = function() {
padding: '6px',
width: '80%',
overflowY: 'scroll',
}
},
}, disclaimer),
h('button', {
style: { marginTop: '18px' },
onClick: () => this.props.dispatch(actions.agreeToDisclaimer())
}, 'I Agree')
onClick: () => this.props.dispatch(actions.agreeToDisclaimer()),
}, 'I Agree'),
])
)
}

View File

@ -3,11 +3,8 @@ const EventEmitter = require('events').EventEmitter
const Component = require('react').Component
const connect = require('react-redux').connect
const h = require('react-hyperscript')
const getCaretCoordinates = require('textarea-caret')
const Mascot = require('../components/mascot')
const actions = require('../actions')
const CreateVaultScreen = require('./create-vault')
const CreateVaultCompleteScreen = require('./create-vault-complete')
module.exports = connect(mapStateToProps)(InitializeMenuScreen)
@ -33,7 +30,6 @@ InitializeMenuScreen.prototype.render = function() {
return this.renderMenu()
}
}
// InitializeMenuScreen.prototype.componentDidMount = function(){
@ -41,7 +37,6 @@ InitializeMenuScreen.prototype.render = function() {
// }
InitializeMenuScreen.prototype.renderMenu = function () {
var state = this.props
return (
h('.initialize-screen.flex-column.flex-center.flex-grow', [

View File

@ -6,7 +6,6 @@ const actions = require('../actions')
module.exports = connect(mapStateToProps)(RestoreVaultScreen)
inherits(RestoreVaultScreen, Component)
function RestoreVaultScreen () {
Component.call(this)
@ -18,7 +17,6 @@ function mapStateToProps(state) {
}
}
RestoreVaultScreen.prototype.render = function () {
var state = this.props
return (
@ -41,7 +39,7 @@ RestoreVaultScreen.prototype.render = function() {
// wallet seed entry
h('h3', 'Wallet Seed'),
h('textarea.twelve-word-phrase.letter-spacey', {
placeholder: 'Enter your secret twelve word phrase here to restore your vault.'
placeholder: 'Enter your secret twelve word phrase here to restore your vault.',
}),
// password

View File

@ -17,8 +17,7 @@ function InfoScreen() {
InfoScreen.prototype.render = function () {
var state = this.props
var rpc = state.rpc
var manifest = chrome.runtime.getManifest();
var manifest = chrome.runtime.getManifest()
return (
h('.flex-column.flex-grow', [
@ -27,7 +26,7 @@ InfoScreen.prototype.render = function() {
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
onClick: (event) => {
state.dispatch(actions.goHome())
}
},
}),
h('h2.page-subtitle', 'Info'),
]),
@ -37,7 +36,7 @@ InfoScreen.prototype.render = function() {
h('.flex-space-around', {
style: {
padding: '20px',
}
},
}, [
// current version number
@ -46,7 +45,7 @@ InfoScreen.prototype.render = function() {
h('div', {
style: {
marginBottom: '10px',
}
},
}, `Version: ${manifest.version}`),
]),
@ -54,10 +53,9 @@ InfoScreen.prototype.render = function() {
style: {
margin: '20px 0 ',
width: '7em',
}
},
}),
h('.info', {
style: {
marginBottom: '20px',
@ -79,14 +77,14 @@ InfoScreen.prototype.render = function() {
onClick (event) { this.navigateTo(event.target.href) },
}, [
h('img.icon-size', {
src: manifest.icons[128]
src: manifest.icons[128],
}),
h('div.info', {
style: {
fontWeight: 800,
}
},'Visit our web site')
])
},
}, 'Visit our web site'),
]),
]),
h('div.fa.fa-slack', [
h('a.info', {
@ -96,7 +94,6 @@ InfoScreen.prototype.render = function() {
}, 'Join the conversation on Slack'),
]),
h('div.fa.fa-twitter', [
h('a.info', {
href: 'https://twitter.com/metamask_io',
@ -124,9 +121,8 @@ InfoScreen.prototype.render = function() {
]),
])
)
}
InfoScreen.prototype.navigateTo = function (url) {
chrome.tabs.create({ url });
chrome.tabs.create({ url })
}

View File

@ -2,7 +2,6 @@ const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const actions = require('./actions')
const ReactCSSTransitionGroup = require('react-addons-css-transition-group')
module.exports = connect(mapStateToProps)(LoadingIndicator)
@ -38,7 +37,7 @@ LoadingIndicator.prototype.render = function() {
height: '100%',
width: '100%',
background: 'rgba(255, 255, 255, 0.5)',
}
},
}, [
h('img', {
src: 'images/loading.svg',

View File

@ -7,7 +7,6 @@ const actions = require('../actions')
module.exports = connect(mapStateToProps)(RevealSeedConfirmatoin)
inherits(RevealSeedConfirmatoin, Component)
function RevealSeedConfirmatoin () {
Component.call(this)
@ -48,7 +47,7 @@ RevealSeedConfirmatoin.prototype.render = function() {
flexDirection: 'column',
padding: '20px',
justifyContent: 'center',
}
},
}, [
h('h4', 'Do not recover your seed words in a public place! These words can be used to steal all your accounts.'),
@ -68,8 +67,8 @@ RevealSeedConfirmatoin.prototype.render = function() {
h(`h4${state && state.confirmationWrong ? '.error' : ''}`, {
style: {
marginTop: '12px',
}
}, `Enter the phrase "I understand" to proceed.`),
},
}, 'Enter the phrase "I understand" to proceed.'),
// confirm confirmation
h('input.large-input.letter-spacey', {
@ -105,7 +104,7 @@ RevealSeedConfirmatoin.prototype.render = function() {
h('span.error', {
style: {
margin: '20px',
}
},
}, props.warning.split('-'))
),

View File

@ -1,5 +1,3 @@
const combineReducers = require('redux').combineReducers
const actions = require('./actions')
const extend = require('xtend')
//
@ -12,7 +10,6 @@ const reduceApp = require('./reducers/app')
module.exports = rootReducer
function rootReducer (state, action) {
// clone
state = extend(state)
@ -34,8 +31,6 @@ function rootReducer(state, action) {
state.appState = reduceApp(state, action)
return state
}

View File

@ -1,12 +1,10 @@
const extend = require('xtend')
const actions = require('../actions')
const valuesFor = require('../util').valuesFor
const txHelper = require('../../lib/tx-helper')
module.exports = reduceApp
function reduceApp (state, action) {
// clone and defaults
const selectedAccount = state.metamask.selectedAccount
const pendingTxs = hasPendingTxs(state)
@ -156,7 +154,6 @@ function reduceApp(state, action) {
warning: null,
})
// accounts
case actions.SET_SELECTED_ACCOUNT:
@ -182,7 +179,7 @@ function reduceApp(state, action) {
return extend(appState, {
currentView: {
name: 'accountDetail',
context: action.value || account,
context: action.value,
},
accountDetail: {
subview: 'transactions',
@ -207,7 +204,6 @@ function reduceApp(state, action) {
})
case actions.SHOW_ACCOUNTS_PAGE:
var seedWords = state.metamask.seedWords
return extend(appState, {
currentView: {
name: seedWords ? 'createVaultComplete' : 'accounts',
@ -281,7 +277,7 @@ function reduceApp(state, action) {
name: 'confTx',
context: ++appState.currentView.context,
warning: null,
}
},
})
case actions.VIEW_PENDING_TX:
@ -292,7 +288,7 @@ function reduceApp(state, action) {
name: 'confTx',
context,
warning: null,
}
},
})
case actions.PREVIOUS_TX:
@ -302,7 +298,7 @@ function reduceApp(state, action) {
name: 'confTx',
context: --appState.currentView.context,
warning: null,
}
},
})
case actions.TRANSACTION_ERROR:
@ -315,7 +311,7 @@ function reduceApp(state, action) {
case actions.UNLOCK_FAILED:
return extend(appState, {
warning: 'Incorrect password. Try again.'
warning: 'Incorrect password. Try again.',
})
case actions.SHOW_LOADING:

View File

@ -1,10 +1,8 @@
const extend = require('xtend')
const actions = require('../actions')
module.exports = reduceIdentities
function reduceIdentities (state, action) {
// clone + defaults
var idState = extend({
@ -14,5 +12,4 @@ function reduceIdentities(state, action) {
default:
return idState
}
}

View File

@ -4,6 +4,7 @@ const actions = require('../actions')
module.exports = reduceMetamask
function reduceMetamask (state, action) {
let newState
// clone + defaults
var metamaskState = extend({
@ -18,9 +19,9 @@ function reduceMetamask(state, action) {
switch (action.type) {
case actions.SHOW_ACCOUNTS_PAGE:
var state = extend(metamaskState)
delete state.seedWords
return state
newState = extend(metamaskState)
delete newState.seedWords
return newState
case actions.UPDATE_METAMASK_STATE:
return extend(metamaskState, action.value)
@ -59,16 +60,16 @@ function reduceMetamask(state, action) {
case actions.COMPLETED_TX:
var stringId = String(action.id)
var newState = extend(metamaskState, {
newState = extend(metamaskState, {
unconfTxs: {},
unconfMsgs: {},
})
for (var id in metamaskState.unconfTxs) {
for (const id in metamaskState.unconfTxs) {
if (id !== stringId) {
newState.unconfTxs[id] = metamaskState.unconfTxs[id]
}
}
for (var id in metamaskState.unconfMsgs) {
for (const id in metamaskState.unconfMsgs) {
if (id !== stringId) {
newState.unconfMsgs[id] = metamaskState.unconfMsgs[id]
}
@ -82,7 +83,7 @@ function reduceMetamask(state, action) {
})
case actions.CLEAR_SEED_WORD_CACHE:
var newState = extend(metamaskState, {
newState = extend(metamaskState, {
isUnlocked: true,
isInitialized: true,
selectedAccount: action.value,
@ -91,7 +92,7 @@ function reduceMetamask(state, action) {
return newState
case actions.SHOW_ACCOUNT_DETAIL:
const newState = extend(metamaskState, {
newState = extend(metamaskState, {
isUnlocked: true,
isInitialized: true,
selectedAccount: action.value,

View File

@ -1,5 +1,4 @@
const inherits = require('util').inherits
const React = require('react')
const Component = require('react').Component
const Provider = require('react-redux').Provider
const h = require('react-hyperscript')
@ -7,7 +6,6 @@ const App = require('./app')
module.exports = Root
inherits(Root, Component)
function Root () { Component.call(this) }
@ -17,7 +15,7 @@ Root.prototype.render = function() {
h(Provider, {
store: this.props.store,
}, [
h(App)
h(App),
])
)

View File

@ -6,7 +6,6 @@ const Identicon = require('./components/identicon')
const actions = require('./actions')
const util = require('./util')
const numericBalance = require('./util').numericBalance
const formatBalance = require('./util').formatBalance
const addressSummary = require('./util').addressSummary
const EtherBalance = require('./components/eth-balance')
const ethUtil = require('ethereumjs-util')
@ -111,7 +110,7 @@ SendTransactionScreen.prototype.render = function() {
// h('div', formatBalance(account && account.balance)),
h(EtherBalance, {
value: account && account.balance,
})
}),
]),
@ -140,7 +139,7 @@ SendTransactionScreen.prototype.render = function() {
h('input.large-input', {
name: 'address',
placeholder: 'Recipient Address',
})
}),
]),
// 'amount' and send button
@ -160,7 +159,7 @@ SendTransactionScreen.prototype.render = function() {
style: {
textTransform: 'uppercase',
},
}, 'Send')
}, 'Send'),
]),
@ -187,7 +186,7 @@ SendTransactionScreen.prototype.render = function() {
style: {
width: '100%',
resize: 'none',
}
},
}),
]),
@ -207,20 +206,20 @@ SendTransactionScreen.prototype.back = function() {
}
SendTransactionScreen.prototype.onSubmit = function () {
const recipient = document.querySelector('input[name="address"]').value
const input = document.querySelector('input[name="amount"]').value
const value = util.normalizeEthStringToWei(input)
const txData = document.querySelector('input[name="txData"]').value
const balance = this.props.balance
let message
if (value.gt(balance)) {
var message = 'Insufficient funds.'
message = 'Insufficient funds.'
return this.props.dispatch(actions.displayWarning(message))
}
if ((!util.isValidAddress(recipient) && !txData) || (!recipient && !txData)) {
var message = 'Recipient address is invalid.'
message = 'Recipient address is invalid.'
return this.props.dispatch(actions.displayWarning(message))
}

View File

@ -2,17 +2,12 @@ const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const copyToClipboard = require('copy-to-clipboard')
const actions = require('./actions')
const AccountPanel = require('./components/account-panel')
module.exports = connect(mapStateToProps)(AppSettingsPage)
function mapStateToProps (state) {
return {
identities: state.metamask.identities,
address: state.appState.currentView.context,
}
return {}
}
inherits(AppSettingsPage, Component)
@ -20,10 +15,7 @@ function AppSettingsPage() {
Component.call(this)
}
AppSettingsPage.prototype.render = function () {
var state = this.props
var identity = state.identities[state.address]
return (
h('.account-detail-section.flex-column.flex-grow', [
@ -62,7 +54,6 @@ AppSettingsPage.prototype.onKeyPress = function(event) {
}
}
AppSettingsPage.prototype.navigateToAccounts = function (event) {
event.stopPropagation()
this.props.dispatch(actions.showAccountsPage())

View File

@ -6,7 +6,6 @@ const rootReducer = require('./reducers')
module.exports = configureStore
const loggerMiddleware = createLogger()
const createStoreWithMiddleware = applyMiddleware(

View File

@ -2,7 +2,6 @@ const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const actions = require('./actions')
module.exports = connect(mapStateToProps)(COMPONENTNAME)
@ -22,9 +21,9 @@ COMPONENTNAME.prototype.render = function() {
h('div', {
style: {
background: 'blue',
}
},
}, [
'Hello, world!'
`Hello, ${props.sender}`,
])
)
}

View File

@ -9,7 +9,6 @@ const EventEmitter = require('events').EventEmitter
module.exports = connect(mapStateToProps)(UnlockScreen)
inherits(UnlockScreen, Component)
function UnlockScreen () {
Component.call(this)
@ -55,7 +54,7 @@ UnlockScreen.prototype.render = function() {
h('.error', {
style: {
display: warning ? 'block' : 'none',
}
},
}, warning),
h('button.primary.cursor-pointer', {

View File

@ -37,7 +37,6 @@ module.exports = {
bnTable: bnTable,
}
function valuesFor (obj) {
if (!obj) return []
return Object.keys(obj)
@ -85,13 +84,13 @@ function weiToEth(bn) {
// Takes hex, returns [beforeDecimal, afterDecimal]
function parseBalance (balance) {
let beforeDecimal, afterDecimal
let wei = numericBalance(balance).toString()
let trailingZeros = /0+$/
var beforeDecimal, afterDecimal
const wei = numericBalance(balance).toString()
const trailingZeros = /0+$/
beforeDecimal = wei.length > 18 ? wei.slice(0, wei.length - 18) : '0'
afterDecimal = ("000000000000000000" + wei).slice(-18).replace(trailingZeros, "")
if(afterDecimal == ""){afterDecimal = "0" }
afterDecimal = ('000000000000000000' + wei).slice(-18).replace(trailingZeros, '')
if (afterDecimal === '') { afterDecimal = '0' }
return [beforeDecimal, afterDecimal]
}
@ -100,7 +99,7 @@ function formatBalance(balance, decimalsToKeep) {
var parsed = parseBalance(balance)
var beforeDecimal = parsed[0]
var afterDecimal = parsed[1]
var formatted = "None"
var formatted = 'None'
if (decimalsToKeep === undefined) {
if (beforeDecimal === '0') {
if (afterDecimal !== '0') {
@ -109,11 +108,11 @@ function formatBalance(balance, decimalsToKeep) {
formatted = '0.' + afterDecimal + ' ETH'
}
} else {
formatted = beforeDecimal + "." + afterDecimal.slice(0,3) + ' ETH'
formatted = beforeDecimal + '.' + afterDecimal.slice(0, 3) + ' ETH'
}
} else {
afterDecimal += Array(decimalsToKeep).join("0")
formatted = beforeDecimal + "." + afterDecimal.slice(0,decimalsToKeep) + ' ETH'
afterDecimal += Array(decimalsToKeep).join('0')
formatted = beforeDecimal + '.' + afterDecimal.slice(0, decimalsToKeep) + ' ETH'
}
return formatted
}
@ -159,10 +158,10 @@ function readableDate(ms) {
var day = date.getDate()
var year = date.getFullYear()
var hours = date.getHours()
var minutes = "0" + date.getMinutes()
var seconds = "0" + date.getSeconds()
var minutes = '0' + date.getMinutes()
var seconds = '0' + date.getSeconds()
var date = `${month}/${day}/${year}`
var dateStr = `${month}/${day}/${year}`
var time = `${hours}:${minutes.substr(-2)}:${seconds.substr(-2)}`
return `${date} ${time}`
return `${dateStr} ${time}`
}

View File

@ -1,13 +1,14 @@
const fs = require('fs')
const path = require('path')
module.exports = bundleCss
var cssFiles = {
'fonts.css': fs.readFileSync(__dirname+'/app/css/fonts.css', 'utf8'),
'reset.css': fs.readFileSync(__dirname+'/app/css/reset.css', 'utf8'),
'lib.css': fs.readFileSync(__dirname+'/app/css/lib.css', 'utf8'),
'index.css': fs.readFileSync(__dirname+'/app/css/index.css', 'utf8'),
'transitions.css': fs.readFileSync(__dirname+'/app/css/transitions.css', 'utf8'),
'fonts.css': fs.readFileSync(path.join(__dirname, '/app/css/fonts.css'), 'utf8'),
'reset.css': fs.readFileSync(path.join(__dirname, '/app/css/reset.css'), 'utf8'),
'lib.css': fs.readFileSync(path.join(__dirname, '/app/css/lib.css'), 'utf8'),
'index.css': fs.readFileSync(path.join(__dirname, '/app/css/index.css'), 'utf8'),
'transitions.css': fs.readFileSync(path.join(__dirname, '/app/css/transitions.css'), 'utf8'),
}
function bundleCss () {

View File

@ -26,7 +26,7 @@ var identities = {
address: '0x333462427bcc9133bb46e88bcbe39cd7ef0e7333',
balance: 0.000001,
txCount: 1,
}
},
}
var unconfTxs = {}
@ -106,9 +106,9 @@ var container = document.getElementById('app-content')
var css = MetaMaskUiCss()
injectCss(css)
var app = MetaMaskUi({
MetaMaskUi({
container: container,
accountManager: accountManager
accountManager: accountManager,
})
// util

View File

@ -1,7 +1,5 @@
const React = require('react')
const render = require('react-dom').render
const h = require('react-hyperscript')
const extend = require('xtend')
const Root = require('./app/root')
const actions = require('./app/actions')
const configureStore = require('./app/store')
@ -9,7 +7,6 @@ const configureStore = require('./app/store')
module.exports = launchApp
function launchApp (opts) {
var accountManager = opts.accountManager
actions._setAccountManager(accountManager)
@ -18,11 +15,9 @@ function launchApp(opts) {
if (err) throw err
startApp(metamaskState, accountManager, opts)
})
}
function startApp (metamaskState, accountManager, opts) {
// parse opts
var store = configureStore({
@ -43,11 +38,6 @@ function startApp(metamaskState, accountManager, opts){
store.dispatch(actions.showConfTxPage())
}
// if unconfirmed messages, start on msgConf page
if (Object.keys(metamaskState.unconfMsgs || {}).length) {
store.dispatch(actions.showConfTxPage())
}
accountManager.on('update', function (metamaskState) {
store.dispatch(actions.updateMetamaskState(metamaskState))
})
@ -59,5 +49,4 @@ function startApp(metamaskState, accountManager, opts){
store: store,
}
), opts.container)
}

View File

@ -34,10 +34,11 @@ IconFactory.prototype.cacheIcon = function(address, diameter, icon) {
if (!(address in this.cache)) {
var sizeCache = {}
sizeCache[diameter] = icon
return this.cache[address] = sizeCache
this.cache[address] = sizeCache
return sizeCache
} else {
return this.cache[address][diameter] = icon
this.cache[address][diameter] = icon
return icon
}
}