mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-21 17:37:01 +01:00
mascara - remove from project (#6283)
This commit is contained in:
parent
70e7e592ae
commit
48047f8194
@ -320,33 +320,6 @@ jobs:
|
||||
name: test:integration:flat
|
||||
command: npm run test:flat
|
||||
|
||||
test-integration-mascara-firefox:
|
||||
docker:
|
||||
- image: circleci/node:8.11.3-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: Install Firefox
|
||||
command: ./.circleci/scripts/firefox-install
|
||||
- run:
|
||||
name: test:integration:mascara
|
||||
command: npm run test:mascara
|
||||
|
||||
test-integration-mascara-chrome:
|
||||
environment:
|
||||
browsers: '["Chrome"]'
|
||||
docker:
|
||||
- image: circleci/node:8.11.3-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: test:integration:mascara
|
||||
command: npm run test:mascara
|
||||
|
||||
all-tests-pass:
|
||||
docker:
|
||||
- image: circleci/node:8.11.3-browsers
|
||||
|
@ -14,9 +14,6 @@ app/vendor/**
|
||||
|
||||
ui/lib/blockies.js
|
||||
|
||||
mascara/src/app/first-time/spinner.js
|
||||
mascara/test/jquery-3.1.0.min.js
|
||||
|
||||
test/integration/bundle.js
|
||||
test/integration/jquery-3.1.0.min.js
|
||||
test/integration/helpers.js
|
||||
|
@ -4,7 +4,6 @@ dist/
|
||||
docs/
|
||||
fonts/
|
||||
images/
|
||||
mascara/
|
||||
node_modules/
|
||||
notices/
|
||||
test/
|
||||
|
25
Dockerfile
25
Dockerfile
@ -1,25 +0,0 @@
|
||||
FROM node:7
|
||||
MAINTAINER kumavis
|
||||
|
||||
# setup app dir
|
||||
RUN mkdir -p /www/
|
||||
WORKDIR /www/
|
||||
|
||||
# install dependencies
|
||||
COPY ./package.json /www/package.json
|
||||
# RUN npm install -g node-gyp
|
||||
RUN npm install >> npm_log 2>> npm_err || true
|
||||
|
||||
RUN cat npm_log && cat npm_err
|
||||
|
||||
# copy over app dir
|
||||
COPY ./ /www/
|
||||
|
||||
# run tests
|
||||
# RUN npm test
|
||||
|
||||
# build app
|
||||
RUN npm run dist
|
||||
|
||||
# start server
|
||||
CMD node mascara/example/server.js
|
@ -102,7 +102,6 @@ setupMetamaskMeshMetrics()
|
||||
* @property {boolean} isInitialized - Whether the first vault has been created.
|
||||
* @property {boolean} isUnlocked - Whether the vault is currently decrypted and accounts are available for selection.
|
||||
* @property {boolean} isAccountMenuOpen - Represents whether the main account selection UI is currently displayed.
|
||||
* @property {boolean} isMascara - True if the current context is the extensionless MetaMascara project.
|
||||
* @property {boolean} isPopup - Returns true if the current view is an externally-triggered notification.
|
||||
* @property {string} rpcTarget - DEPRECATED - The URL of the current RPC provider.
|
||||
* @property {Object} identities - An object matching lower-case hex addresses to Identity objects with "address" and "name" (nickname) keys.
|
||||
|
@ -23,7 +23,6 @@ async function start () {
|
||||
const SHORT_SHA1 = CIRCLE_SHA1.slice(0, 7)
|
||||
const BUILD_LINK_BASE = `https://${CIRCLE_BUILD_NUM}-42009758-gh.circle-artifacts.com/0`
|
||||
|
||||
const MASCARA = `${BUILD_LINK_BASE}/builds/mascara/home.html`
|
||||
const CHROME = `${BUILD_LINK_BASE}/builds/metamask-chrome-${VERSION}.zip`
|
||||
const FIREFOX = `${BUILD_LINK_BASE}/builds/metamask-firefox-${VERSION}.zip`
|
||||
const EDGE = `${BUILD_LINK_BASE}/builds/metamask-edge-${VERSION}.zip`
|
||||
@ -34,7 +33,6 @@ async function start () {
|
||||
<details>
|
||||
<summary>
|
||||
Builds ready [${SHORT_SHA1}]:
|
||||
<a href="${MASCARA}">mascara</a>,
|
||||
<a href="${CHROME}">chrome</a>,
|
||||
<a href="${FIREFOX}">firefox</a>,
|
||||
<a href="${EDGE}">edge</a>,
|
||||
|
@ -3,7 +3,6 @@
|
||||
"isInitialized": true,
|
||||
"isUnlocked": true,
|
||||
"isAccountMenuOpen": false,
|
||||
"isMascara": false,
|
||||
"isPopup": false,
|
||||
"rpcTarget": "https://rawtestrpc.metamask.io/",
|
||||
"identities": {
|
||||
|
@ -2,7 +2,6 @@
|
||||
"metamask": {
|
||||
"isInitialized": true,
|
||||
"isUnlocked": true,
|
||||
"isMascara": false,
|
||||
"rpcTarget": "https://rawtestrpc.metamask.io/",
|
||||
"identities": {
|
||||
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825": {
|
||||
|
@ -1,11 +0,0 @@
|
||||
metamascara:
|
||||
build: ./
|
||||
restart: always
|
||||
ports:
|
||||
- "9001"
|
||||
environment:
|
||||
MASCARA_ORIGIN: "https://wallet.metamask.io"
|
||||
VIRTUAL_PORT: "9001"
|
||||
VIRTUAL_HOST: "wallet.metamask.io"
|
||||
LETSENCRYPT_HOST: "wallet.metamask.io"
|
||||
LETSENCRYPT_EMAIL: "admin@metamask.io"
|
53
gulpfile.js
53
gulpfile.js
@ -51,8 +51,6 @@ const browserPlatforms = [
|
||||
'opera',
|
||||
]
|
||||
const commonPlatforms = [
|
||||
// browser webapp
|
||||
'mascara',
|
||||
// browser extensions
|
||||
...browserPlatforms,
|
||||
]
|
||||
@ -110,14 +108,6 @@ createCopyTasks('manifest', {
|
||||
destinations: browserPlatforms.map(platform => `./dist/${platform}`),
|
||||
})
|
||||
|
||||
// copy mascara
|
||||
|
||||
createCopyTasks('html:mascara', {
|
||||
source: './mascara/',
|
||||
pattern: 'proxy/index.html',
|
||||
destinations: [`./dist/mascara/`],
|
||||
})
|
||||
|
||||
function createCopyTasks (label, opts) {
|
||||
if (!opts.devOnly) {
|
||||
const copyTaskName = `copy:${label}`
|
||||
@ -298,8 +288,6 @@ const buildJsFiles = [
|
||||
createTasksForBuildJsUIDeps({ dependenciesToBundle: uiDependenciesToBundle, filename: 'libs' })
|
||||
createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'dev:extension:js', devMode: true })
|
||||
createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'build:extension:js' })
|
||||
createTasksForBuildJsMascara({ taskPrefix: 'build:mascara:js' })
|
||||
createTasksForBuildJsMascara({ taskPrefix: 'dev:mascara:js', devMode: true })
|
||||
|
||||
function createTasksForBuildJsUIDeps ({ dependenciesToBundle, filename }) {
|
||||
const destinations = browserPlatforms.map(platform => `./dist/${platform}`)
|
||||
@ -340,22 +328,6 @@ function createTasksForBuildJsExtension ({ buildJsFiles, taskPrefix, devMode, bu
|
||||
createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinations, buildPhase1, buildPhase2 })
|
||||
}
|
||||
|
||||
function createTasksForBuildJsMascara ({ taskPrefix, devMode, bundleTaskOpts = {} }) {
|
||||
// inpage must be built before all other scripts:
|
||||
const rootDir = './mascara/src/'
|
||||
const buildPhase1 = ['ui', 'proxy', 'background', 'metamascara']
|
||||
const destinations = ['./dist/mascara']
|
||||
bundleTaskOpts = Object.assign({
|
||||
buildSourceMaps: true,
|
||||
sourceMapDir: './',
|
||||
minifyBuild: !devMode,
|
||||
buildWithFullPaths: devMode,
|
||||
watch: devMode,
|
||||
devMode,
|
||||
}, bundleTaskOpts)
|
||||
createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinations, buildPhase1 })
|
||||
}
|
||||
|
||||
function createTasksForBuildJs ({ rootDir, taskPrefix, bundleTaskOpts, destinations, buildPhase1 = [], buildPhase2 = [] }) {
|
||||
// bundle task for each file
|
||||
const jsFiles = [].concat(buildPhase1, buildPhase2)
|
||||
@ -405,7 +377,6 @@ gulp.task('dev',
|
||||
'dev:scss',
|
||||
gulp.parallel(
|
||||
'dev:extension:js',
|
||||
'dev:mascara:js',
|
||||
'dev:copy',
|
||||
'dev:reload'
|
||||
)
|
||||
@ -424,18 +395,6 @@ gulp.task('dev:extension',
|
||||
)
|
||||
)
|
||||
|
||||
gulp.task('dev:mascara',
|
||||
gulp.series(
|
||||
'clean',
|
||||
'dev:scss',
|
||||
gulp.parallel(
|
||||
'dev:mascara:js',
|
||||
'dev:copy',
|
||||
'dev:reload'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
gulp.task('build',
|
||||
gulp.series(
|
||||
'clean',
|
||||
@ -443,7 +402,6 @@ gulp.task('build',
|
||||
gulpParallel(
|
||||
'build:extension:js:uideps',
|
||||
'build:extension:js',
|
||||
'build:mascara:js',
|
||||
'copy'
|
||||
)
|
||||
)
|
||||
@ -460,17 +418,6 @@ gulp.task('build:extension',
|
||||
)
|
||||
)
|
||||
|
||||
gulp.task('build:mascara',
|
||||
gulp.series(
|
||||
'clean',
|
||||
'build:scss',
|
||||
gulp.parallel(
|
||||
'build:mascara:js',
|
||||
'copy'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
gulp.task('dist',
|
||||
gulp.series(
|
||||
'build',
|
||||
|
@ -1,33 +0,0 @@
|
||||
start the dual servers (dapp + mascara)
|
||||
```
|
||||
npm run mascara
|
||||
```
|
||||
|
||||
### First time use:
|
||||
|
||||
- navigate to: http://localhost:9001
|
||||
- Create an Account
|
||||
- go back to http://localhost:9002
|
||||
- open devTools
|
||||
- click Sync Tx
|
||||
|
||||
### Tests:
|
||||
|
||||
```
|
||||
npm run testMascara
|
||||
```
|
||||
|
||||
Test will run in browser, you will have to have these browsers installed:
|
||||
|
||||
- Chrome
|
||||
- Firefox
|
||||
- Opera
|
||||
|
||||
|
||||
### Deploy:
|
||||
|
||||
Will build and deploy mascara via docker
|
||||
|
||||
```
|
||||
docker-compose build && docker-compose stop && docker-compose up -d && docker-compose logs --tail 200 -f
|
||||
```
|
@ -1,38 +0,0 @@
|
||||
const EthQuery = require('ethjs-query')
|
||||
|
||||
window.addEventListener('load', loadProvider)
|
||||
window.addEventListener('message', console.warn)
|
||||
|
||||
async function loadProvider () {
|
||||
const ethereumProvider = window.metamask.createDefaultProvider({ host: 'http://localhost:9001' })
|
||||
const ethQuery = new EthQuery(ethereumProvider)
|
||||
const accounts = await ethQuery.accounts()
|
||||
window.METAMASK_ACCOUNT = accounts[0] || 'locked'
|
||||
logToDom(accounts.length ? accounts[0] : 'LOCKED or undefined', 'account')
|
||||
setupButtons(ethQuery)
|
||||
}
|
||||
|
||||
|
||||
function logToDom (message, context) {
|
||||
document.getElementById(context).innerText = message
|
||||
console.log(message)
|
||||
}
|
||||
|
||||
function setupButtons (ethQuery) {
|
||||
const accountButton = document.getElementById('action-button-1')
|
||||
accountButton.addEventListener('click', async () => {
|
||||
const accounts = await ethQuery.accounts()
|
||||
window.METAMASK_ACCOUNT = accounts[0] || 'locked'
|
||||
logToDom(accounts.length ? accounts[0] : 'LOCKED or undefined', 'account')
|
||||
})
|
||||
const txButton = document.getElementById('action-button-2')
|
||||
txButton.addEventListener('click', async () => {
|
||||
if (!window.METAMASK_ACCOUNT || window.METAMASK_ACCOUNT === 'locked') return
|
||||
const txHash = await ethQuery.sendTransaction({
|
||||
from: window.METAMASK_ACCOUNT,
|
||||
to: window.METAMASK_ACCOUNT,
|
||||
data: '',
|
||||
})
|
||||
logToDom(txHash, 'cb-value')
|
||||
})
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="http://localhost:9001/metamascara.js"></script>
|
||||
<title>MetaMask ZeroClient Example</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<button id="action-button-1">GET ACCOUNT</button>
|
||||
<div id="account"></div>
|
||||
<button id="action-button-2">SEND TRANSACTION</button>
|
||||
<div id="cb-value" ></div>
|
||||
<script src="./app.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,31 +0,0 @@
|
||||
const express = require('express')
|
||||
const path = require('path')
|
||||
const createMetamascaraServer = require('../server/')
|
||||
const createBundle = require('../server/util').createBundle
|
||||
const serveBundle = require('../server/util').serveBundle
|
||||
//
|
||||
// Iframe Server
|
||||
//
|
||||
|
||||
const mascaraServer = createMetamascaraServer()
|
||||
|
||||
// start the server
|
||||
const mascaraPort = 9001
|
||||
mascaraServer.listen(mascaraPort)
|
||||
console.log(`Mascara service listening on port ${mascaraPort}`)
|
||||
|
||||
|
||||
//
|
||||
// Dapp Server
|
||||
//
|
||||
|
||||
const dappServer = express()
|
||||
|
||||
// serve dapp bundle
|
||||
serveBundle(dappServer, '/app.js', createBundle(require.resolve('./app.js')))
|
||||
dappServer.use(express.static(path.join(__dirname, '/app/')))
|
||||
|
||||
// start the server
|
||||
const dappPort = '9002'
|
||||
dappServer.listen(dappPort)
|
||||
console.log(`Dapp listening on port ${dappPort}`)
|
@ -1,20 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>MetaMask ZeroClient Iframe</title>
|
||||
<meta name="description" content="MetaMask ZeroClient">
|
||||
<meta name="author" content="MetaMask">
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
Hello! I am the MetaMask iframe.
|
||||
<script src="./proxy.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,21 +0,0 @@
|
||||
const path = require('path')
|
||||
const express = require('express')
|
||||
const compression = require('compression')
|
||||
|
||||
module.exports = createMetamascaraServer
|
||||
|
||||
|
||||
function createMetamascaraServer () {
|
||||
|
||||
// setup server
|
||||
const server = express()
|
||||
server.use(compression())
|
||||
|
||||
// serve assets
|
||||
server.use(express.static(path.join(__dirname, '/../ui/'), { setHeaders: (res) => res.set('X-Frame-Options', 'DENY') }))
|
||||
server.use(express.static(path.join(__dirname, '/../../dist/mascara')))
|
||||
server.use(express.static(path.join(__dirname, '/../proxy')))
|
||||
|
||||
return server
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
const browserify = require('browserify')
|
||||
const watchify = require('watchify')
|
||||
|
||||
module.exports = {
|
||||
serveBundle,
|
||||
createBundle,
|
||||
}
|
||||
|
||||
|
||||
function serveBundle (server, path, bundle) {
|
||||
server.get(path, function (req, res) {
|
||||
res.setHeader('Content-Type', 'application/javascript; charset=UTF-8')
|
||||
res.send(bundle.latest)
|
||||
})
|
||||
}
|
||||
|
||||
function createBundle (entryPoint) {
|
||||
|
||||
var bundleContainer = {}
|
||||
|
||||
var bundler = browserify({
|
||||
entries: [entryPoint],
|
||||
cache: {},
|
||||
packageCache: {},
|
||||
plugin: [watchify],
|
||||
})
|
||||
.transform('babelify')
|
||||
.transform('uglifyify', { global: true })
|
||||
|
||||
bundler.on('update', bundle)
|
||||
bundle()
|
||||
|
||||
return bundleContainer
|
||||
|
||||
function bundle () {
|
||||
bundler.bundle(function (err, result) {
|
||||
if (err) {
|
||||
console.log(`Bundle failed! (${entryPoint})`)
|
||||
console.error(err)
|
||||
return
|
||||
}
|
||||
console.log(`Bundle updated! (${entryPoint})`)
|
||||
bundleContainer.latest = result.toString()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
global.window = global
|
||||
|
||||
const SwGlobalListener = require('sw-stream/lib/sw-global-listener.js')
|
||||
const connectionListener = new SwGlobalListener(global)
|
||||
const setupMultiplex = require('../../app/scripts/lib/stream-utils.js').setupMultiplex
|
||||
|
||||
const DbController = require('idb-global')
|
||||
|
||||
const SwPlatform = require('../../app/scripts/platforms/sw')
|
||||
const MetamaskController = require('../../app/scripts/metamask-controller')
|
||||
|
||||
const Migrator = require('../../app/scripts/lib/migrator/')
|
||||
const migrations = require('../../app/scripts/migrations/')
|
||||
const firstTimeState = require('../../app/scripts/first-time-state')
|
||||
|
||||
const STORAGE_KEY = 'metamask-config'
|
||||
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
|
||||
global.metamaskPopupIsOpen = false
|
||||
|
||||
const log = require('loglevel')
|
||||
global.log = log
|
||||
log.setDefaultLevel(METAMASK_DEBUG ? 'debug' : 'warn')
|
||||
|
||||
global.addEventListener('install', function (event) {
|
||||
event.waitUntil(global.skipWaiting())
|
||||
})
|
||||
global.addEventListener('activate', function (event) {
|
||||
event.waitUntil(global.clients.claim())
|
||||
})
|
||||
|
||||
log.debug('inside:open')
|
||||
|
||||
// state persistence
|
||||
const dbController = new DbController({
|
||||
key: STORAGE_KEY,
|
||||
})
|
||||
|
||||
start().catch(log.error)
|
||||
|
||||
async function start () {
|
||||
log.debug('MetaMask initializing...')
|
||||
const initState = await loadStateFromPersistence()
|
||||
await setupController(initState)
|
||||
log.debug('MetaMask initialization complete.')
|
||||
}
|
||||
|
||||
//
|
||||
// State and Persistence
|
||||
//
|
||||
async function loadStateFromPersistence () {
|
||||
// migrations
|
||||
const migrator = new Migrator({ migrations })
|
||||
const initialState = migrator.generateInitialState(firstTimeState)
|
||||
dbController.initialState = initialState
|
||||
const versionedData = await dbController.open()
|
||||
const migratedData = await migrator.migrateData(versionedData)
|
||||
await dbController.put(migratedData)
|
||||
return migratedData.data
|
||||
}
|
||||
|
||||
async function setupController (initState, client) {
|
||||
|
||||
//
|
||||
// MetaMask Controller
|
||||
//
|
||||
|
||||
const platform = new SwPlatform()
|
||||
|
||||
const controller = new MetamaskController({
|
||||
// platform specific implementation
|
||||
platform,
|
||||
// User confirmation callbacks:
|
||||
showUnconfirmedMessage: noop,
|
||||
unlockAccountMessage: noop,
|
||||
showUnapprovedTx: noop,
|
||||
// initial state
|
||||
initState,
|
||||
})
|
||||
global.metamaskController = controller
|
||||
|
||||
controller.store.subscribe(async (state) => {
|
||||
try {
|
||||
const versionedData = await versionifyData(state)
|
||||
await dbController.put(versionedData)
|
||||
} catch (e) { console.error('METAMASK Error:', e) }
|
||||
})
|
||||
|
||||
async function versionifyData (state) {
|
||||
const rawData = await dbController.get()
|
||||
return {
|
||||
data: state,
|
||||
meta: rawData.meta,
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// connect to other contexts
|
||||
//
|
||||
|
||||
connectionListener.on('remote', (portStream, messageEvent) => {
|
||||
log.debug('REMOTE CONECTION FOUND***********')
|
||||
connectRemote(portStream, messageEvent.data.context)
|
||||
})
|
||||
|
||||
function connectRemote (connectionStream, context) {
|
||||
var isMetaMaskInternalProcess = (context === 'popup')
|
||||
if (isMetaMaskInternalProcess) {
|
||||
// communication with popup
|
||||
controller.setupTrustedCommunication(connectionStream, 'MetaMask')
|
||||
global.metamaskPopupIsOpen = true
|
||||
} else {
|
||||
// communication with page
|
||||
setupUntrustedCommunication(connectionStream, context)
|
||||
}
|
||||
}
|
||||
|
||||
function setupUntrustedCommunication (connectionStream, originDomain) {
|
||||
// setup multiplexing
|
||||
var mx = setupMultiplex(connectionStream)
|
||||
// connect features
|
||||
controller.setupProviderConnection(mx.createStream('provider'), originDomain)
|
||||
controller.setupPublicConfig(mx.createStream('publicConfig'))
|
||||
}
|
||||
}
|
||||
// // this will be useful later but commented out for linting for now (liiiinting)
|
||||
// function sendMessageToAllClients (message) {
|
||||
// global.clients.matchAll().then(function (clients) {
|
||||
// clients.forEach(function (client) {
|
||||
// client.postMessage(message)
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
|
||||
function noop () {}
|
@ -1 +0,0 @@
|
||||
global.metamask = require('metamascara')
|
@ -1,25 +0,0 @@
|
||||
const createParentStream = require('iframe-stream').ParentStream
|
||||
const SwController = require('sw-controller')
|
||||
const SwStream = require('sw-stream/lib/sw-stream.js')
|
||||
|
||||
const keepAliveDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000
|
||||
const background = new SwController({
|
||||
fileName: './scripts/background.js',
|
||||
keepAlive: true,
|
||||
keepAliveInterval: 30000,
|
||||
keepAliveDelay,
|
||||
})
|
||||
|
||||
const pageStream = createParentStream()
|
||||
background.on('ready', () => {
|
||||
const swStream = SwStream({
|
||||
serviceWorker: background.controller,
|
||||
context: 'dapp',
|
||||
})
|
||||
pageStream.pipe(swStream).pipe(pageStream)
|
||||
|
||||
})
|
||||
background.on('updatefound', () => window.location.reload())
|
||||
|
||||
background.on('error', console.error)
|
||||
background.startWorker()
|
@ -1,73 +0,0 @@
|
||||
const injectCss = require('inject-css')
|
||||
const SwController = require('sw-controller')
|
||||
const SwStream = require('sw-stream')
|
||||
const MetaMaskUiCss = require('../../ui/css')
|
||||
const MetamascaraPlatform = require('../../app/scripts/platforms/window')
|
||||
const startPopup = require('../../app/scripts/popup-core')
|
||||
|
||||
// create platform global
|
||||
global.platform = new MetamascaraPlatform()
|
||||
|
||||
var css = MetaMaskUiCss()
|
||||
injectCss(css)
|
||||
const container = document.getElementById('app-content')
|
||||
|
||||
const name = 'popup'
|
||||
window.METAMASK_UI_TYPE = name
|
||||
window.METAMASK_PLATFORM_TYPE = 'mascara'
|
||||
|
||||
const keepAliveDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000
|
||||
|
||||
const swController = new SwController({
|
||||
fileName: './background.js',
|
||||
keepAlive: true,
|
||||
keepAliveDelay,
|
||||
keepAliveInterval: 20000,
|
||||
})
|
||||
|
||||
swController.once('updatefound', windowReload)
|
||||
swController.once('ready', async () => {
|
||||
try {
|
||||
swController.removeListener('updatefound', windowReload)
|
||||
console.log('swController ready')
|
||||
await timeout(1000)
|
||||
console.log('connecting to app')
|
||||
await connectApp()
|
||||
console.log('app connected')
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
})
|
||||
|
||||
console.log('starting service worker')
|
||||
swController.startWorker()
|
||||
|
||||
// Setup listener for when the service worker is read
|
||||
function connectApp () {
|
||||
const connectionStream = SwStream({
|
||||
serviceWorker: swController.getWorker(),
|
||||
context: name,
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
startPopup({ container, connectionStream }, (err, store) => {
|
||||
console.log('hello from MetaMascara ui!')
|
||||
if (err) reject(err)
|
||||
store.subscribe(() => {
|
||||
const state = store.getState()
|
||||
if (state.appState.shouldClose) window.close()
|
||||
})
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function windowReload () {
|
||||
if (window.METAMASK_SKIP_RELOAD) return
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
function timeout (time) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, time || 1500)
|
||||
})
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
export default function wait (time) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
setTimeout(function () {
|
||||
resolve()
|
||||
}, time * 3 || 1500)
|
||||
})
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var browserify = require('browserify')
|
||||
var tests = fs.readdirSync(path.join(__dirname, 'lib'))
|
||||
var bundlePath = path.join(__dirname, 'test-bundle.js')
|
||||
var b = browserify()
|
||||
|
||||
// Remove old bundle
|
||||
try {
|
||||
fs.unlinkSync(bundlePath)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
|
||||
var writeStream = fs.createWriteStream(bundlePath)
|
||||
|
||||
tests.forEach(function (fileName) {
|
||||
b.add(path.join(__dirname, 'lib', fileName))
|
||||
})
|
||||
|
||||
b.bundle().pipe(writeStream)
|
||||
|
4
mascara/test/jquery-3.1.0.min.js
vendored
4
mascara/test/jquery-3.1.0.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,10 +0,0 @@
|
||||
window.addEventListener('load', () => {
|
||||
window.METAMASK_SKIP_RELOAD = true
|
||||
// inject app container
|
||||
const body = document.body
|
||||
const container = document.createElement('div')
|
||||
container.id = 'app-content'
|
||||
body.appendChild(container)
|
||||
// start ui
|
||||
require('../src/ui.js')
|
||||
})
|
@ -1,42 +0,0 @@
|
||||
const EventEmitter = require('events')
|
||||
const IDB = require('idb-global')
|
||||
const KEY = 'metamask-test-config'
|
||||
module.exports = class Helper extends EventEmitter {
|
||||
|
||||
tryToCleanContext () {
|
||||
this.unregister()
|
||||
.then(() => this.clearDb())
|
||||
.then(() => super.emit('complete'))
|
||||
.catch((err) => {
|
||||
if (err) {
|
||||
super.emit('complete')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
unregister () {
|
||||
return global.navigator.serviceWorker.getRegistration()
|
||||
.then((registration) => {
|
||||
if (registration) {
|
||||
return registration.unregister()
|
||||
.then((b) => b ? Promise.resolve() : Promise.reject())
|
||||
} else return Promise.resolve()
|
||||
})
|
||||
}
|
||||
clearDb () {
|
||||
return new Promise((resolve, reject) => {
|
||||
const deleteRequest = global.indexDB.deleteDatabase(KEY)
|
||||
deleteRequest.addEventListener('success', resolve)
|
||||
deleteRequest.addEventListener('error', reject)
|
||||
})
|
||||
|
||||
}
|
||||
mockState (state) {
|
||||
const db = new IDB({
|
||||
version: 2,
|
||||
key: KEY,
|
||||
initialState: state,
|
||||
})
|
||||
return db.open()
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>MetaMascara Alpha</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app-content"></div>
|
||||
<script src="./scripts/ui.js" type="text/javascript" charset="utf-8"></script>
|
||||
</body>
|
||||
</html>
|
17
package.json
17
package.json
@ -4,7 +4,6 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "gulp dev:extension",
|
||||
"mascara": "gulp dev:mascara & node ./mascara/example/server",
|
||||
"dist": "gulp dist",
|
||||
"doc": "jsdoc -c development/tools/.jsdoc.json",
|
||||
"publish-docs": "gh-pages -d docs/jsdocs",
|
||||
@ -12,7 +11,7 @@
|
||||
"watch:test:unit": "nodemon --exec \"npm run test:unit\" ./test ./app ./ui",
|
||||
"test:unit": "cross-env METAMASK_ENV=test mocha --exit --require test/setup.js --recursive \"test/unit/**/*.js\" \"ui/app/**/*.test.js\"",
|
||||
"test:single": "cross-env METAMASK_ENV=test mocha --require test/helper.js",
|
||||
"test:integration": "npm run test:integration:build && npm run test:flat && npm run test:mascara",
|
||||
"test:integration": "npm run test:integration:build && npm run test:flat",
|
||||
"test:integration:build": "gulp build:scss",
|
||||
"test:e2e:drizzle:beta": "SELENIUM_BROWSER=chrome test/e2e/beta/run-drizzle.sh",
|
||||
"test:e2e:chrome": "SELENIUM_BROWSER=chrome test/e2e/beta/run-all.sh",
|
||||
@ -27,12 +26,6 @@
|
||||
"test:flat:build:states": "node development/genStates.js",
|
||||
"test:flat:build:locales": "mkdirp dist/chrome && cp -R app/_locales dist/chrome/_locales",
|
||||
"test:flat:build:ui": "npm run test:flat:build:states && browserify ./development/mock-dev.js -o ./development/bundle.js",
|
||||
"test:mascara": "npm run test:mascara:build && karma start test/mascara.conf.js",
|
||||
"test:mascara:build": "mkdirp dist/mascara && npm run test:mascara:build:ui && npm run test:mascara:build:background && npm run test:mascara:build:tests && npm run test:mascara:build:locales",
|
||||
"test:mascara:build:ui": "browserify mascara/test/test-ui.js -o dist/mascara/ui.js",
|
||||
"test:mascara:build:locales": "mkdirp dist/chrome && cp -R app/_locales dist/chrome/_locales",
|
||||
"test:mascara:build:background": "browserify mascara/src/background.js -o dist/mascara/background.js",
|
||||
"test:mascara:build:tests": "browserify test/integration/lib/first-time.js -o dist/mascara/tests.js",
|
||||
"ganache:start": "ganache-cli --noVMErrorsOnRPCResponse -i 5777 -m 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'",
|
||||
"sentry:publish": "node ./development/sentry-publish.js",
|
||||
"lint": "eslint .",
|
||||
@ -130,7 +123,6 @@
|
||||
"ethjs-contract": "^0.2.3",
|
||||
"ethjs-ens": "^2.0.0",
|
||||
"ethjs-query": "^0.3.4",
|
||||
"express": "^4.15.5",
|
||||
"extension-link-enabler": "^1.0.0",
|
||||
"extension-port-stream": "^1.0.0",
|
||||
"extensionizer": "^1.0.1",
|
||||
@ -139,10 +131,7 @@
|
||||
"fuse.js": "^3.2.0",
|
||||
"hat": "0.0.3",
|
||||
"human-standard-token-abi": "^2.0.0",
|
||||
"idb-global": "^2.1.0",
|
||||
"identicon.js": "^2.3.1",
|
||||
"iframe": "^1.0.0",
|
||||
"iframe-stream": "^3.0.0",
|
||||
"inject-css": "^0.1.1",
|
||||
"jazzicon": "^1.2.0",
|
||||
"json-rpc-engine": "^4.0.0",
|
||||
@ -154,7 +143,6 @@
|
||||
"lodash.uniqby": "^4.7.0",
|
||||
"loglevel": "^1.4.1",
|
||||
"luxon": "^1.8.2",
|
||||
"metamascara": "^2.0.0",
|
||||
"metamask-inpage-provider": "^1.3.0",
|
||||
"metamask-logo": "^2.1.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
@ -207,8 +195,6 @@
|
||||
"semver": "^5.4.1",
|
||||
"shallow-copy": "0.0.1",
|
||||
"single-call-balance-checker-abi": "^1.0.0",
|
||||
"sw-controller": "^1.0.3",
|
||||
"sw-stream": "^2.0.2",
|
||||
"swappable-obj-proxy": "^1.1.0",
|
||||
"textarea-caret": "^3.0.1",
|
||||
"valid-url": "^1.0.9",
|
||||
@ -238,7 +224,6 @@
|
||||
"chai": "^4.1.0",
|
||||
"chromedriver": "^2.41.0",
|
||||
"clipboardy": "^1.2.3",
|
||||
"compression": "^1.7.1",
|
||||
"coveralls": "^3.0.0",
|
||||
"cross-env": "^5.1.4",
|
||||
"css-loader": "^0.28.11",
|
||||
|
@ -1,17 +0,0 @@
|
||||
const getBaseConfig = require('./base.conf.js')
|
||||
|
||||
module.exports = function (config) {
|
||||
const settings = getBaseConfig(config)
|
||||
|
||||
// ui and tests
|
||||
settings.files.push('dist/mascara/ui.js')
|
||||
settings.files.push('dist/mascara/tests.js')
|
||||
// service worker background
|
||||
settings.files.push({ pattern: 'dist/mascara/background.js', watched: false, included: false, served: true })
|
||||
settings.proxies['/background.js'] = '/base/dist/mascara/background.js'
|
||||
|
||||
// use this to keep the browser open for debugging
|
||||
settings.browserNoActivityTimeout = 10000000
|
||||
|
||||
config.set(settings)
|
||||
}
|
@ -312,7 +312,6 @@ App.propTypes = {
|
||||
sidebar: PropTypes.object,
|
||||
alertOpen: PropTypes.bool,
|
||||
hideSidebar: PropTypes.func,
|
||||
isMascara: PropTypes.bool,
|
||||
isOnboarding: PropTypes.bool,
|
||||
isUnlocked: PropTypes.bool,
|
||||
networkDropdownOpen: PropTypes.bool,
|
||||
@ -388,7 +387,6 @@ function mapStateToProps (state) {
|
||||
currentView: state.appState.currentView,
|
||||
activeAddress: state.appState.activeAddress,
|
||||
transForward: state.appState.transForward,
|
||||
isMascara: state.metamask.isMascara,
|
||||
isOnboarding: Boolean(!noActiveNotices || seedWords || !isInitialized),
|
||||
isPopup: state.metamask.isPopup,
|
||||
seedWords: state.metamask.seedWords,
|
||||
|
@ -12,7 +12,6 @@ export default class MenuBar extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
hideSidebar: PropTypes.func,
|
||||
isMascara: PropTypes.bool,
|
||||
sidebarOpen: PropTypes.bool,
|
||||
showSidebar: PropTypes.func,
|
||||
}
|
||||
@ -21,7 +20,7 @@ export default class MenuBar extends PureComponent {
|
||||
|
||||
render () {
|
||||
const { t } = this.context
|
||||
const { isMascara, sidebarOpen, hideSidebar, showSidebar } = this.props
|
||||
const { sidebarOpen, hideSidebar, showSidebar } = this.props
|
||||
const { accountDetailsMenuOpen } = this.state
|
||||
|
||||
return (
|
||||
@ -45,29 +44,27 @@ export default class MenuBar extends PureComponent {
|
||||
/>
|
||||
</Tooltip>
|
||||
<SelectedAccount />
|
||||
{
|
||||
!isMascara && (
|
||||
<Tooltip
|
||||
title={t('accountOptions')}
|
||||
position="bottom"
|
||||
>
|
||||
<div
|
||||
className="fa fa-ellipsis-h fa-lg menu-bar__open-in-browser"
|
||||
onClick={() => {
|
||||
this.context.metricsEvent({
|
||||
eventOpts: {
|
||||
category: 'Navigation',
|
||||
action: 'Home',
|
||||
name: 'Opened Account Options',
|
||||
},
|
||||
})
|
||||
this.setState({ accountDetailsMenuOpen: true })
|
||||
}}
|
||||
>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
<Tooltip
|
||||
title={t('accountOptions')}
|
||||
position="bottom"
|
||||
>
|
||||
<div
|
||||
className="fa fa-ellipsis-h fa-lg menu-bar__open-in-browser"
|
||||
onClick={() => {
|
||||
this.context.metricsEvent({
|
||||
eventOpts: {
|
||||
category: 'Navigation',
|
||||
action: 'Home',
|
||||
name: 'Opened Account Options',
|
||||
},
|
||||
})
|
||||
this.setState({ accountDetailsMenuOpen: true })
|
||||
}}
|
||||
>
|
||||
</div>
|
||||
</Tooltip>
|
||||
|
||||
{
|
||||
accountDetailsMenuOpen && (
|
||||
<AccountDetailsDropdown
|
||||
|
@ -4,11 +4,10 @@ import MenuBar from './menu-bar.component'
|
||||
import { showSidebar, hideSidebar } from '../../actions'
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const { appState: { sidebar: { isOpen }, isMascara } } = state
|
||||
const { appState: { sidebar: { isOpen } } } = state
|
||||
|
||||
return {
|
||||
sidebarOpen: isOpen,
|
||||
isMascara,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
const extend = require('xtend')
|
||||
const actions = require('../actions')
|
||||
const MetamascaraPlatform = require('../../../app/scripts/platforms/window')
|
||||
const { getEnvironmentType } = require('../../../app/scripts/lib/util')
|
||||
const { ENVIRONMENT_TYPE_POPUP } = require('../../../app/scripts/lib/enums')
|
||||
const { OLD_UI_NETWORK_TYPE } = require('../../../app/scripts/controllers/network/enums')
|
||||
@ -15,7 +14,6 @@ function reduceMetamask (state, action) {
|
||||
isInitialized: false,
|
||||
isUnlocked: false,
|
||||
isAccountMenuOpen: false,
|
||||
isMascara: window.platform instanceof MetamascaraPlatform,
|
||||
isPopup: getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP,
|
||||
rpcTarget: 'https://rawtestrpc.metamask.io/',
|
||||
identities: {},
|
||||
|
Loading…
Reference in New Issue
Block a user