Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mascara - docker support #1311

Merged
merged 3 commits into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
builds
development
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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: "[email protected]"
8 changes: 4 additions & 4 deletions mascara/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ module.exports = createMetamascaraServer
function createMetamascaraServer(){

// start bundlers
const metamascaraBundle = createBundle('./src/mascara.js')
const proxyBundle = createBundle('./src/proxy.js')
const uiBundle = createBundle('./src/ui.js')
const backgroundBuild = createBundle('./src/background.js')
const metamascaraBundle = createBundle(__dirname + '/../src/mascara.js')
const proxyBundle = createBundle(__dirname + '/../src/proxy.js')
const uiBundle = createBundle(__dirname + '/../src/ui.js')
const backgroundBuild = createBundle(__dirname + '/../src/background.js')

// serve bundles
const server = express()
Expand Down
31 changes: 14 additions & 17 deletions mascara/src/mascara.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
const Web3 = require('web3')
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
//

var provider = setupProvider({
mascaraUrl: MASACARA_DOMAIN + '/proxy/',
const provider = setupProvider({
mascaraUrl: MASCARA_ORIGIN + '/proxy/',
})
instrumentForUserInteractionTriggers(provider)

var web3 = new Web3(provider)
web3.setProvider = function(){
console.log('MetaMask - overrode web3.setProvider')
}
const web3 = new Web3(provider)
global.web3 = web3

//
//
// export web3
// ui stuff
//

global.web3 = web3
let shouldPop = false
window.addEventListener('click', maybeTriggerPopup)

//
// ui stuff
// util
//

var shouldPop = false
window.addEventListener('click', function(){
function maybeTriggerPopup(){
if (!shouldPop) return
shouldPop = false
window.open(MASACARA_DOMAIN, '', 'width=360 height=500')
window.open(MASCARA_ORIGIN, '', 'width=360 height=500')
console.log('opening window...')
})

}

function instrumentForUserInteractionTriggers(provider){
var _super = provider.sendAsync.bind(provider)
const _super = provider.sendAsync.bind(provider)
provider.sendAsync = function(payload, cb){
if (payload.method === 'eth_sendTransaction') {
console.log('saw send')
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
]
}
],
"envify",
"brfs"
]
},
Expand Down Expand Up @@ -127,6 +128,7 @@
"clone": "^1.0.2",
"deep-freeze-strict": "^1.1.1",
"del": "^2.2.0",
"envify": "^4.0.0",
"fs-promise": "^1.0.0",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-if": "^2.0.1",
Expand Down