Merge pull request #1311 from MetaMask/mascara-publish

Mascara - docker support
feature/default_network_editable
Frankie 8 years ago committed by GitHub
commit 4a42ac86a0
  1. 3
      .dockerignore
  2. 22
      Dockerfile
  3. 11
      docker-compose.yml
  4. 8
      mascara/server/index.js
  5. 31
      mascara/src/mascara.js
  6. 2
      package.json

@ -0,0 +1,3 @@
node_modules
builds
development

@ -0,0 +1,22 @@
FROM node:6
MAINTAINER kumavis
# setup app dir
RUN mkdir -p /www/
WORKDIR /www/
# install dependencies
COPY ./package.json /www/package.json
RUN npm install
# 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

@ -0,0 +1,11 @@
metamascara:
build: ./
restart: always
ports:
- "9001"
environment:
MASCARA_ORIGIN: "https://zero.metamask.io"
VIRTUAL_PORT: "9001"
VIRTUAL_HOST: "zero.metamask.io"
LETSENCRYPT_HOST: "zero.metamask.io"
LETSENCRYPT_EMAIL: "admin@metamask.io"

@ -8,10 +8,10 @@ module.exports = createMetamascaraServer
function createMetamascaraServer(){ function createMetamascaraServer(){
// start bundlers // start bundlers
const metamascaraBundle = createBundle('./src/mascara.js') const metamascaraBundle = createBundle(__dirname + '/../src/mascara.js')
const proxyBundle = createBundle('./src/proxy.js') const proxyBundle = createBundle(__dirname + '/../src/proxy.js')
const uiBundle = createBundle('./src/ui.js') const uiBundle = createBundle(__dirname + '/../src/ui.js')
const backgroundBuild = createBundle('./src/background.js') const backgroundBuild = createBundle(__dirname + '/../src/background.js')
// serve bundles // serve bundles
const server = express() const server = express()

@ -1,44 +1,41 @@
const Web3 = require('web3') const Web3 = require('web3')
const setupProvider = require('./lib/setup-provider.js') const setupProvider = require('./lib/setup-provider.js')
const MASACARA_DOMAIN = 'http://localhost:9001' const MASCARA_ORIGIN = process.env.MASCARA_ORIGIN || 'http://localhost:9001'
console.log('MASCARA_ORIGIN:', MASCARA_ORIGIN)
// //
// setup web3 // setup web3
// //
var provider = setupProvider({ const provider = setupProvider({
mascaraUrl: MASACARA_DOMAIN + '/proxy/', mascaraUrl: MASCARA_ORIGIN + '/proxy/',
}) })
instrumentForUserInteractionTriggers(provider) instrumentForUserInteractionTriggers(provider)
var web3 = new Web3(provider) const web3 = new Web3(provider)
web3.setProvider = function(){ global.web3 = web3
console.log('MetaMask - overrode web3.setProvider')
}
// //
// // ui stuff
// export web3
// //
global.web3 = web3 let shouldPop = false
window.addEventListener('click', maybeTriggerPopup)
// //
// ui stuff // util
// //
var shouldPop = false function maybeTriggerPopup(){
window.addEventListener('click', function(){
if (!shouldPop) return if (!shouldPop) return
shouldPop = false shouldPop = false
window.open(MASACARA_DOMAIN, '', 'width=360 height=500') window.open(MASCARA_ORIGIN, '', 'width=360 height=500')
console.log('opening window...') console.log('opening window...')
}) }
function instrumentForUserInteractionTriggers(provider){ function instrumentForUserInteractionTriggers(provider){
var _super = provider.sendAsync.bind(provider) const _super = provider.sendAsync.bind(provider)
provider.sendAsync = function(payload, cb){ provider.sendAsync = function(payload, cb){
if (payload.method === 'eth_sendTransaction') { if (payload.method === 'eth_sendTransaction') {
console.log('saw send') console.log('saw send')

@ -33,6 +33,7 @@
] ]
} }
], ],
"envify",
"brfs" "brfs"
] ]
}, },
@ -127,6 +128,7 @@
"clone": "^1.0.2", "clone": "^1.0.2",
"deep-freeze-strict": "^1.1.1", "deep-freeze-strict": "^1.1.1",
"del": "^2.2.0", "del": "^2.2.0",
"envify": "^4.0.0",
"fs-promise": "^1.0.0", "fs-promise": "^1.0.0",
"gulp": "github:gulpjs/gulp#4.0", "gulp": "github:gulpjs/gulp#4.0",
"gulp-if": "^2.0.1", "gulp-if": "^2.0.1",

Loading…
Cancel
Save