Skip to content

Commit 25e5793

Browse files
authored
Merge pull request #1027 from MetaMask/Version-3.1.0
Version 3.1.0
2 parents 9ab7ce3 + 0e01abd commit 25e5793

33 files changed

+875
-79
lines changed

.eslintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"parserOptions": {
3+
"sourceType": "module",
34
"ecmaVersion": 6,
45
"ecmaFeatures": {
56
"experimentalObjectRestSpread": true,
@@ -44,7 +45,7 @@
4445
"eol-last": 1,
4546
"eqeqeq": [2, "allow-null"],
4647
"generator-star-spacing": [2, { "before": true, "after": true }],
47-
"handle-callback-err": [2, "^(err|error)$" ],
48+
"handle-callback-err": [1, "^(err|error)$" ],
4849
"indent": [2, 2, { "SwitchCase": 1 }],
4950
"jsx-quotes": [2, "prefer-single"],
5051
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
@@ -145,6 +146,6 @@
145146
"wrap-iife": [2, "any"],
146147
"yield-star-spacing": [2, "both"],
147148
"yoda": [2, "never"],
148-
"prefer-const": 1
149+
"prefer-const": 1,
149150
}
150151
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## Current Master
44

5+
## 3.1.0 2017-1-18
6+
7+
- Add ability to import accounts by private key.
8+
- Fixed bug that returned the wrong transaction hashes on private networks that had not implemented EIP 155 replay protection (like TestRPC).
9+
10+
## 3.0.1 2017-1-17
11+
12+
- Fixed bug that prevented eth.sign from working.
513
- Fix the displaying of transactions that have been submitted to the network in Transaction History
614

715
## 3.0.0 2017-1-16

app/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "MetaMask",
33
"short_name": "Metamask",
4-
"version": "3.0.0",
4+
"version": "3.1.0",
55
"manifest_version": 2,
66
"author": "https://metamask.io",
77
"description": "Ethereum Browser Extension",

app/scripts/keyring-controller.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ module.exports = class KeyringController extends EventEmitter {
234234
addNewKeyring (type, opts) {
235235
const Keyring = this.getKeyringClassForType(type)
236236
const keyring = new Keyring(opts)
237-
return keyring.getAccounts()
237+
return keyring.deserialize(opts)
238+
.then(() => {
239+
return keyring.getAccounts()
240+
})
238241
.then((accounts) => {
239242
this.keyrings.push(keyring)
240243
return this.setupAccounts(accounts)
@@ -397,6 +400,7 @@ module.exports = class KeyringController extends EventEmitter {
397400
}).then((rawSig) => {
398401
cb(null, rawSig)
399402
approvalCb(null, true)
403+
messageManager.confirmMsg(msgId)
400404
return rawSig
401405
})
402406
} catch (e) {

app/scripts/keyrings/hd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class HdKeyring extends EventEmitter {
7676
// For eth_sign, we need to sign transactions:
7777
signMessage (withAccount, data) {
7878
const wallet = this._getWalletForAccount(withAccount)
79-
const message = ethUtil.removeHexPrefix(data)
79+
const message = ethUtil.stripHexPrefix(data)
8080
var privKey = wallet.getPrivateKey()
8181
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
8282
var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s))

app/scripts/keyrings/simple.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ class SimpleKeyring extends EventEmitter {
2020
}
2121

2222
deserialize (privateKeys = []) {
23-
this.wallets = privateKeys.map((privateKey) => {
24-
const stripped = ethUtil.stripHexPrefix(privateKey)
25-
const buffer = new Buffer(stripped, 'hex')
26-
const wallet = Wallet.fromPrivateKey(buffer)
27-
return wallet
23+
return new Promise((resolve, reject) => {
24+
try {
25+
this.wallets = privateKeys.map((privateKey) => {
26+
const stripped = ethUtil.stripHexPrefix(privateKey)
27+
const buffer = new Buffer(stripped, 'hex')
28+
const wallet = Wallet.fromPrivateKey(buffer)
29+
return wallet
30+
})
31+
} catch (e) {
32+
reject(e)
33+
}
34+
resolve()
2835
})
29-
return Promise.resolve()
3036
}
3137

3238
addAccounts (n = 1) {
@@ -54,8 +60,7 @@ class SimpleKeyring extends EventEmitter {
5460
// For eth_sign, we need to sign transactions:
5561
signMessage (withAccount, data) {
5662
const wallet = this._getWalletForAccount(withAccount)
57-
58-
const message = ethUtil.removeHexPrefix(data)
63+
const message = ethUtil.stripHexPrefix(data)
5964
var privKey = wallet.getPrivateKey()
6065
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
6166
var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s))

app/scripts/lib/config-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ ConfigManager.prototype.updateConversionRate = function () {
306306
this.setConversionPrice(parsedResponse.ticker.price)
307307
this.setConversionDate(parsedResponse.timestamp)
308308
}).catch((err) => {
309-
console.error('Error in conversion.', err)
309+
console.warn('MetaMask - Failed to query currency conversion.')
310310
this.setConversionPrice(0)
311311
this.setConversionDate('N/A')
312312
})

app/scripts/metamask-controller.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ module.exports = class MetamaskController extends EventEmitter {
115115
.then((newState) => { cb(null, newState) })
116116
.catch((reason) => { cb(reason) })
117117
},
118-
addNewKeyring: nodeify(keyringController.addNewKeyring).bind(keyringController),
118+
addNewKeyring: (type, opts, cb) => {
119+
keyringController.addNewKeyring(type, opts)
120+
.then(() => keyringController.fullUpdate())
121+
.then((newState) => { cb(null, newState) })
122+
.catch((reason) => { cb(reason) })
123+
},
119124
addNewAccount: nodeify(keyringController.addNewAccount).bind(keyringController),
120125
setSelectedAccount: nodeify(keyringController.setSelectedAccount).bind(keyringController),
121126
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController),

app/scripts/transaction-manager.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,29 +190,28 @@ module.exports = class TransactionManager extends EventEmitter {
190190
let fromAddress = txParams.from
191191
let ethTx = this.txProviderUtils.buildEthTxFromParams(txParams, txMeta.gasMultiplier)
192192
this.signEthTx(ethTx, fromAddress).then(() => {
193-
this.updateTxAsSigned(txMeta.id, ethTx)
193+
this.setTxStatusSigned(txMeta.id)
194194
cb(null, ethUtil.bufferToHex(ethTx.serialize()))
195195
}).catch((err) => {
196196
cb(err)
197197
})
198198
}
199199

200200
publishTransaction (txId, rawTx, cb) {
201-
this.txProviderUtils.publishTransaction(rawTx, (err) => {
201+
this.txProviderUtils.publishTransaction(rawTx, (err, txHash) => {
202202
if (err) return cb(err)
203+
this.setTxHash(txId, txHash)
203204
this.setTxStatusSubmitted(txId)
204205
cb()
205206
})
206207
}
207208

208-
// receives a signed tx object and updates the tx hash
209-
updateTxAsSigned (txId, ethTx) {
209+
// receives a txHash records the tx as signed
210+
setTxHash (txId, txHash) {
210211
// Add the tx hash to the persisted meta-tx object
211-
let txHash = ethUtil.bufferToHex(ethTx.hash())
212212
let txMeta = this.getTx(txId)
213213
txMeta.hash = txHash
214214
this.updateTx(txMeta)
215-
this.setTxStatusSigned(txMeta.id)
216215
}
217216

218217
/*
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"metamask": {
3+
"isInitialized": true,
4+
"isUnlocked": true,
5+
"rpcTarget": "https://rawtestrpc.metamask.io/",
6+
"identities": {
7+
"0x58bda1f9d87dc7d2bcc6f7c2513efc9d03fca683": {
8+
"address": "0x58bda1f9d87dc7d2bcc6f7c2513efc9d03fca683",
9+
"name": "Account 1"
10+
},
11+
"0x9858e7d8b79fc3e6d989636721584498926da38a": {
12+
"address": "0x9858e7d8b79fc3e6d989636721584498926da38a",
13+
"name": "Imported Account"
14+
}
15+
},
16+
"unconfTxs": {},
17+
"currentFiat": "USD",
18+
"conversionRate": 10.19458075,
19+
"conversionDate": 1484696373,
20+
"noActiveNotices": true,
21+
"network": "3",
22+
"accounts": {
23+
"0x58bda1f9d87dc7d2bcc6f7c2513efc9d03fca683": {
24+
"code": "0x",
25+
"balance": "0x0",
26+
"nonce": "0x0",
27+
"address": "0x58bda1f9d87dc7d2bcc6f7c2513efc9d03fca683"
28+
},
29+
"0x9858e7d8b79fc3e6d989636721584498926da38a": {
30+
"code": "0x",
31+
"balance": "0x0",
32+
"nonce": "0x0",
33+
"address": "0x9858e7d8b79fc3e6d989636721584498926da38a"
34+
}
35+
},
36+
"transactions": [],
37+
"provider": {
38+
"type": "testnet"
39+
},
40+
"selectedAccount": "0x9858e7d8b79fc3e6d989636721584498926da38a",
41+
"selectedAccountTxList": [],
42+
"isDisclaimerConfirmed": true,
43+
"unconfMsgs": {},
44+
"messages": [],
45+
"shapeShiftTxList": [],
46+
"keyringTypes": [
47+
"Simple Key Pair",
48+
"HD Key Tree"
49+
],
50+
"keyrings": [
51+
{
52+
"type": "HD Key Tree",
53+
"accounts": [
54+
"58bda1f9d87dc7d2bcc6f7c2513efc9d03fca683"
55+
]
56+
},
57+
{
58+
"type": "Simple Key Pair",
59+
"accounts": [
60+
"0x9858e7d8b79fc3e6d989636721584498926da38a"
61+
]
62+
}
63+
],
64+
"lostAccounts": [],
65+
"seedWords": null
66+
},
67+
"appState": {
68+
"menuOpen": false,
69+
"currentView": {
70+
"name": "accounts"
71+
},
72+
"accountDetail": {
73+
"subview": "transactions",
74+
"accountExport": "none",
75+
"privateKey": ""
76+
},
77+
"transForward": true,
78+
"isLoading": false,
79+
"warning": null,
80+
"scrollToBottom": false,
81+
"forgottenPassword": false
82+
},
83+
"identities": {}
84+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"metamask": {
3+
"isInitialized": true,
4+
"isUnlocked": true,
5+
"rpcTarget": "https://rawtestrpc.metamask.io/",
6+
"identities": {
7+
"0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9": {
8+
"address": "0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9",
9+
"name": "Account 1"
10+
},
11+
"0xd7c0cd9e7d2701c710d64fc492c7086679bdf7b4": {
12+
"address": "0xd7c0cd9e7d2701c710d64fc492c7086679bdf7b4",
13+
"name": "Account 2"
14+
},
15+
"0x1acfb961c5a8268eac8e09d6241a26cbeff42241": {
16+
"address": "0x1acfb961c5a8268eac8e09d6241a26cbeff42241",
17+
"name": "Account 3"
18+
},
19+
"0xabc2bca51709b8615147352c62420f547a63a00c": {
20+
"address": "0xabc2bca51709b8615147352c62420f547a63a00c",
21+
"name": "Account 4"
22+
}
23+
},
24+
"unconfTxs": {
25+
"7992944905869041": {
26+
"id": 7992944905869041,
27+
"txParams": {
28+
"from": "0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9",
29+
"value": "0x0",
30+
"data": "0x606060405234610000575b60da806100186000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630dbe671f14603c575b6000565b3460005760466088565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a72305820a99dfa6091771f518dd1ae8d1ee347bae3304dffd98fd24b1b99a8380bc60a750029",
31+
"gas": "0x1af75",
32+
"metamaskId": 7992944905869041,
33+
"metamaskNetworkId": "3"
34+
},
35+
"time": 1482279685589,
36+
"status": "unconfirmed",
37+
"gasMultiplier": 1,
38+
"metamaskNetworkId": "3",
39+
"gasLimitSpecified": true,
40+
"estimatedGas": "0x1af75",
41+
"simulationFails": true
42+
}
43+
},
44+
"currentFiat": "USD",
45+
"conversionRate": 7.69158136,
46+
"conversionDate": 1482279663,
47+
"noActiveNotices": true,
48+
"network": "3",
49+
"accounts": {
50+
"0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9": {
51+
"code": "0x",
52+
"nonce": "0x3",
53+
"balance": "0x11f646fe14c9c000",
54+
"address": "0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9"
55+
},
56+
"0xd7c0cd9e7d2701c710d64fc492c7086679bdf7b4": {
57+
"code": "0x",
58+
"nonce": "0x0",
59+
"balance": "0x0",
60+
"address": "0xd7c0cd9e7d2701c710d64fc492c7086679bdf7b4"
61+
},
62+
"0x1acfb961c5a8268eac8e09d6241a26cbeff42241": {
63+
"code": "0x",
64+
"balance": "0x0",
65+
"nonce": "0x0",
66+
"address": "0x1acfb961c5a8268eac8e09d6241a26cbeff42241"
67+
},
68+
"0xabc2bca51709b8615147352c62420f547a63a00c": {
69+
"code": "0x",
70+
"balance": "0x0",
71+
"nonce": "0x0",
72+
"address": "0xabc2bca51709b8615147352c62420f547a63a00c"
73+
}
74+
},
75+
"transactions": [
76+
{
77+
"id": 7992944905869041,
78+
"txParams": {
79+
"from": "0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9",
80+
"value": "0x0",
81+
"data": "0x606060405234610000575b60da806100186000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630dbe671f14603c575b6000565b3460005760466088565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a72305820a99dfa6091771f518dd1ae8d1ee347bae3304dffd98fd24b1b99a8380bc60a750029",
82+
"gas": "0x1af75",
83+
"metamaskId": 7992944905869041,
84+
"metamaskNetworkId": "3"
85+
},
86+
"time": 1482279685589,
87+
"status": "unconfirmed",
88+
"gasMultiplier": 1,
89+
"metamaskNetworkId": "3",
90+
"gasLimitSpecified": true,
91+
"estimatedGas": "0x1af75",
92+
"simulationFails": true
93+
}
94+
],
95+
"provider": {
96+
"type": "testnet"
97+
},
98+
"selectedAccount": "0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9",
99+
"seedWords": false,
100+
"isDisclaimerConfirmed": true,
101+
"unconfMsgs": {},
102+
"messages": [],
103+
"shapeShiftTxList": [],
104+
"keyringTypes": [
105+
"Simple Key Pair",
106+
"HD Key Tree"
107+
],
108+
"lostAccounts": []
109+
},
110+
"appState": {
111+
"menuOpen": false,
112+
"currentView": {
113+
"name": "confTx",
114+
"context": 0
115+
},
116+
"accountDetail": {
117+
"subview": "transactions"
118+
},
119+
"transForward": true,
120+
"isLoading": false,
121+
"warning": null
122+
},
123+
"identities": {}
124+
}

0 commit comments

Comments
 (0)