Skip to content

Commit

Permalink
Merge branch 'develop' into 17191/onboarding-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmashuang authored Jan 23, 2023
2 parents af79d7d + 51518c4 commit 375bcaa
Show file tree
Hide file tree
Showing 19 changed files with 173 additions and 398 deletions.
24 changes: 0 additions & 24 deletions app/scripts/flask/snaps-blocklist.js

This file was deleted.

35 changes: 0 additions & 35 deletions app/scripts/flask/snaps-utilities.js

This file was deleted.

127 changes: 0 additions & 127 deletions app/scripts/flask/snaps-utilities.test.js

This file was deleted.

25 changes: 10 additions & 15 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ import {
} from '@metamask/snaps-controllers';
///: END:ONLY_INCLUDE_IN

import { wordlist as englishWordlist } from '@metamask/scure-bip39/dist/wordlists/english';

import browser from 'webextension-polyfill';
import {
AssetType,
Expand Down Expand Up @@ -169,10 +167,6 @@ import {
///: END:ONLY_INCLUDE_IN
} from './controllers/permissions';
import createRPCMethodTrackingMiddleware from './lib/createRPCMethodTrackingMiddleware';
///: BEGIN:ONLY_INCLUDE_IN(flask)
import { checkSnapsBlockList } from './flask/snaps-utilities';
import { SNAP_BLOCKLIST } from './flask/snaps-blocklist';
///: END:ONLY_INCLUDE_IN
import { securityProviderCheck } from './lib/security-provider-helpers';

export const METAMASK_CONTROLLER_EVENTS = {
Expand Down Expand Up @@ -741,7 +735,7 @@ export default class MetamaskController extends EventEmitter {
///: BEGIN:ONLY_INCLUDE_IN(flask)
this.snapExecutionService = new IframeExecutionService({
iframeUrl: new URL(
'https://metamask.github.io/iframe-execution-environment/0.11.1',
'https://metamask.github.io/iframe-execution-environment/0.12.0',
),
messenger: this.controllerMessenger.getRestricted({
name: 'ExecutionService',
Expand Down Expand Up @@ -776,15 +770,19 @@ export default class MetamaskController extends EventEmitter {
],
});

const isMain = process.env.METAMASK_BUILD_TYPE === 'main';
const isFlask = process.env.METAMASK_BUILD_TYPE === 'flask';

this.snapController = new SnapController({
environmentEndowmentPermissions: Object.values(EndowmentPermissions),
closeAllConnections: this.removeAllConnections.bind(this),
checkBlockList: async (snapsToCheck) => {
return checkSnapsBlockList(snapsToCheck, SNAP_BLOCKLIST);
},
state: initState.SnapController,
messenger: snapControllerMessenger,
featureFlags: { dappsCanUpdateSnaps: true },
featureFlags: {
dappsCanUpdateSnaps: true,
allowLocalSnaps: isFlask,
requireAllowlist: isMain,
},
});

this.notificationController = new NotificationController({
Expand Down Expand Up @@ -2579,10 +2577,7 @@ export default class MetamaskController extends EventEmitter {
throw new Error('Primary keyring mnemonic unavailable.');
}

const recoveredIndices = Array.from(
new Uint16Array(new Uint8Array(keyring.mnemonic).buffer),
);
return recoveredIndices.map((i) => englishWordlist[i]).join(' ');
return keyring.mnemonic;
}

//
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/metamask-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ describe('MetaMaskController', function () {
});

describe('getPrimaryKeyringMnemonic', function () {
it('should return a mnemonic as a string', function () {
it('should return a mnemonic as a Uint8Array', function () {
const mockMnemonic =
'above mercy benefit hospital call oval domain student sphere interest argue shock';
const mnemonicIndices = mockMnemonic
Expand All @@ -534,7 +534,7 @@ describe('MetaMaskController', function () {

const recoveredMnemonic = metamaskController.getPrimaryKeyringMnemonic();

assert.equal(recoveredMnemonic, mockMnemonic);
assert.equal(recoveredMnemonic, uint8ArrayMnemonic);
});
});

Expand Down
8 changes: 1 addition & 7 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@
"packages": {
"@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": true,
"@metamask/rpc-methods>@metamask/key-tree>@noble/secp256k1": true,
"@metamask/rpc-methods>@metamask/key-tree>@scure/bip39": true,
"@metamask/scure-bip39": true,
"@metamask/snaps-utils>@noble/hashes": true,
"@metamask/snaps-utils>@scure/base": true,
"@metamask/utils": true
Expand All @@ -1066,12 +1066,6 @@
"browserify>browser-resolve": true
}
},
"@metamask/rpc-methods>@metamask/key-tree>@scure/bip39": {
"packages": {
"@metamask/snaps-utils>@noble/hashes": true,
"@metamask/snaps-utils>@scure/base": true
}
},
"@metamask/rpc-methods>nanoid": {
"globals": {
"crypto.getRandomValues": true
Expand Down
35 changes: 14 additions & 21 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1035,19 +1035,16 @@
"globals": {
"WorkerGlobalScope": true,
"addEventListener": true,
"browser": true,
"chrome": true,
"location.origin": true,
"onmessage": "write",
"postMessage": true,
"removeEventListener": true
},
"packages": {
"@metamask/post-message-stream>@metamask/utils": true,
"@metamask/post-message-stream>readable-stream": true
}
},
"@metamask/post-message-stream>@metamask/utils": {
"packages": {
"eslint>fast-deep-equal": true
"@metamask/post-message-stream>readable-stream": true,
"@metamask/utils": true
}
},
"@metamask/post-message-stream>readable-stream": {
Expand Down Expand Up @@ -1114,10 +1111,10 @@
"@metamask/rpc-methods>@metamask/key-tree": true,
"@metamask/rpc-methods>nanoid": true,
"@metamask/snaps-ui": true,
"@metamask/snaps-ui>superstruct": true,
"@metamask/snaps-utils": true,
"@metamask/snaps-utils>@noble/hashes": true,
"@metamask/utils": true,
"@metamask/utils>superstruct": true,
"eth-rpc-errors": true
}
},
Expand All @@ -1139,7 +1136,7 @@
"packages": {
"@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": true,
"@metamask/rpc-methods>@metamask/key-tree>@noble/secp256k1": true,
"@metamask/rpc-methods>@metamask/key-tree>@scure/bip39": true,
"@metamask/scure-bip39": true,
"@metamask/snaps-utils>@noble/hashes": true,
"@metamask/snaps-utils>@scure/base": true,
"@metamask/utils": true
Expand All @@ -1161,12 +1158,6 @@
"browserify>browser-resolve": true
}
},
"@metamask/rpc-methods>@metamask/key-tree>@scure/bip39": {
"packages": {
"@metamask/snaps-utils>@noble/hashes": true,
"@metamask/snaps-utils>@scure/base": true
}
},
"@metamask/rpc-methods>nanoid": {
"globals": {
"crypto.getRandomValues": true
Expand Down Expand Up @@ -1216,13 +1207,13 @@
"@metamask/snaps-controllers": {
"globals": {
"URL": true,
"chrome.offscreen.createDocument": true,
"chrome.offscreen.hasDocument": true,
"clearTimeout": true,
"console.error": true,
"console.info": true,
"console.log": true,
"console.warn": true,
"document.body.appendChild": true,
"document.createElement": true,
"document.getElementById": true,
"fetch.bind": true,
"setTimeout": true
Expand Down Expand Up @@ -1406,23 +1397,25 @@
},
"@metamask/snaps-ui": {
"packages": {
"@metamask/snaps-ui>superstruct": true,
"@metamask/utils": true
"@metamask/utils": true,
"@metamask/utils>superstruct": true
}
},
"@metamask/snaps-utils": {
"globals": {
"TextDecoder": true,
"URL": true
"URL": true,
"document.body.appendChild": true,
"document.createElement": true
},
"packages": {
"@metamask/snaps-ui>superstruct": true,
"@metamask/snaps-utils>@noble/hashes": true,
"@metamask/snaps-utils>@scure/base": true,
"@metamask/snaps-utils>cron-parser": true,
"@metamask/snaps-utils>rfdc": true,
"@metamask/snaps-utils>validate-npm-package-name": true,
"@metamask/utils": true,
"@metamask/utils>superstruct": true,
"semver": true
}
},
Expand Down
Loading

0 comments on commit 375bcaa

Please sign in to comment.