Skip to content

Commit

Permalink
Merge pull request #13873 from MetaMask/Version-v10.11.1
Browse files Browse the repository at this point in the history
Version v10.11.1 RC
  • Loading branch information
danjm authored Mar 11, 2022
2 parents c86a642 + 0361aa6 commit d0b7aca
Show file tree
Hide file tree
Showing 18 changed files with 311 additions and 64 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [10.11.1]
### Changed
- Fixes GridPlus Lattice bugs by upgrading to `gridplus-sdk` v1.0.0, `eth-lattice-keyring` v0.5.0 and to compatibility with v0.14.0 ([#13834](https://github.com/MetaMask/metamask-extension/pull/13834))
- Increases transaction data in state logs
- Preserves fewer transactions with shared nonces across networks, decreasing number of old transactions that are not deleted ([#13669](https://github.com/MetaMask/metamask-extension/pull/13669))
- Increase the number of transactions saved in state logs to 60 ([#13743](https://github.com/MetaMask/metamask-extension/pull/13743))

### Fixed
- Ensure that MetaMask popup is shown when a user attempts to connect to a dapp they are already connected to ([#13840](https://github.com/MetaMask/metamask-extension/pull/13840))
- Submit correct gas limit for Swaps Smart Transactions ([#13891](https://github.com/MetaMask/metamask-extension/pull/13891))

## [10.11.0]
### Added
- Swaps: Add support for Smart Transactions on Mainnet and Rinkeby ([#12676](https://github.com/MetaMask/metamask-extension/pull/12676))
Expand Down Expand Up @@ -2764,7 +2775,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Uncategorized
- Added the ability to restore accounts from seed words.

[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.11.0...HEAD
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.11.1...HEAD
[10.11.1]: https://github.com/MetaMask/metamask-extension/compare/v10.11.0...v10.11.1
[10.11.0]: https://github.com/MetaMask/metamask-extension/compare/v10.10.2...v10.11.0
[10.10.2]: https://github.com/MetaMask/metamask-extension/compare/v10.10.1...v10.10.2
[10.10.1]: https://github.com/MetaMask/metamask-extension/compare/v10.10.0...v10.10.1
Expand Down
2 changes: 1 addition & 1 deletion app/manifest/_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"clipboardWrite",
"http://localhost:8545/",
"https://*.infura.io/",
"https://wallet.gridplus.io/*",
"https://lattice.gridplus.io/*",
"activeTab",
"webRequest",
"*://*.eth/",
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/controllers/transactions/tx-state-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ export default class TransactionStateManager extends EventEmitter {
const txsToDelete = transactions
.reverse()
.filter((tx) => {
const { nonce } = tx.txParams;
const { nonce, from } = tx.txParams;
const { chainId, metamaskNetworkId, status } = tx;
const key = `${nonce}-${chainId ?? metamaskNetworkId}`;
const key = `${nonce}-${chainId ?? metamaskNetworkId}-${from}`;
if (nonceNetworkSet.has(key)) {
return false;
} else if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function requestEthereumAccountsHandler(
// lock state when they were received.
try {
locks.add(origin);
await getUnlockPromise();
await getUnlockPromise(true);
res.result = await getAccounts();
end();
} catch (error) {
Expand Down
8 changes: 4 additions & 4 deletions app/scripts/lib/seed-phrase-verifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ const seedPhraseVerifier = {
* - The keyring always creates the accounts in the same sequence.
*
* @param {Array} createdAccounts - The accounts to restore
* @param {string} seedWords - The seed words to verify
* @returns {Promise<void>} Promises undefined
* @param {Buffer} seedPhrase - The seed words to verify, encoded as a Buffer
* @returns {Promise<void>}
*/
async verifyAccounts(createdAccounts, seedWords) {
async verifyAccounts(createdAccounts, seedPhrase) {
if (!createdAccounts || createdAccounts.length < 1) {
throw new Error('No created accounts defined.');
}

const keyringController = new KeyringController({});
const Keyring = keyringController.getKeyringClassForType('HD Key Tree');
const opts = {
mnemonic: seedWords,
mnemonic: seedPhrase,
numberOfAccounts: createdAccounts.length,
};

Expand Down
20 changes: 12 additions & 8 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ export default class MetamaskController extends EventEmitter {
this.networkController,
),
preferencesStore: this.preferencesController.store,
txHistoryLimit: 40,
txHistoryLimit: 60,
signTransaction: this.keyringController.signTransaction.bind(
this.keyringController,
),
Expand Down Expand Up @@ -1792,13 +1792,16 @@ export default class MetamaskController extends EventEmitter {
* Create a new Vault and restore an existent keyring.
*
* @param {string} password
* @param {string} seed
* @param {number[]} encodedSeedPhrase - The seed phrase, encoded as an array
* of UTF-8 bytes.
*/
async createNewVaultAndRestore(password, seed) {
async createNewVaultAndRestore(password, encodedSeedPhrase) {
const releaseLock = await this.createVaultMutex.acquire();
try {
let accounts, lastBalance;

const seedPhraseAsBuffer = Buffer.from(encodedSeedPhrase);

const { keyringController } = this;

// clear known identities
Expand All @@ -1819,7 +1822,7 @@ export default class MetamaskController extends EventEmitter {
// create new vault
const vault = await keyringController.createNewVaultAndRestore(
password,
seed,
seedPhraseAsBuffer,
);

const ethQuery = new EthQuery(this.provider);
Expand Down Expand Up @@ -2279,7 +2282,8 @@ export default class MetamaskController extends EventEmitter {
*
* Called when the first account is created and on unlocking the vault.
*
* @returns {Promise<string>} Seed phrase to be confirmed by the user.
* @returns {Promise<number[]>} The seed phrase to be confirmed by the user,
* encoded as an array of UTF-8 bytes.
*/
async verifySeedPhrase() {
const primaryKeyring = this.keyringController.getKeyringsByType(
Expand All @@ -2290,16 +2294,16 @@ export default class MetamaskController extends EventEmitter {
}

const serialized = await primaryKeyring.serialize();
const seedWords = serialized.mnemonic;
const seedPhraseAsBuffer = Buffer.from(serialized.mnemonic);

const accounts = await primaryKeyring.getAccounts();
if (accounts.length < 1) {
throw new Error('MetamaskController - No accounts found');
}

try {
await seedPhraseVerifier.verifyAccounts(accounts, seedWords);
return seedWords;
await seedPhraseVerifier.verifyAccounts(accounts, seedPhraseAsBuffer);
return Array.from(seedPhraseAsBuffer.values());
} catch (err) {
log.error(err.message);
throw err;
Expand Down
7 changes: 7 additions & 0 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,9 @@
}
},
"bip39": {
"globals": {
"console.log": true
},
"packages": {
"buffer": true,
"create-hash": true,
Expand Down Expand Up @@ -1889,6 +1892,7 @@
"eth-hd-keyring": {
"packages": {
"bip39": true,
"buffer": true,
"eth-sig-util": true,
"eth-simple-keyring": true,
"ethereumjs-wallet": true
Expand Down Expand Up @@ -1947,6 +1951,7 @@
"packages": {
"bip39": true,
"browser-passworder": true,
"buffer": true,
"eth-hd-keyring": true,
"eth-sig-util": true,
"eth-simple-keyring": true,
Expand Down Expand Up @@ -2337,6 +2342,7 @@
"gridplus-sdk": {
"globals": {
"console.error": true,
"console.warn": true,
"setTimeout": true
},
"packages": {
Expand All @@ -2350,6 +2356,7 @@
"crc-32": true,
"elliptic": true,
"eth-eip712-util-browser": true,
"hash.js": true,
"js-sha3": true,
"rlp-browser": true,
"secp256k1": true,
Expand Down
7 changes: 7 additions & 0 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,9 @@
}
},
"bip39": {
"globals": {
"console.log": true
},
"packages": {
"buffer": true,
"create-hash": true,
Expand Down Expand Up @@ -1908,6 +1911,7 @@
"eth-hd-keyring": {
"packages": {
"bip39": true,
"buffer": true,
"eth-sig-util": true,
"eth-simple-keyring": true,
"ethereumjs-wallet": true
Expand Down Expand Up @@ -1966,6 +1970,7 @@
"packages": {
"bip39": true,
"browser-passworder": true,
"buffer": true,
"eth-hd-keyring": true,
"eth-sig-util": true,
"eth-simple-keyring": true,
Expand Down Expand Up @@ -2356,6 +2361,7 @@
"gridplus-sdk": {
"globals": {
"console.error": true,
"console.warn": true,
"setTimeout": true
},
"packages": {
Expand All @@ -2369,6 +2375,7 @@
"crc-32": true,
"elliptic": true,
"eth-eip712-util-browser": true,
"hash.js": true,
"js-sha3": true,
"rlp-browser": true,
"secp256k1": true,
Expand Down
7 changes: 7 additions & 0 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,9 @@
}
},
"bip39": {
"globals": {
"console.log": true
},
"packages": {
"buffer": true,
"create-hash": true,
Expand Down Expand Up @@ -1889,6 +1892,7 @@
"eth-hd-keyring": {
"packages": {
"bip39": true,
"buffer": true,
"eth-sig-util": true,
"eth-simple-keyring": true,
"ethereumjs-wallet": true
Expand Down Expand Up @@ -1947,6 +1951,7 @@
"packages": {
"bip39": true,
"browser-passworder": true,
"buffer": true,
"eth-hd-keyring": true,
"eth-sig-util": true,
"eth-simple-keyring": true,
Expand Down Expand Up @@ -2337,6 +2342,7 @@
"gridplus-sdk": {
"globals": {
"console.error": true,
"console.warn": true,
"setTimeout": true
},
"packages": {
Expand All @@ -2350,6 +2356,7 @@
"crc-32": true,
"elliptic": true,
"eth-eip712-util-browser": true,
"hash.js": true,
"js-sha3": true,
"rlp-browser": true,
"secp256k1": true,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metamask-crx",
"version": "10.11.0",
"version": "10.11.1",
"private": true,
"repository": {
"type": "git",
Expand Down Expand Up @@ -150,7 +150,7 @@
"eth-json-rpc-infura": "^5.1.0",
"eth-json-rpc-middleware": "^8.0.0",
"eth-keyring-controller": "^6.2.0",
"eth-lattice-keyring": "^0.4.0",
"eth-lattice-keyring": "^0.5.0",
"eth-method-registry": "^2.0.0",
"eth-query": "^2.1.2",
"eth-rpc-errors": "^4.0.2",
Expand Down
99 changes: 99 additions & 0 deletions patches/bip39+2.5.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
diff --git a/node_modules/bip39/index.js b/node_modules/bip39/index.js
index aa0f29f..bee8008 100644
--- a/node_modules/bip39/index.js
+++ b/node_modules/bip39/index.js
@@ -48,7 +48,9 @@ function salt (password) {
}

function mnemonicToSeed (mnemonic, password) {
- var mnemonicBuffer = Buffer.from(unorm.nfkd(mnemonic), 'utf8')
+ var mnemonicBuffer = typeof mnemonic === 'string'
+ ? Buffer.from(unorm.nfkd(mnemonic), 'utf8')
+ : mnemonic
var saltBuffer = Buffer.from(salt(unorm.nfkd(password)), 'utf8')

return pbkdf2(mnemonicBuffer, saltBuffer, 2048, 64, 'sha512')
@@ -61,12 +63,28 @@ function mnemonicToSeedHex (mnemonic, password) {
function mnemonicToEntropy (mnemonic, wordlist) {
wordlist = wordlist || DEFAULT_WORDLIST

- var words = unorm.nfkd(mnemonic).split(' ')
+ var mnemonicAsBuffer = typeof mnemonic === 'string'
+ ? Buffer.from(unorm.nfkd(mnemonic), 'utf8')
+ : mnemonic
+
+ var words = [];
+ var currentWord = [];
+ for (const byte of mnemonicAsBuffer.values()) {
+ // split at space or \u3000 (ideographic space, for Japanese wordlists)
+ if (byte === 0x20 || byte === 0x3000) {
+ words.push(Buffer.from(currentWord));
+ currentWord = [];
+ } else {
+ currentWord.push(byte);
+ }
+ }
+ words.push(Buffer.from(currentWord));
+
if (words.length % 3 !== 0) throw new Error(INVALID_MNEMONIC)

// convert word indices to 11 bit binary strings
var bits = words.map(function (word) {
- var index = wordlist.indexOf(word)
+ var index = wordlist.indexOf(word.toString('utf8'))
if (index === -1) throw new Error(INVALID_MNEMONIC)

return lpad(index.toString(2), '0', 11)
@@ -104,12 +122,41 @@ function entropyToMnemonic (entropy, wordlist) {

var bits = entropyBits + checksumBits
var chunks = bits.match(/(.{1,11})/g)
- var words = chunks.map(function (binary) {
+ var wordsAsBuffers = chunks.map(function (binary) {
var index = binaryToByte(binary)
- return wordlist[index]
+ return Buffer.from(wordlist[index], 'utf8')
})

- return wordlist === JAPANESE_WORDLIST ? words.join('\u3000') : words.join(' ')
+ var bufferSize = wordsAsBuffers.reduce(function (bufferSize, wordAsBuffer, i) {
+ var shouldAddSeparator = i < wordsAsBuffers.length - 1
+ return (
+ bufferSize +
+ wordAsBuffer.length +
+ (shouldAddSeparator ? 1 : 0)
+ )
+ }, 0)
+ var separator = wordlist === JAPANESE_WORDLIST ? '\u3000' : ' '
+ var result = wordsAsBuffers.reduce(function (result, wordAsBuffer, i) {
+ var shouldAddSeparator = i < wordsAsBuffers.length - 1
+ result.workingBuffer.set(wordAsBuffer, result.offset)
+ if (shouldAddSeparator) {
+ result.workingBuffer.write(
+ separator,
+ result.offset + wordAsBuffer.length,
+ separator.length,
+ 'utf8'
+ )
+ }
+ return {
+ workingBuffer: result.workingBuffer,
+ offset: (
+ result.offset +
+ wordAsBuffer.length +
+ (shouldAddSeparator ? 1 : 0)
+ )
+ }
+ }, { workingBuffer: Buffer.alloc(bufferSize), offset: 0 })
+ return result.workingBuffer;
}

function generateMnemonic (strength, rng, wordlist) {
@@ -124,6 +171,7 @@ function validateMnemonic (mnemonic, wordlist) {
try {
mnemonicToEntropy(mnemonic, wordlist)
} catch (e) {
+ console.log('could not validate mnemonic', e)
return false
}

Loading

0 comments on commit d0b7aca

Please sign in to comment.